Fix discovery managers to be properly cancelled

Signed-off-by: Jinwook Jeong <vustthat@gmail.com>
This commit is contained in:
Jinwook Jeong 2022-04-09 01:03:54 +09:00
parent 6555cc68ca
commit c7c7847b6f
2 changed files with 6 additions and 10 deletions

View file

@ -140,11 +140,9 @@ type Manager struct {
// Run starts the background processing
func (m *Manager) Run() error {
go m.sender()
for range m.ctx.Done() {
m.cancelDiscoverers()
return m.ctx.Err()
}
return nil
<-m.ctx.Done()
m.cancelDiscoverers()
return m.ctx.Err()
}
// SyncCh returns a read only channel used by all the clients to receive target updates.

View file

@ -166,11 +166,9 @@ type Manager struct {
// Run starts the background processing.
func (m *Manager) Run() error {
go m.sender()
for range m.ctx.Done() {
m.cancelDiscoverers()
return m.ctx.Err()
}
return nil
<-m.ctx.Done()
m.cancelDiscoverers()
return m.ctx.Err()
}
// SyncCh returns a read only channel used by all the clients to receive target updates.