From b45923983381d57e8befbdfb1953ebc349ff7d8e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 8 Dec 2011 01:08:40 +0100 Subject: Recover from an internal mess-up in the outgoing packet queues by creating a new queue object. --- .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 55 ++++++++++++++-------- 1 file changed, 36 insertions(+), 19 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c951071..ae72175 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -498,7 +498,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (m_deliverPackets == false) return false; - OutgoingPacket packet; + OutgoingPacket packet = null; OpenSim.Framework.LocklessQueue queue; TokenBucket bucket; bool packetSent = false; @@ -530,32 +530,49 @@ namespace OpenSim.Region.ClientStack.LindenUDP // No dequeued packet waiting to be sent, try to pull one off // this queue queue = m_packetOutboxes[i]; - if (queue != null && queue.Dequeue(out packet)) + if (queue != null) { - // A packet was pulled off the queue. See if we have - // enough tokens in the bucket to send it out - if (bucket.RemoveTokens(packet.Buffer.DataLength)) + bool success = false; + try { - // Send the packet - m_udpServer.SendPacketFinal(packet); - packetSent = true; + success = queue.Dequeue(out packet); } - else + catch { - // Save the dequeued packet for the next iteration - m_nextPackets[i] = packet; + m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue(); } - - // If the queue is empty after this dequeue, fire the queue - // empty callback now so it has a chance to fill before we - // get back here - if (queue.Count == 0) + if (success) + { + // A packet was pulled off the queue. See if we have + // enough tokens in the bucket to send it out + if (bucket.RemoveTokens(packet.Buffer.DataLength)) + { + // Send the packet + m_udpServer.SendPacketFinal(packet); + packetSent = true; + } + else + { + // Save the dequeued packet for the next iteration + m_nextPackets[i] = packet; + } + + // If the queue is empty after this dequeue, fire the queue + // empty callback now so it has a chance to fill before we + // get back here + if (queue.Count == 0) + emptyCategories |= CategoryToFlag(i); + } + else + { + // No packets in this queue. Fire the queue empty callback + // if it has not been called recently emptyCategories |= CategoryToFlag(i); + } } else { - // No packets in this queue. Fire the queue empty callback - // if it has not been called recently + m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue(); emptyCategories |= CategoryToFlag(i); } } @@ -713,4 +730,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } } -} \ No newline at end of file +} -- cgit v1.1