From a2734ffa72a29dbfbca4a720b91eee980238df05 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 27 Dec 2020 08:50:11 -0500 Subject: [PATCH] SSU: Fix restoration of window after failed message Reported by and adapted from patch by zlatinb --- .../i2p/router/transport/udp/PeerState.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index dfd39ef88..e521c3f97 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -1434,18 +1434,18 @@ public class PeerState { if (_log.shouldLog(Log.WARN)) _log.warn("Unable to send a direct message: " + state + " to: " + this); } - if (failedSize > 0) { - // restore the window - synchronized(this) { - // this isn't exactly right, because some fragments may not have been sent at all, - // but that should be unlikely - _sendWindowBytesRemaining += failedSize; - _sendWindowBytesRemaining += failedCount * fragmentOverhead(); - if (_sendWindowBytesRemaining > _sendWindowBytes) - _sendWindowBytesRemaining = _sendWindowBytes; - } - // no need to nudge(), this is called from OMF loop before allocateSend() + } + if (failedSize > 0) { + // restore the window + synchronized(this) { + // this isn't exactly right, because some fragments may not have been sent at all, + // but that should be unlikely + _sendWindowBytesRemaining += failedSize; + _sendWindowBytesRemaining += failedCount * fragmentOverhead(); + if (_sendWindowBytesRemaining > _sendWindowBytes) + _sendWindowBytesRemaining = _sendWindowBytes; } + // no need to nudge(), this is called from OMF loop before allocateSend() } }