From 527505ea5eb9a70aa668b60210624b5a6c0c923c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 1 Jul 2022 21:55:41 +0300 Subject: [PATCH] consensus: drain messages and transactions on exit as well There might be some threads blocked on these channels. --- pkg/consensus/consensus.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index 8e1b5ad32..d9963d2c4 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -332,14 +332,18 @@ events: default: } } -drainBlocksLoop: +drainLoop: for { select { + case <-s.messages: + case <-s.transactions: case <-s.blockEvents: default: - break drainBlocksLoop + break drainLoop } } + close(s.messages) + close(s.transactions) close(s.blockEvents) close(s.finished) }