mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Properly close deps channel (#1197)
In case where commitTransactions is interrupted, it will exit without properly closing chDeps, leaving the dependency calculation goroutine hanging. This commit fixes this issue.
This commit is contained in:
parent
5461f9bdc4
commit
8be2283e7a
1 changed files with 9 additions and 1 deletions
|
|
@ -921,6 +921,7 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
|
|||
chDeps := make(chan blockstm.TxDep)
|
||||
|
||||
var depsWg sync.WaitGroup
|
||||
var once sync.Once
|
||||
|
||||
EnableMVHashMap := w.chainConfig.IsCancun(env.header.Number)
|
||||
|
||||
|
|
@ -930,6 +931,11 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
|
|||
|
||||
chDeps = make(chan blockstm.TxDep)
|
||||
|
||||
// Make sure we safely close the channel in case of interrupt
|
||||
defer once.Do(func() {
|
||||
close(chDeps)
|
||||
})
|
||||
|
||||
depsWg.Add(1)
|
||||
|
||||
go func(chDeps chan blockstm.TxDep) {
|
||||
|
|
@ -1109,7 +1115,9 @@ mainloop:
|
|||
|
||||
// nolint:nestif
|
||||
if EnableMVHashMap && w.IsRunning() {
|
||||
once.Do(func() {
|
||||
close(chDeps)
|
||||
})
|
||||
depsWg.Wait()
|
||||
|
||||
var blockExtraData types.BlockExtraData
|
||||
|
|
|
|||
Loading…
Reference in a new issue