routing: wait for topology clients to fully exit before closing ntfn chan

This commit fixes a send on closed channel panic by adding additional
synchronization when cancelling the notifications for a particular
topology client. We now ensure that all goroutines belonging to a
particular topology client exit fully before we close the notification
channel in order to avoid a panic.
This commit is contained in:
Olaoluwa Osuntokun
2017-06-25 13:31:41 +01:00
parent 286026fbb9
commit 5c45d52ab6
2 changed files with 10 additions and 0 deletions

View File

@@ -489,7 +489,10 @@ func (r *ChannelRouter) networkHandler() {
if ntfnUpdate.cancel {
if client, ok := r.topologyClients[ntfnUpdate.clientID]; ok {
delete(r.topologyClients, clientID)
close(client.exit)
client.wg.Wait()
close(client.ntfnChan)
}