Skip to content

Commit b74c406

Browse files
committed
Made enumerationLock private
1 parent 1796891 commit b74c406

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

serial.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ type serialhub struct {
4848

4949
// SerialPortList is the serial port list
5050
type SerialPortList struct {
51-
Ports []SpPortItem
52-
Mu sync.Mutex `json:"-"`
51+
Ports []SpPortItem
52+
Mu sync.Mutex `json:"-"`
53+
enumerationLock sync.Mutex
5354
}
5455

5556
// SpPortItem is the serial port item
@@ -132,13 +133,13 @@ func (sp *SerialPortList) List() {
132133
}
133134
}
134135

135-
var serialEnumeratorLock sync.Mutex
136-
137136
func (sp *SerialPortList) Update() {
138-
if !serialEnumeratorLock.TryLock() {
137+
if !sp.enumerationLock.TryLock() {
138+
// already enumerating...
139139
return
140140
}
141-
defer serialEnumeratorLock.Unlock()
141+
defer sp.enumerationLock.Unlock()
142+
142143
ports, err := enumerateSerialPorts()
143144
if err != nil {
144145
// TODO: report error?

0 commit comments

Comments
 (0)