Skip to content

Commit

Permalink
Revert "new ordered sendq, it's fairly resource intensive"
Browse files Browse the repository at this point in the history
This reverts commit 6f26e01.
  • Loading branch information
tylerjwatson committed Jul 18, 2015
1 parent 6f26e01 commit 2bd803d
Show file tree
Hide file tree
Showing 10 changed files with 493 additions and 488 deletions.
8 changes: 0 additions & 8 deletions Terraria/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -10635,13 +10634,6 @@ public static void startDedInputCallBack(object threadContext)
break;
}
string lower = str.ToLower();

if (str == "!free")
{
Console.WriteLine("sendq: {0}/{1} small blocks used", PacketHeap.usedSmallBlocks.Count(i => i == 1), PacketHeap.kPacketHeapSmallCount);
Console.WriteLine("sendq: {0}/{1} large blocks used", PacketHeap.usedLargeBlocks.Count(i => i == 1), PacketHeap.kPacketHeapLargeCount);
}

if (!ServerApi.Hooks.InvokeServerCommand(str))
{
try
Expand Down
12 changes: 8 additions & 4 deletions Terraria/Net/NetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Broadcast(NetPacket packet, int ignoreClient = -1)
{
if (i != ignoreClient && Netplay.Clients[i].Socket.IsConnected())
{
/// NetManager.SendData(i, Netplay.Clients[i].Socket, packet);
NetManager.SendData(i, Netplay.Clients[i].Socket, packet);
}
}
}
Expand Down Expand Up @@ -92,9 +92,13 @@ public static void SendCallback(object state)

public static void SendData(int player, ISocket socket, NetPacket packet)
{
HeapItem item = PacketHeap.Allocate(HeapType.LargeHeap);
Array.Copy(packet.Buffer.Data, 0, item.Array, item.Offset, packet.Length);
SendQueue.Broadcast(item);
ArraySegment<byte> seg;

Netplay.Clients[player].sendQueue.AllocAndSet(packet.Length, (BinaryWriter bw) =>
{
bw.Write(packet.Buffer.Data, 0, packet.Length);
return true;
});
}

private static void UpdateStats(int length)
Expand Down
163 changes: 0 additions & 163 deletions Terraria/Net/Sockets/PacketHeap.cs

This file was deleted.

Loading

0 comments on commit 2bd803d

Please sign in to comment.