Skip to content

Commit

Permalink
server: fix semaphore release
Browse files Browse the repository at this point in the history
The acquire and release functions should have opposite impacts on the
count.

Credit to @colega who spotted the diff.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Oct 18, 2023
1 parent b4c2f6e commit f160e12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
Expand Down

0 comments on commit f160e12

Please sign in to comment.