From b45923983381d57e8befbdfb1953ebc349ff7d8e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 8 Dec 2011 01:08:40 +0100 Subject: [PATCH] Recover from an internal mess-up in the outgoing packet queues by creating a new queue object. --- .../ClientStack/Linden/UDP/LLUDPClient.cs | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c95107141c..ae721757b0 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); + } + catch + { + m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue(); + } + 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 { - // 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) + // 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 +}