From 723dca86338f8656868dcc83c0c21ccc4258c5cc Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Tue, 25 Feb 2025 08:31:12 -0500 Subject: [PATCH] Fix for data race for c.out Signed-off-by: Derek Collison --- server/client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/client.go b/server/client.go index e3724bc3e5..8cbf98e517 100644 --- a/server/client.go +++ b/server/client.go @@ -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