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) log.Debug("dropping message due to closing:\n%s", msg)
continue continue
} }
if !h.dispatchMsg(msg) { if h.dispatchMsg(msg) {
closing = true closing = true
} }
case msg := <-h.msgChan: case msg := <-h.msgChan:
@ -59,7 +59,7 @@ func (h *Handler) Dispatch() {
log.Debug("dropping internal message due to closing:\n%s", msg) log.Debug("dropping internal message due to closing:\n%s", msg)
continue continue
} }
if !h.dispatchMsg(message{messageType: notifyMsg, notification: msg}) { if h.dispatchMsg(message{messageType: notifyMsg, notification: msg}) {
closing = true closing = true
} }
} }

View File

@ -263,11 +263,12 @@ func (sr *ChainRouter) Shutdown() {
chain.Shutdown() chain.Shutdown()
close(chain.msgs) 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() chain.wg.Wait()
} }
sr.chains = map[[32]byte]*Handler{}
sr.lock.Unlock()
sr.gossiper.Stop() sr.gossiper.Stop()
} }