From 7a58c510373afdffe56ec1ddc7c148f48e1abcf3 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Mon, 22 Mar 2021 21:26:58 +0000 Subject: [PATCH] windowsize atomicity --- udp/congestion/newreno.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/udp/congestion/newreno.go b/udp/congestion/newreno.go index 5f14fcd..4e94a41 100644 --- a/udp/congestion/newreno.go +++ b/udp/congestion/newreno.go @@ -260,11 +260,12 @@ func (c *NewReno) receivedAck(ack uint32) { c.inFlight = c.inFlight[i:] if c.slowStart { - c.windowSize += uint32(i) + atomic.AddUint32(&c.windowSize, uint32(i)) } else { c.windowCount += uint32(i) - if c.windowCount > c.windowSize { - c.windowCount -= uint32(i) + s := c.windowSize + if c.windowCount > s { + c.windowCount -= s atomic.AddUint32(&c.windowSize, 1) } }