File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,9 @@ type serialhub struct {
48
48
49
49
// SerialPortList is the serial port list
50
50
type SerialPortList struct {
51
- Ports []SpPortItem
52
- Mu sync.Mutex `json:"-"`
51
+ Ports []SpPortItem
52
+ Mu sync.Mutex `json:"-"`
53
+ enumerationLock sync.Mutex
53
54
}
54
55
55
56
// SpPortItem is the serial port item
@@ -132,13 +133,13 @@ func (sp *SerialPortList) List() {
132
133
}
133
134
}
134
135
135
- var serialEnumeratorLock sync.Mutex
136
-
137
136
func (sp * SerialPortList ) Update () {
138
- if ! serialEnumeratorLock .TryLock () {
137
+ if ! sp .enumerationLock .TryLock () {
138
+ // already enumerating...
139
139
return
140
140
}
141
- defer serialEnumeratorLock .Unlock ()
141
+ defer sp .enumerationLock .Unlock ()
142
+
142
143
ports , err := enumerateSerialPorts ()
143
144
if err != nil {
144
145
// TODO: report error?
You can’t perform that action at this time.
0 commit comments