Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
dido18 committed Jan 21, 2025
1 parent c042f10 commit 43bd6ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions serialport.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/base64"
"io"
"strconv"
"sync/atomic"
"time"

log "github.com/sirupsen/logrus"
Expand All @@ -42,7 +43,7 @@ type serport struct {

// Keep track of whether we're being actively closed
// just so we don't show scary error messages
isClosing bool
isClosing atomic.Bool

isClosingDueToError bool

Expand Down Expand Up @@ -79,7 +80,7 @@ func (p *serport) reader() {
n, err := p.portIo.Read(serialBuffer)

//if we detect that port is closing, break out of this for{} loop.
if p.isClosing {
if p.isClosing.Load() {
strmsg := "Shutting down reader on " + p.portConf.Name
log.Println(strmsg)
h.broadcastSys <- []byte(strmsg)
Expand Down Expand Up @@ -298,7 +299,8 @@ func spHandlerOpen(portname string, baud int) {
}

func (p *serport) Close() {
p.isClosing = true
p.isClosing.Store(true)

p.bufferFlow.Close()
p.portIo.Close()
serialPorts.MarkPortAsClosed(p.portName)
Expand Down

0 comments on commit 43bd6ea

Please sign in to comment.