Remove go routines for mdns watcher and cache registry (#919)

This commit is contained in:
Asim Aslam
2019-11-06 15:49:40 +00:00
committed by GitHub
parent b84134581c
commit 254045e9f3
3 changed files with 128 additions and 18 deletions

View File

@@ -8,11 +8,14 @@ import (
)
type mdnsWatcher struct {
id string
wo WatchOptions
ch chan *mdns.ServiceEntry
exit chan struct{}
// the mdns domain
domain string
// the registry
registry *mdnsRegistry
}
func (m *mdnsWatcher) Next() (*Result, error) {
@@ -76,5 +79,9 @@ func (m *mdnsWatcher) Stop() {
return
default:
close(m.exit)
// remove self from the registry
m.registry.mtx.Lock()
delete(m.registry.watchers, m.id)
m.registry.mtx.Unlock()
}
}