Fixed deadlock issue

This commit is contained in:
StephenButtolph 2020-05-29 12:13:05 -04:00
parent 6318186848
commit 312e17bfb3
2 changed files with 6 additions and 5 deletions

View File

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

View File

@ -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()
}