Skip to content

Commit f26c453

Browse files
committed
properly unlock mutex
1 parent 92b0c4b commit f26c453

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: arduino/discovery/discovery.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ func (d *Discovery) Start() error {
9090

9191
// List retrieve the port list from this discovery
9292
func (d *Discovery) List() ([]*BoardPort, error) {
93+
// ensure the connection to the discoverer is unique to avoid messing up
94+
// the messages exchanged
9395
d.Lock()
96+
defer d.Unlock()
97+
9498
if _, err := d.in.Write([]byte("LIST\n")); err != nil {
9599
return nil, fmt.Errorf("sending LIST command to discovery: %s", err)
96100
}
@@ -112,7 +116,6 @@ func (d *Discovery) List() ([]*BoardPort, error) {
112116
return nil, fmt.Errorf("decoding LIST command: %s", err)
113117
}
114118
done <- true
115-
d.Unlock()
116119
return event.Ports, nil
117120
}
118121

0 commit comments

Comments
 (0)