diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index f0d25bc86e..a82c49c7e0 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -568,9 +568,6 @@ func (t *Tree) AbortGeneration() { // for it to shutdown before returning (if it is running). This call should not // be made concurrently. func (dl *diskLayer) abortGeneration() bool { - dl.lock.Lock() - defer dl.lock.Unlock() - // Store ideal time for abort to get better estimate of load // // Note that we set this time regardless if abortion was skipped otherwise we @@ -580,7 +577,10 @@ func (dl *diskLayer) abortGeneration() bool { } // If the disk layer is running a snapshot generator, abort it - if dl.genAbort != nil && dl.genStats == nil { + dl.lock.RLock() + shouldAbort := dl.genAbort != nil && dl.genStats == nil + dl.lock.RUnlock() + if shouldAbort { abort := make(chan struct{}) dl.genAbort <- abort <-abort