Skip to content

Commit

Permalink
Fix for data race for c.out
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Collison <[email protected]>
  • Loading branch information
derekcollison authored and neilalexander committed Feb 25, 2025
1 parent fc5f10f commit 723dca8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3355,14 +3355,15 @@ func (c *client) stalledWait(producer *client) {
// Grab stall channel which the slow consumer will close when caught up.
stall := c.out.stc

c.mu.Unlock()
defer c.mu.Lock()

// Calculate stall time.
ttl := stallClientMinDuration
if c.out.pb >= c.out.mp {
ttl = stallClientMaxDuration
}

c.mu.Unlock()
defer c.mu.Lock()

// Now check if we are close to total allowed.
if producer.in.tst+ttl > stallTotalAllowed {
ttl = stallTotalAllowed - producer.in.tst
Expand Down

0 comments on commit 723dca8

Please sign in to comment.