File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020 "encoding/base64"
2121 "io"
2222 "strconv"
23+ "sync/atomic"
2324 "time"
2425
2526 log "github.com/sirupsen/logrus"
@@ -42,7 +43,7 @@ type serport struct {
4243
4344 // Keep track of whether we're being actively closed
4445 // just so we don't show scary error messages
45- isClosing bool
46+ isClosing atomic. Bool
4647
4748 isClosingDueToError bool
4849
@@ -79,7 +80,7 @@ func (p *serport) reader() {
7980 n , err := p .portIo .Read (serialBuffer )
8081
8182 //if we detect that port is closing, break out of this for{} loop.
82- if p .isClosing {
83+ if p .isClosing . Load () {
8384 strmsg := "Shutting down reader on " + p .portConf .Name
8485 log .Println (strmsg )
8586 h .broadcastSys <- []byte (strmsg )
@@ -298,7 +299,8 @@ func spHandlerOpen(portname string, baud int) {
298299}
299300
300301func (p * serport ) Close () {
301- p .isClosing = true
302+ p .isClosing .Store (true )
303+
302304 p .bufferFlow .Close ()
303305 p .portIo .Close ()
304306 serialPorts .MarkPortAsClosed (p .portName )
You can’t perform that action at this time.
0 commit comments