Skip to content

Commit

Permalink
fix: lockcontext tries
Browse files Browse the repository at this point in the history
  • Loading branch information
px3303 committed Apr 8, 2024
1 parent c04a82e commit e76c4db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (m *Mutex) lockContext(ctx context.Context, tries int) error {
return m.release(ctx, pool, value)
})
}()
if i == m.tries-1 && err != nil {
if i == tries-1 && err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion mutex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestMutexAlreadyLocked(t *testing.T) {
assertAcquired(ctx, t, v.pools, mutex1)

mutex2 := rs.NewMutex(key)
err = mutex2.Lock()
err = mutex2.TryLock()
var errTaken *ErrTaken
if !errors.As(err, &errTaken) {
t.Fatalf("mutex was not already locked: %s", err)
Expand Down

0 comments on commit e76c4db

Please sign in to comment.