mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-09 07:08:58 +00:00
Merge pull request #153 from jwetzell/fix/serial-client-closing
close serial client more reliably
This commit is contained in:
@@ -125,6 +125,9 @@ func (sc *SerialClient) Start(ctx context.Context, router common.RouteIO) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if sc.ctx.Err() != nil {
|
if sc.ctx.Err() != nil {
|
||||||
sc.logger.Debug("done")
|
sc.logger.Debug("done")
|
||||||
|
if sc.port != nil {
|
||||||
|
sc.port.Close()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
sc.logger.Error("port setup error", "port", sc.Port, "error", err.Error())
|
sc.logger.Error("port setup error", "port", sc.Port, "error", err.Error())
|
||||||
@@ -136,6 +139,9 @@ func (sc *SerialClient) Start(ctx context.Context, router common.RouteIO) error
|
|||||||
select {
|
select {
|
||||||
case <-sc.ctx.Done():
|
case <-sc.ctx.Done():
|
||||||
sc.logger.Debug("done")
|
sc.logger.Debug("done")
|
||||||
|
if sc.port != nil {
|
||||||
|
sc.port.Close()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
READ:
|
READ:
|
||||||
|
|||||||
Reference in New Issue
Block a user