Skip to content

Commit 7efb340

Browse files
committed
fix: unlock mutex if trying is successful
Signed-off-by: Donnie Adams <[email protected]>
1 parent aba0474 commit 7efb340

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

run.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ func (r *Run) Close() error {
135135
return fmt.Errorf("run not started")
136136
}
137137

138-
if !r.lock.TryLock() {
139-
// If we can't get the lock, then the run is still running. Abort it.
140-
r.cancel(errAbortRun)
138+
if r.lock.TryLock() {
139+
r.lock.Unlock()
140+
// If we can get the lock, then the run isn't running, so nothing to do.
141+
return nil
141142
}
143+
144+
r.cancel(errAbortRun)
142145
if r.wait == nil {
143146
return nil
144147
}

0 commit comments

Comments
 (0)