Skip to content

Commit

Permalink
Fix message resize not affecting pending messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-weiland committed Nov 22, 2023
1 parent c7f0d10 commit caf0344
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions RiptideNetworking/RiptideNetworking/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static int MaxPayloadSize
maxArraySize = MaxSize / sizeof(ulong) + (MaxSize % sizeof(ulong) == 0 ? 0 : 1);
ByteBuffer = new byte[MaxSize];
TrimPool(); // When ActiveSocketCount is 0, this clears the pool
PendingMessage.ClearPool();
}
}
/// <summary>An intermediary buffer to help convert <see cref="data"/> to a byte array when sending.</summary>
Expand Down
6 changes: 6 additions & 0 deletions RiptideNetworking/RiptideNetworking/PendingMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ private static PendingMessage RetrieveFromPool()
return message;
}

/// <summary>Empties the pool. Does not affect <see cref="PendingMessage"/> instances which are actively pending and therefore not in the pool.</summary>
public static void ClearPool()
{
pool.Clear();
}

/// <summary>Returns the <see cref="PendingMessage"/> instance to the pool so it can be reused.</summary>
private void Release()
{
Expand Down

0 comments on commit caf0344

Please sign in to comment.