Skip to content

Commit

Permalink
improve abortGeneration locks (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush authored May 22, 2024
1 parent 2c1df7d commit 9f90702
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/state/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9f90702

Please sign in to comment.