Skip to content

Commit 1e7da91

Browse files
authored
Clean-up port cache after a STOP (#22)
Fix #9
1 parent 3e05773 commit 1e7da91

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ import (
4545
)
4646

4747
func main() {
48-
dfuDisc := &DFUDiscovery{
49-
portsCache: map[string]*discovery.Port{},
50-
}
48+
dfuDisc := &DFUDiscovery{}
5149
disc := discovery.NewServer(dfuDisc)
5250
if err := disc.Run(os.Stdin, os.Stdout); err != nil {
5351
fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
@@ -88,11 +86,13 @@ func (d *DFUDiscovery) StartSync(eventCB discovery.EventCallback, errorCB discov
8886
}
8987
closeChan := make(chan struct{})
9088
go func() {
89+
d.portsCache = map[string]*discovery.Port{}
9190
for {
9291
d.sendUpdates(eventCB, errorCB)
9392
select {
9493
case <-time.After(5 * time.Second):
9594
case <-closeChan:
95+
d.portsCache = nil
9696
return
9797
}
9898
}

0 commit comments

Comments
 (0)