Commit 7c7bd31d authored by Alexey Kholupko's avatar Alexey Kholupko
Browse files

mDNS discovery starts announcing right away: does not wait for first interval to elapse.

Closes #256
parent c9eddef0
...@@ -118,8 +118,7 @@ func (m *mdnsService) pollForEntries(ctx context.Context) { ...@@ -118,8 +118,7 @@ func (m *mdnsService) pollForEntries(ctx context.Context) {
ticker := time.NewTicker(m.interval) ticker := time.NewTicker(m.interval)
for { for {
select { //execute mdns query right away at method call and then with every tick
case <-ticker.C:
entriesCh := make(chan *mdns.ServiceEntry, 16) entriesCh := make(chan *mdns.ServiceEntry, 16)
go func() { go func() {
for entry := range entriesCh { for entry := range entriesCh {
...@@ -141,6 +140,10 @@ func (m *mdnsService) pollForEntries(ctx context.Context) { ...@@ -141,6 +140,10 @@ func (m *mdnsService) pollForEntries(ctx context.Context) {
} }
close(entriesCh) close(entriesCh)
log.Debug("mdns query complete") log.Debug("mdns query complete")
select {
case <-ticker.C:
continue
case <-ctx.Done(): case <-ctx.Done():
log.Debug("mdns service halting") log.Debug("mdns service halting")
return return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment