From a4ba72c08cdda80cefdf541e70ff8432b55fefd9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 15 May 2017 18:47:18 -0700 Subject: [PATCH] routing: close exit chan before ntfnChan to cancel topology clients This commit fixes a panic due to a send on a closed channel that could possibly occur depending on the order of channel closes when a client goes to cancel a topology notification client. Previously we closed the ntfnChan first, this would possible result in a panic as the goroutine may have succeeded on a send at the same time the channel was closed. Instead, we now close the `exit` channel first which is meant to be a signal to the goroutine that the client has been canceled. --- routing/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing/router.go b/routing/router.go index 2a9459aa..8b88d3fc 100644 --- a/routing/router.go +++ b/routing/router.go @@ -489,8 +489,8 @@ func (r *ChannelRouter) networkHandler() { if ntfnUpdate.cancel { if client, ok := r.topologyClients[ntfnUpdate.clientID]; ok { delete(r.topologyClients, clientID) - close(client.ntfnChan) close(client.exit) + close(client.ntfnChan) } continue