From f160e1270255bad28058fe802e46c69405b560fc Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 18 Oct 2023 10:33:11 +0000 Subject: [PATCH] server: fix semaphore release The acquire and release functions should have opposite impacts on the count. Credit to @colega who spotted the diff. Signed-off-by: Bryan Boreham --- server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.go b/server.go index b44c7e86c3b..e6f89259660 100644 --- a/server.go +++ b/server.go @@ -2093,7 +2093,7 @@ func (q *atomicSemaphore) release() { // concurrent calls to acquire, but also note that with synchronous calls to // acquire, as our system does, n will never be less than -1. There are // fairness issues (queuing) to consider if this was to be generalized. - if atomic.AddInt64(&q.n, -1) <= 0 { + if atomic.AddInt64(&q.n, 1) <= 0 { // An acquire was waiting on us. Unblock it. q.wait <- struct{}{} }