Skip to content

Commit

Permalink
fix: unlock mutex if trying is successful
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Nov 15, 2024
1 parent aba0474 commit 7efb340
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ func (r *Run) Close() error {
return fmt.Errorf("run not started")
}

if !r.lock.TryLock() {
// If we can't get the lock, then the run is still running. Abort it.
r.cancel(errAbortRun)
if r.lock.TryLock() {
r.lock.Unlock()
// If we can get the lock, then the run isn't running, so nothing to do.
return nil
}

r.cancel(errAbortRun)
if r.wait == nil {
return nil
}
Expand Down

0 comments on commit 7efb340

Please sign in to comment.