Skip to content

Commit

Permalink
fix: Fixed window exhaust handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoTenPvP committed Sep 10, 2019
1 parent dcbaea3 commit 57b995d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Ruffles/Channeling/Channels/ReliableChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ public HeapMemory[] CreateOutgoingMessage(ArraySegment<byte> 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++;

Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions Ruffles/Channeling/Channels/ReliableSequencedChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 57b995d

Please sign in to comment.