diff --git a/snow/networking/router/handler.go b/snow/networking/router/handler.go index b2ca710..9203714 100644 --- a/snow/networking/router/handler.go +++ b/snow/networking/router/handler.go @@ -51,7 +51,7 @@ func (h *Handler) Dispatch() { log.Debug("dropping message due to closing:\n%s", msg) continue } - if !h.dispatchMsg(msg) { + if h.dispatchMsg(msg) { closing = true } case msg := <-h.msgChan: @@ -59,7 +59,7 @@ func (h *Handler) Dispatch() { log.Debug("dropping internal message due to closing:\n%s", msg) continue } - if !h.dispatchMsg(message{messageType: notifyMsg, notification: msg}) { + if h.dispatchMsg(message{messageType: notifyMsg, notification: msg}) { closing = true } } diff --git a/snow/networking/router/subnet_router.go b/snow/networking/router/subnet_router.go index 66f1341..bf7c2eb 100644 --- a/snow/networking/router/subnet_router.go +++ b/snow/networking/router/subnet_router.go @@ -263,11 +263,12 @@ func (sr *ChainRouter) Shutdown() { chain.Shutdown() close(chain.msgs) } - for _, chain := range sr.chains { + sr.chains = map[[32]byte]*Handler{} + prevChains := sr.chains + sr.lock.Unlock() + for _, chain := range prevChains { chain.wg.Wait() } - sr.chains = map[[32]byte]*Handler{} - sr.lock.Unlock() sr.gossiper.Stop() }