From cd3f0dfa25a787710a5bcf24c63c402da61a91de Mon Sep 17 00:00:00 2001 From: Simon Dudley Date: Tue, 22 Feb 2022 14:23:43 +1000 Subject: [PATCH] Remove shutdown latch from BftProcessor We don't want BftMiningCoordinator.stop() to wait for BftProcessor to shutdown before calling shutdown on the BftExecutor. This prevents BftMiningCoordinator from being able to be shutdown from the same thread. We want to enable shutdown from the same thread to support migrating from one miningCoordinator instance to another (IBFT -> QBFT). Signed-off-by: Simon Dudley --- .../besu/consensus/common/bft/BftProcessor.java | 7 ------- .../common/bft/blockcreation/BftMiningCoordinator.java | 7 ------- 2 files changed, 14 deletions(-) diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java index a85b440cf61..c0c983c1de7 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftProcessor.java @@ -17,7 +17,6 @@ import org.hyperledger.besu.consensus.common.bft.events.BftEvent; import java.util.Optional; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; @@ -31,7 +30,6 @@ public class BftProcessor implements Runnable { private final BftEventQueue incomingQueue; private volatile boolean shutdown = false; private final EventMultiplexer eventMultiplexer; - private final CountDownLatch shutdownLatch = new CountDownLatch(1); /** * Construct a new BftProcessor @@ -49,10 +47,6 @@ public void stop() { shutdown = true; } - public void awaitStop() throws InterruptedException { - shutdownLatch.await(); - } - @Override public void run() { try { @@ -64,7 +58,6 @@ public void run() { } // Clean up the executor service the round timer has been utilising LOG.info("Shutting down BFT event processor"); - shutdownLatch.countDown(); } private Optional nextEvent() { diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java index 218d54f4294..7eab22753f5 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftMiningCoordinator.java @@ -88,13 +88,6 @@ public void stop() { if (state.compareAndSet(State.RUNNING, State.STOPPED)) { blockchain.removeObserver(blockAddedObserverId); bftProcessor.stop(); - // Make sure the processor has stopped before shutting down the executors - try { - bftProcessor.awaitStop(); - } catch (final InterruptedException e) { - LOG.debug("Interrupted while waiting for IbftProcessor to stop.", e); - Thread.currentThread().interrupt(); - } bftExecutors.stop(); } }