router/registry: fix nil eventChan bug (#1773)

* router/registry: fix nil eventChan bug
This commit is contained in:
ben-toogood 2020-07-01 12:03:13 +01:00 committed by GitHub
parent 1b5c83f3cc
commit 64e9185386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -285,7 +285,6 @@ func (r *router) watchTable(w Watcher) error {
select {
case <-r.exit:
close(r.eventChan)
return nil
case r.eventChan <- event:
// process event
@ -705,10 +704,13 @@ func (r *router) Close() error {
r.sub.Unlock()
}
// remove event chan
r.eventChan = nil
r.running = false
// close and remove event chan
if r.eventChan != nil {
close(r.eventChan)
r.eventChan = nil
}
r.running = false
return nil
}