From ebeef02fef1a04b5b4cfe13dad588bcce7f9ba21 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 7 Feb 2011 07:45:03 -0800 Subject: Hunting down mantis #5365 Revert "refactor: remove redundant null checks" This reverts commit 6e58996b4d9db202cd7795a37bd687362effef48. --- .../LindenUDP/UnackedPacketCollection.cs | 45 ++++++++++++++-------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs') diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index 9d40688..d762bef 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -141,31 +141,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void ProcessQueues() { // Process all the pending adds + OutgoingPacket pendingAdd; - while (m_pendingAdds.TryDequeue(out pendingAdd)) - m_packets[pendingAdd.SequenceNumber] = pendingAdd; + if (m_pendingAdds != null) + { + while (m_pendingAdds.TryDequeue(out pendingAdd)) + { + if (pendingAdd != null && m_packets != null) + { + m_packets[pendingAdd.SequenceNumber] = pendingAdd; + } + } + } // Process all the pending removes, including updating statistics and round-trip times PendingAck pendingRemove; OutgoingPacket ackedPacket; - while (m_pendingRemoves.TryDequeue(out pendingRemove)) + if (m_pendingRemoves != null) { - if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) + while (m_pendingRemoves.TryDequeue(out pendingRemove)) { - m_packets.Remove(pendingRemove.SequenceNumber); - - // Update stats - Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); - - if (!pendingRemove.FromResend) + if (m_pendingRemoves != null && m_packets != null) { - // Calculate the round-trip time for this packet and its ACK - int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; - if (rtt > 0) - ackedPacket.Client.UpdateRoundTrip(rtt); + if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) + { + m_packets.Remove(pendingRemove.SequenceNumber); + + // Update stats + Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); + + if (!pendingRemove.FromResend) + { + // Calculate the round-trip time for this packet and its ACK + int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; + if (rtt > 0) + ackedPacket.Client.UpdateRoundTrip(rtt); + } + } } } } } } -} \ No newline at end of file +} -- cgit v1.1 From 89bb5c0941625542ce3fe364cf91a2e2fa60cbcf Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 10 Feb 2011 06:09:04 -0800 Subject: Revert "Hunting down mantis #5365" This reverts commit ebeef02fef1a04b5b4cfe13dad588bcce7f9ba21. --- .../LindenUDP/UnackedPacketCollection.cs | 45 ++++++++-------------- 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs') diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index d762bef..9d40688 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -141,46 +141,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void ProcessQueues() { // Process all the pending adds - OutgoingPacket pendingAdd; - if (m_pendingAdds != null) - { - while (m_pendingAdds.TryDequeue(out pendingAdd)) - { - if (pendingAdd != null && m_packets != null) - { - m_packets[pendingAdd.SequenceNumber] = pendingAdd; - } - } - } + while (m_pendingAdds.TryDequeue(out pendingAdd)) + m_packets[pendingAdd.SequenceNumber] = pendingAdd; // Process all the pending removes, including updating statistics and round-trip times PendingAck pendingRemove; OutgoingPacket ackedPacket; - if (m_pendingRemoves != null) + while (m_pendingRemoves.TryDequeue(out pendingRemove)) { - while (m_pendingRemoves.TryDequeue(out pendingRemove)) + if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) { - if (m_pendingRemoves != null && m_packets != null) + m_packets.Remove(pendingRemove.SequenceNumber); + + // Update stats + Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); + + if (!pendingRemove.FromResend) { - if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) - { - m_packets.Remove(pendingRemove.SequenceNumber); - - // Update stats - Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); - - if (!pendingRemove.FromResend) - { - // Calculate the round-trip time for this packet and its ACK - int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; - if (rtt > 0) - ackedPacket.Client.UpdateRoundTrip(rtt); - } - } + // Calculate the round-trip time for this packet and its ACK + int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; + if (rtt > 0) + ackedPacket.Client.UpdateRoundTrip(rtt); } } } } } -} +} \ No newline at end of file -- cgit v1.1 From 45382e6f828395cbbcc1324d366c4f3e0eff7ad7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 10 Feb 2011 06:26:26 -0800 Subject: Reinstated a couple of null checks related to the previous revert. --- .../LindenUDP/UnackedPacketCollection.cs | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs') diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index 9d40688..d195110 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -143,7 +143,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Process all the pending adds OutgoingPacket pendingAdd; while (m_pendingAdds.TryDequeue(out pendingAdd)) - m_packets[pendingAdd.SequenceNumber] = pendingAdd; + if (pendingAdd != null) + m_packets[pendingAdd.SequenceNumber] = pendingAdd; // Process all the pending removes, including updating statistics and round-trip times PendingAck pendingRemove; @@ -152,17 +153,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) { - m_packets.Remove(pendingRemove.SequenceNumber); - - // Update stats - Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); - - if (!pendingRemove.FromResend) + if (ackedPacket != null) { - // Calculate the round-trip time for this packet and its ACK - int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; - if (rtt > 0) - ackedPacket.Client.UpdateRoundTrip(rtt); + m_packets.Remove(pendingRemove.SequenceNumber); + + // Update stats + Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); + + if (!pendingRemove.FromResend) + { + // Calculate the round-trip time for this packet and its ACK + int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; + if (rtt > 0) + ackedPacket.Client.UpdateRoundTrip(rtt); + } } } } -- cgit v1.1