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