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 committed 2017-06-25 13:31:55 +01:00
1 parent 286026fbb9
commit 5c45d52ab6
2 files changed
+10

No files matched your search

+3
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)
}