Skip to content

Commit

Permalink
core: add check in AddChildIndexer to avoid double lock (ethereum#20982)
Browse files Browse the repository at this point in the history
This fixes a theoretical double lock condition which could occur in

    indexer.AddChildIndexer(indexer)

Nobody would ever do that though.

Co-authored-by: Felix Lange <[email protected]>
  • Loading branch information
BurtonQin and fjl authored Apr 27, 2020
1 parent e32ee6a commit ba068d4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/chain_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash) {

// AddChildIndexer adds a child ChainIndexer that can use the output of this one
func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) {
if indexer == c {
panic("can't add indexer as a child of itself")
}
c.lock.Lock()
defer c.lock.Unlock()

Expand Down

0 comments on commit ba068d4

Please sign in to comment.