Revert 7754 and 7755 pending a rework

0.6.1-post-fixes
Melanie Thielker 2008-12-17 20:34:37 +00:00
parent 5320f0f33c
commit 2bcf315ea2
3 changed files with 59 additions and 47 deletions

View File

@ -99,8 +99,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//
private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>();
private Dictionary<uint, LLQueItem> m_NeedAck =
new Dictionary<uint, LLQueItem>();
// Dictionary of the packets that need acks from the client.
//
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>
/// The number of milliseconds that can pass before a packet that needs an ack is resent.
@ -296,9 +314,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
item.throttleType = throttlePacketType;
item.TickCount = System.Environment.TickCount;
item.Identifier = id;
item.Resends = 0;
item.Bytes = packet.ToBytes();
item.Length = item.Bytes.Length;
m_PacketQueue.Enqueue(item);
m_PacketsSent++;
@ -318,7 +333,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_DropSafeTimeout > now ||
intervalMs > 500) // We were frozen!
{
foreach (LLQueItem data in new List<LLQueItem>
foreach (AckData data in new List<AckData>
(m_NeedAck.Values))
{
if (m_DropSafeTimeout > now)
@ -349,7 +364,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int resent = 0;
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
{
Packet packet = data.Packet;
@ -615,7 +630,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void ProcessAck(uint id)
{
LLQueItem data;
AckData data;
Packet packet;
lock (m_NeedAck)
@ -625,9 +640,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!m_NeedAck.TryGetValue(id, out data))
return;
packet = data.Packet;
m_NeedAck.Remove(id);
m_UnackedBytes -= packet.ToBytes().Length;
PacketPool.Instance.ReturnPacket(data.Packet);
m_UnackedBytes -= data.Length;
}
}
@ -661,7 +678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
lock (m_NeedAck)
{
foreach (uint key in m_NeedAck.Keys)
info.needAck.Add(key, m_NeedAck[key].Bytes);
info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes());
}
LLQueItem[] queitems = m_PacketQueue.GetQueueArray();
@ -669,7 +686,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
for (int i = 0; i < queitems.Length; i++)
{
if (queitems[i].Incoming == false)
info.out_packets.Add(queitems[i].Bytes);
info.out_packets.Add(queitems[i].Packet.ToBytes());
}
info.sequence = m_Sequence;
@ -680,7 +697,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SetClientInfo(ClientInfo info)
{
m_PendingAcks = info.pendingAcks;
m_NeedAck = new Dictionary<uint, LLQueItem>();
m_NeedAck = new Dictionary<uint, AckData>();
Packet packet = null;
int packetEnd = 0;
@ -699,16 +716,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
}
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_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0));
}
m_Sequence = info.sequence;
@ -732,7 +740,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void DropResend(Object id)
{
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
{
if (data.Identifier != null && data.Identifier == id)
{
@ -769,12 +777,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// We want to see that packet arrive if it's reliable
if (packet.Header.Reliable)
{
m_UnackedBytes += item.Length;
m_UnackedBytes += packet.ToBytes().Length;
// Keep track of when this packet was sent out
item.TickCount = System.Environment.TickCount;
m_NeedAck[packet.Header.Sequence] = item;
m_NeedAck[packet.Header.Sequence] = new AckData(packet,
item.Identifier, System.Environment.TickCount,
0);
}
}
}
@ -784,7 +792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Abort();
// Actually make the byte array and send it
byte[] sendbuffer = item.Bytes;
byte[] sendbuffer = packet.ToBytes();
//m_log.DebugFormat(
// "[CLIENT]: In {0} sending packet {1}",

View File

@ -345,8 +345,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
ResendThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
ResendThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -356,8 +357,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = LandOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
LandThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
LandThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -366,8 +368,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = WindOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
WindThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
WindThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -376,8 +379,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
CloudThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
CloudThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -395,8 +399,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
SendQueue.Enqueue(qpack);
}
TotalThrottle.AddBytes(qpack.Length);
TaskThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
TaskThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -405,8 +410,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
TextureThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
TextureThrottle.AddBytes(qpackSize);
qchanged = true;
}
@ -415,8 +421,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
TotalThrottle.AddBytes(qpack.Length);
AssetThrottle.AddBytes(qpack.Length);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
AssetThrottle.AddBytes(qpackSize);
qchanged = true;
}
}
@ -444,8 +451,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try
{
Monitor.Enter(this);
throttle.AddBytes(item.Length);
TotalThrottle.AddBytes(item.Length);
throttle.AddBytes(item.Packet.ToBytes().Length);
TotalThrottle.AddBytes(item.Packet.ToBytes().Length);
SendQueue.Enqueue(item);
}
catch (Exception e)

View File

@ -42,8 +42,5 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public ThrottleOutPacketType throttleType;
public int TickCount;
public Object Identifier;
public int Resends;
public Byte[] Bytes;
public int Length;
}
}