Skip to content

Commit

Permalink
Fix integer overflow on network bytes metric
Browse files Browse the repository at this point in the history
  • Loading branch information
features-not-bugs committed Feb 25, 2023
1 parent f470953 commit 7d45927
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/RustServerMetrics/MetricsLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class MetricsLogger : SingletonComponent<MetricsLogger>
class NetworkUpdateData
{
public int count;
public int bytes;
public long bytes;

public NetworkUpdateData(int count, int bytes)
public NetworkUpdateData(int count, long bytes)
{
this.count = count;
this.bytes = bytes;
Expand Down Expand Up @@ -169,12 +169,12 @@ internal void OnNetWriteSend(NetWrite write, SendInfo sendInfo)
if (sendInfo.connection != null)
{
data.count++;
data.bytes += (int)write.Position;
data.bytes += write.Position;
}
else if (sendInfo.connections != null)
{
data.count += sendInfo.connections.Count;
data.bytes += (int)write.Position * data.count;
data.bytes += write.Position * data.count;
}
}

Expand Down

0 comments on commit 7d45927

Please sign in to comment.