Skip to content

Commit a5c2bc0

Browse files
authored
Merge pull request #25 from arduino/scerza/fix-darwin-discovery
Fix `STOP` command not stopping discovery syncing
2 parents 28a7faa + 43eeb2e commit a5c2bc0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sync/sync_darwin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
6161
// Output initial port state: get the current port list to send as initial "add" events
6262
current, err := enumerator.GetDetailedPortsList()
6363
if err != nil {
64-
// TODO: how to handle errors? should we just retry silently?
64+
errorCB(err.Error())
65+
return
6566
}
6667
for _, port := range current {
6768
eventCB("add", toDiscoveryPort(port))
@@ -71,7 +72,7 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
7172
events := make([]syscall.Kevent_t, 10)
7273

7374
for {
74-
t100ms := syscall.Timespec{Nsec: 100000000, Sec: 0}
75+
t100ms := syscall.Timespec{Nsec: 100_000_000, Sec: 0}
7576
n, err := syscall.Kevent(kq, []syscall.Kevent_t{ev1}, events, &t100ms)
7677
select {
7778
case <-closeChan:
@@ -92,7 +93,6 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
9293
// if there is an event retry up to 5 times
9394
var enumeratorErr error
9495
for retries := 0; retries < 5; retries++ {
95-
retries--
9696
updates, err := enumerator.GetDetailedPortsList()
9797
if err != nil {
9898
enumeratorErr = err

0 commit comments

Comments
 (0)