Skip to content

Commit 57b995d

Browse files
committed
fix: Fixed window exhaust handling
1 parent dcbaea3 commit 57b995d

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Ruffles/Channeling/Channels/ReliableChannel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> payload, out byte h
135135

136136
lock (_lock)
137137
{
138+
PendingOutgoingPacket unsafeOutgoing = _sendSequencer.GetUnsafe(_lastOutboundSequenceNumber + 1, out bool isSafe);
139+
140+
if (unsafeOutgoing.Alive && !isSafe)
141+
{
142+
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Outgoing packet window is exhausted. Disconnecting");
143+
144+
connection.Disconnect(false);
145+
146+
dealloc = false;
147+
headerSize = 0;
148+
return null;
149+
}
150+
138151
// Increment the sequence number
139152
_lastOutboundSequenceNumber++;
140153

@@ -255,6 +268,7 @@ public void InternalUpdate()
255268
{
256269
// If they don't ack the message, disconnect them
257270
connection.Disconnect(false);
271+
return;
258272
}
259273
else if ((DateTime.Now - _sendSequencer[i].LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier)
260274
{

Ruffles/Channeling/Channels/ReliableSequencedChannel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ public HeapMemory HandlePoll()
149149
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Incoming packet window is exhausted. Disconnecting");
150150

151151
connection.Disconnect(false);
152+
153+
hasMore = false;
154+
return null;
152155
}
153156
else if (!_receiveSequencer[sequence].Alive)
154157
{
@@ -372,6 +375,7 @@ public void InternalUpdate()
372375
{
373376
// If they don't ack the message, disconnect them
374377
connection.Disconnect(false);
378+
return;
375379
}
376380
else if ((DateTime.Now - _sendSequencer[i].LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier)
377381
{

Ruffles/Channeling/Channels/ReliableSequencedFragmentedChannel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ public HeapMemory HandlePoll()
314314
if (Logging.CurrentLogLevel <= LogLevel.Error) Logging.LogError("Incoming packet window is exhausted. Disconnecting");
315315

316316
connection.Disconnect(false);
317+
318+
hasMore = false;
319+
return null;
317320
}
318321
else if (!_receiveSequencer[sequence].Alive)
319322
{
@@ -639,7 +642,6 @@ public void InternalUpdate()
639642
{
640643
// If they don't ack the message, disconnect them
641644
connection.Disconnect(false);
642-
643645
return;
644646
}
645647
else if ((DateTime.Now - ((PendingOutgoingFragment)_sendSequencer[i].Fragments[j]).LastSent).TotalMilliseconds > connection.Roundtrip * config.ReliabilityResendRoundtripMultiplier)

0 commit comments

Comments
 (0)