Skip to content

Commit

Permalink
fix(refcount): wait for prev to exit in Access
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Jul 23, 2024
1 parent 2e0585b commit f72f133
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions refcount/refcount.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ func (r *RefCount[T]) Access(ctx context.Context, useCtx bool, cb func(ctx conte
if prevCancel != nil {
prevCancel()
}
if prevWait != nil {
// wait for previous routine to exit.
<-prevWait
}
return context.Canceled
case <-waitCh:
}
Expand Down

0 comments on commit f72f133

Please sign in to comment.