Skip to content

Commit 43bd6ea

Browse files
committed
resolve conflict
1 parent c042f10 commit 43bd6ea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: serialport.go

+5-3
Original file line numberDiff line numberDiff 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

300301
func (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)

0 commit comments

Comments
 (0)