aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-05 18:36:13 +0800
committerGitHub <noreply@github.com>2018-11-05 18:36:13 +0800
commitf3e03e18d815d92493d3a85ecb3a0048247ecf71 (patch)
treef8b173ea6f013b30a996a875078907890d6a64de
parent916831419352e00876e8323b3e5243170107719b (diff)
downloaddexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.tar.gz
dexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.tar.zst
dexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.zip
core: Fix deadlock (#298)
-rw-r--r--core/consensus.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 2eed101..56c757b 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -159,6 +159,15 @@ func (recv *consensusBAReceiver) ConfirmBlock(
recv.consensus.logger.Error("Failed to process block", "error", err)
return
}
+ // Clean the restartNotary channel so BA will not stuck by deadlock.
+CleanChannelLoop:
+ for {
+ select {
+ case <-recv.restartNotary:
+ default:
+ break CleanChannelLoop
+ }
+ }
if block.Timestamp.After(recv.changeNotaryTime) {
recv.round++
recv.restartNotary <- true