Marry AckData to LLQueItem, and store packet data and length there for
use everywhere. Each packet gets serialized only once now in PacketHandler0.6.1-post-fixes
parent
ff7c8551ba
commit
0d3a9b45ae
|
@ -99,26 +99,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
//
|
//
|
||||||
private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>();
|
private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>();
|
||||||
|
|
||||||
// Dictionary of the packets that need acks from the client.
|
private Dictionary<uint, LLQueItem> m_NeedAck =
|
||||||
//
|
new Dictionary<uint, LLQueItem>();
|
||||||
private class AckData
|
|
||||||
{
|
|
||||||
public AckData(Packet packet, Object identifier, int tickCount, int resends)
|
|
||||||
{
|
|
||||||
Packet = packet;
|
|
||||||
Identifier = identifier;
|
|
||||||
TickCount = tickCount;
|
|
||||||
Resends = resends;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Packet Packet;
|
|
||||||
public Object Identifier;
|
|
||||||
public int TickCount;
|
|
||||||
public int Resends;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<uint, AckData> m_NeedAck =
|
|
||||||
new Dictionary<uint, AckData>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of milliseconds that can pass before a packet that needs an ack is resent.
|
/// The number of milliseconds that can pass before a packet that needs an ack is resent.
|
||||||
|
@ -314,6 +296,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
item.throttleType = throttlePacketType;
|
item.throttleType = throttlePacketType;
|
||||||
item.TickCount = System.Environment.TickCount;
|
item.TickCount = System.Environment.TickCount;
|
||||||
item.Identifier = id;
|
item.Identifier = id;
|
||||||
|
item.Resends = 0;
|
||||||
|
item.Bytes = packet.ToBytes();
|
||||||
|
item.Length = item.Bytes.Length;
|
||||||
|
|
||||||
m_PacketQueue.Enqueue(item);
|
m_PacketQueue.Enqueue(item);
|
||||||
m_PacketsSent++;
|
m_PacketsSent++;
|
||||||
|
@ -333,7 +318,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (m_DropSafeTimeout > now ||
|
if (m_DropSafeTimeout > now ||
|
||||||
intervalMs > 500) // We were frozen!
|
intervalMs > 500) // We were frozen!
|
||||||
{
|
{
|
||||||
foreach (AckData data in new List<AckData>
|
foreach (LLQueItem data in new List<LLQueItem>
|
||||||
(m_NeedAck.Values))
|
(m_NeedAck.Values))
|
||||||
{
|
{
|
||||||
if (m_DropSafeTimeout > now)
|
if (m_DropSafeTimeout > now)
|
||||||
|
@ -364,7 +349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
int resent = 0;
|
int resent = 0;
|
||||||
|
|
||||||
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
|
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
|
||||||
{
|
{
|
||||||
Packet packet = data.Packet;
|
Packet packet = data.Packet;
|
||||||
|
|
||||||
|
@ -629,7 +614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private void ProcessAck(uint id)
|
private void ProcessAck(uint id)
|
||||||
{
|
{
|
||||||
AckData data;
|
LLQueItem data;
|
||||||
Packet packet;
|
Packet packet;
|
||||||
|
|
||||||
lock (m_NeedAck)
|
lock (m_NeedAck)
|
||||||
|
@ -639,10 +624,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (!m_NeedAck.TryGetValue(id, out data))
|
if (!m_NeedAck.TryGetValue(id, out data))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
packet = data.Packet;
|
|
||||||
|
|
||||||
m_NeedAck.Remove(id);
|
m_NeedAck.Remove(id);
|
||||||
m_UnackedBytes -= packet.ToBytes().Length;
|
m_UnackedBytes -= data.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +659,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
lock (m_NeedAck)
|
lock (m_NeedAck)
|
||||||
{
|
{
|
||||||
foreach (uint key in m_NeedAck.Keys)
|
foreach (uint key in m_NeedAck.Keys)
|
||||||
info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes());
|
info.needAck.Add(key, m_NeedAck[key].Bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLQueItem[] queitems = m_PacketQueue.GetQueueArray();
|
LLQueItem[] queitems = m_PacketQueue.GetQueueArray();
|
||||||
|
@ -684,7 +667,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
for (int i = 0; i < queitems.Length; i++)
|
for (int i = 0; i < queitems.Length; i++)
|
||||||
{
|
{
|
||||||
if (queitems[i].Incoming == false)
|
if (queitems[i].Incoming == false)
|
||||||
info.out_packets.Add(queitems[i].Packet.ToBytes());
|
info.out_packets.Add(queitems[i].Bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.sequence = m_Sequence;
|
info.sequence = m_Sequence;
|
||||||
|
@ -695,7 +678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public void SetClientInfo(ClientInfo info)
|
public void SetClientInfo(ClientInfo info)
|
||||||
{
|
{
|
||||||
m_PendingAcks = info.pendingAcks;
|
m_PendingAcks = info.pendingAcks;
|
||||||
m_NeedAck = new Dictionary<uint, AckData>();
|
m_NeedAck = new Dictionary<uint, LLQueItem>();
|
||||||
|
|
||||||
Packet packet = null;
|
Packet packet = null;
|
||||||
int packetEnd = 0;
|
int packetEnd = 0;
|
||||||
|
@ -714,7 +697,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0));
|
LLQueItem item = new LLQueItem();
|
||||||
|
item.Packet = packet;
|
||||||
|
item.Incoming = false;
|
||||||
|
item.throttleType = 0;
|
||||||
|
item.TickCount = System.Environment.TickCount;
|
||||||
|
item.Identifier = 0;
|
||||||
|
item.Resends = 0;
|
||||||
|
item.Bytes = packet.ToBytes();
|
||||||
|
item.Length = item.Bytes.Length;
|
||||||
|
m_NeedAck.Add(key, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Sequence = info.sequence;
|
m_Sequence = info.sequence;
|
||||||
|
@ -738,7 +730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private void DropResend(Object id)
|
private void DropResend(Object id)
|
||||||
{
|
{
|
||||||
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
|
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
|
||||||
{
|
{
|
||||||
if (data.Identifier != null && data.Identifier == id)
|
if (data.Identifier != null && data.Identifier == id)
|
||||||
{
|
{
|
||||||
|
@ -774,12 +766,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// We want to see that packet arrive if it's reliable
|
// We want to see that packet arrive if it's reliable
|
||||||
if (packet.Header.Reliable)
|
if (packet.Header.Reliable)
|
||||||
{
|
{
|
||||||
m_UnackedBytes += packet.ToBytes().Length;
|
m_UnackedBytes += item.Length;
|
||||||
|
|
||||||
// Keep track of when this packet was sent out
|
// Keep track of when this packet was sent out
|
||||||
m_NeedAck[packet.Header.Sequence] = new AckData(packet,
|
item.TickCount = System.Environment.TickCount;
|
||||||
item.Identifier, System.Environment.TickCount,
|
|
||||||
0);
|
m_NeedAck[packet.Header.Sequence] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -789,7 +781,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
Abort();
|
Abort();
|
||||||
|
|
||||||
// Actually make the byte array and send it
|
// Actually make the byte array and send it
|
||||||
byte[] sendbuffer = packet.ToBytes();
|
byte[] sendbuffer = item.Bytes;
|
||||||
|
|
||||||
//m_log.DebugFormat(
|
//m_log.DebugFormat(
|
||||||
// "[CLIENT]: In {0} sending packet {1}",
|
// "[CLIENT]: In {0} sending packet {1}",
|
||||||
|
|
|
@ -42,5 +42,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public ThrottleOutPacketType throttleType;
|
public ThrottleOutPacketType throttleType;
|
||||||
public int TickCount;
|
public int TickCount;
|
||||||
public Object Identifier;
|
public Object Identifier;
|
||||||
|
public int Resends;
|
||||||
|
public Byte[] Bytes;
|
||||||
|
public int Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue