From 57b995d3af1640e0a02bceed5b1e6c34bbe130f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= Date: Tue, 10 Sep 2019 14:03:49 +0200 Subject: [PATCH] fix: Fixed window exhaust handling --- Ruffles/Channeling/Channels/ReliableChannel.cs | 14 ++++++++++++++ .../Channels/ReliableSequencedChannel.cs | 4 ++++ .../Channels/ReliableSequencedFragmentedChannel.cs | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Ruffles/Channeling/Channels/ReliableChannel.cs b/Ruffles/Channeling/Channels/ReliableChannel.cs index 44b8ed7..f4a8adf 100644 --- a/Ruffles/Channeling/Channels/ReliableChannel.cs +++ b/Ruffles/Channeling/Channels/ReliableChannel.cs @@ -135,6 +135,19 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment payload, out byte h lock (_lock) { + PendingOutgoingPacket unsafeOutgoing = _sendSequencer.GetUnsafe(_lastOutboundSequenceNumber + 1, out bool isSafe); + + if (unsafeOutgoing.Alive && !isSafe) + { + if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Outgoing packet window is exhausted. Disconnecting"); + + connection.Disconnect(false); + + dealloc = false; + headerSize = 0; + return null; + } + // Increment the sequence number _lastOutboundSequenceNumber++; @@ -255,6 +268,7 @@ public void InternalUpdate() { // If they don't ack the message, disconnect them connection.Disconnect(false); + return; } else if ((DateTime.Now - _sendSequencer[i].LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier) { diff --git a/Ruffles/Channeling/Channels/ReliableSequencedChannel.cs b/Ruffles/Channeling/Channels/ReliableSequencedChannel.cs index e55c1de..009ad1b 100644 --- a/Ruffles/Channeling/Channels/ReliableSequencedChannel.cs +++ b/Ruffles/Channeling/Channels/ReliableSequencedChannel.cs @@ -149,6 +149,9 @@ public HeapMemory HandlePoll() if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Incoming packet window is exhausted. Disconnecting"); connection.Disconnect(false); + + hasMore = false; + return null; } else if (!_receiveSequencer[sequence].Alive) { @@ -372,6 +375,7 @@ public void InternalUpdate() { // If they don't ack the message, disconnect them connection.Disconnect(false); + return; } else if ((DateTime.Now - _sendSequencer[i].LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier) { diff --git a/Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs b/Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs index ab51eef..5d0e203 100644 --- a/Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs +++ b/Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs @@ -314,6 +314,9 @@ public HeapMemory HandlePoll() if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Incoming packet window is exhausted. Disconnecting"); connection.Disconnect(false); + + hasMore = false; + return null; } else if (!_receiveSequencer[sequence].Alive) { @@ -639,7 +642,6 @@ public void InternalUpdate() { // If they don't ack the message, disconnect them connection.Disconnect(false); - return; } else if ((DateTime.Now - ((PendingOutgoingFragment)_sendSequencer[i].Fragments[j]).LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier)