Skip to content

Commit 2a34653

Browse files
Fixing node race condition bug, due to uint32 being read without any concurrent measure.
Signed-off-by: Shashank Pal <[email protected]>
1 parent f9f39e5 commit 2a34653

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/locks/locks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func DecrementQueueSize(lockID string) {
6565
currentWait, ok := waitQueue.Load(lockID)
6666
if ok {
6767
if ptr, ok := currentWait.(*uint32); ok {
68-
if *ptr > 0 {
68+
if atomic.LoadUint32(ptr) > 0 {
6969
atomic.AddUint32(ptr, ^uint32(0))
7070
}
7171
}

utils/limiter/semaphoreN_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestSemaphoreN_Wait(t *testing.T) {
5959
wg.Add(1)
6060
go func() {
6161
defer wg.Done()
62-
err = lim.Wait(ctx)
62+
err := lim.Wait(ctx)
6363
defer lim.Release(ctx)
6464
assert.NoError(t, err)
6565
}()

0 commit comments

Comments
 (0)