Skip to content

Commit

Permalink
[R4R] fix:defer bloomprocessor close (bnb-chain#860)
Browse files Browse the repository at this point in the history
* fix:defer bloomprocessor close

* fix: fix deadlock in Close

* perf:rm defer bloomprocessors Close and manual close before return
  • Loading branch information
qinglin89 authored and j75689 committed Jun 7, 2022
1 parent f93e6f2 commit bd67fb2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
for i, tx := range block.Transactions() {
if isPoSA {
if isSystemTx, err := posa.IsSystemTransaction(tx, block.Header()); err != nil {
bloomProcessors.Close()
return statedb, nil, nil, 0, err
} else if isSystemTx {
systemTxs = append(systemTxs, tx)
Expand All @@ -421,12 +422,14 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg

msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee)
if err != nil {
return statedb, nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
bloomProcessors.Close()
return statedb, nil, nil, 0, err
}
statedb.Prepare(tx.Hash(), i)
receipt, err := applyTransaction(msg, p.config, p.bc, nil, gp, statedb, blockNumber, blockHash,
tx, usedGas, vmenv, bloomProcessors)
if err != nil {
bloomProcessors.Close()
return statedb, nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}

Expand Down

0 comments on commit bd67fb2

Please sign in to comment.