Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
k3rn3l-p4n1c committed Dec 13, 2018
1 parent 85b2f6b commit c1312ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deadline.go
Expand Up @@ -28,16 +28,16 @@ func RunOr(ctx context.Context, function func(ctx context.Context), afterTimeout
function(ctx)
lock.Lock()
if !timeoutExceeded {
lock.Unlock()
finishSignal <- struct{}{}
}
lock.Unlock()
}()

select {
case <-finishSignal:
lock.Lock()
defer lock.Unlock()
timeoutExceeded = true
lock.Unlock()
return nil

case <-ctx.Done():
Expand Down

0 comments on commit c1312ef

Please sign in to comment.