Skip to content

Commit f586a10

Browse files
committed
Fixed extremely rare race condition in DiscoveryManager
1 parent 149c7e1 commit f586a10

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: internal/arduino/discovery/discoverymanager/discoverymanager.go

+5
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,16 @@ func (dm *DiscoveryManager) Watch() (*PortWatcher, error) {
171171
defer dm.watchersMutex.Unlock()
172172
delete(dm.watchers, watcher)
173173
close(watcher.feed)
174+
watcher.feed = nil
174175
}
175176
go func() {
176177
dm.watchersMutex.Lock()
177178
defer dm.watchersMutex.Unlock()
178179

180+
if watcher.feed == nil {
181+
return
182+
}
183+
179184
// if watcher is still online...
180185
if _, ok := dm.watchers[watcher]; ok {
181186
return

0 commit comments

Comments
 (0)