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.
This commit is contained in:
Olaoluwa Osuntokun 2017-05-15 18:47:18 -07:00
parent bfc869739d
commit a4ba72c08c
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 1 additions and 1 deletions

View File

@ -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