mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
core: fix txLookupLock mutex leak on error returns in reorg()
txLookupLock.Lock() was acquired without a matching defer, so any of the multiple early error returns inside reorg() left the mutex permanently locked. Subsequent reorgs or transaction lookups would deadlock. Replace the manual Unlock() at the happy-path exit with a deferred call placed immediately after Lock(), so all return paths release the lock.
This commit is contained in:
parent
ab357151da
commit
855cf6bb96
1 changed files with 1 additions and 3 deletions
|
|
@ -2628,6 +2628,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error
|
|||
// as the txlookups should be changed atomically, and all subsequent
|
||||
// reads should be blocked until the mutation is complete.
|
||||
bc.txLookupLock.Lock()
|
||||
defer bc.txLookupLock.Unlock()
|
||||
|
||||
// Reorg can be executed, start reducing the chain's old blocks and appending
|
||||
// the new blocks
|
||||
|
|
@ -2730,9 +2731,6 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error
|
|||
// Reset the tx lookup cache to clear stale txlookup cache.
|
||||
bc.txLookupCache.Purge()
|
||||
|
||||
// Release the tx-lookup lock after mutation.
|
||||
bc.txLookupLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue