We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1796891 commit b74c406Copy full SHA for b74c406
serial.go
@@ -48,8 +48,9 @@ type serialhub struct {
48
49
// SerialPortList is the serial port list
50
type SerialPortList struct {
51
- Ports []SpPortItem
52
- Mu sync.Mutex `json:"-"`
+ Ports []SpPortItem
+ Mu sync.Mutex `json:"-"`
53
+ enumerationLock sync.Mutex
54
}
55
56
// SpPortItem is the serial port item
@@ -132,13 +133,13 @@ func (sp *SerialPortList) List() {
132
133
134
135
-var serialEnumeratorLock sync.Mutex
136
-
137
func (sp *SerialPortList) Update() {
138
- if !serialEnumeratorLock.TryLock() {
+ if !sp.enumerationLock.TryLock() {
+ // already enumerating...
139
return
140
141
- defer serialEnumeratorLock.Unlock()
+ defer sp.enumerationLock.Unlock()
142
+
143
ports, err := enumerateSerialPorts()
144
if err != nil {
145
// TODO: report error?
0 commit comments