Skip to content

Commit 59e8c0b

Browse files
committed
Renamed mutex var and added comment
1 parent ac3d1f9 commit 59e8c0b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

serialport.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,13 @@ func (p *serport) writerRaw() {
274274
h.broadcastSys <- []byte(msgstr)
275275
}
276276

277-
var spHandlerLock sync.Mutex
277+
// This lock is used to prevent multiple threads from trying to open the same port at the same time.
278+
// It presents issues with the serial port driver on some OS's: https://github.com/arduino/arduino-create-agent/issues/1031
279+
var spHandlerOpenLock sync.Mutex
278280

279281
func spHandlerOpen(portname string, baud int, buftype string) {
280-
spHandlerLock.Lock()
281-
defer spHandlerLock.Unlock()
282+
spHandlerOpenLock.Lock()
283+
defer spHandlerOpenLock.Unlock()
282284

283285
log.Print("Inside spHandler")
284286

0 commit comments

Comments
 (0)