From 6f0240157531e4d5a20e21dfcc4a4e704b71d839 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Tue, 17 Mar 2026 14:32:17 +0800 Subject: [PATCH] fix(core/txpool): avoid blocking reset completion on close #31030 (#2175) * fix(core/txpool): coordinate reset lifecycle and shutdown signaling #28837 Improve txpool loop synchronization around background resets. This change: - adds an explicit termination channel to signal pool shutdown - tracks forced-reset intent and a waiter channel inside the reset loop - ensures reset waiters are notified on completion or on pool termination - allows an explicit sync request path to trigger an additional reset round when needed Scope is limited to internal txpool concurrency control in core/txpool/txpool.go, with no protocol or RPC behavior change. * fix(core/txpool): avoid blocking reset completion on close #31030 --- core/txpool/txpool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index c8e1e25a0e..4e7f801f84 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -166,7 +166,10 @@ func (p *TxPool) loop(head *types.Header, chain BlockChain) { for _, subpool := range p.subpools { subpool.Reset(oldHead, newHead) } - resetDone <- newHead + select { + case resetDone <- newHead: + case <-p.term: + } }(oldHead, newHead) // If the reset operation was explicitly requested, consider it