From fabe2206db37be39a90254da8a7fff973f2dd977 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Sat, 17 Jul 2010 15:08:59 -0700 Subject: Ensure that packets do NOT get delivered to a client before the modules that can deal with the client's response have finished loading. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 9 +++++++++ .../Region/ClientStack/LindenUDP/LLUDPClient.cs | 10 ++++++++++ .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 23 +++++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 754127d..a9f9d60 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -334,6 +334,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // protected HashSet m_attachmentsSent; private int m_moneyBalance; + private bool m_deliverPackets = true; private int m_animationSequenceNumber = 1; private bool m_SendLogoutPacketWhenClosing = true; private AgentUpdateArgs lastarg; @@ -378,6 +379,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP get { return m_startpos; } set { m_startpos = value; } } + public bool DeliverPackets + { + get { return m_deliverPackets; } + set { + m_deliverPackets = value; + m_udpClient.m_deliverPackets = value; + } + } public UUID AgentId { get { return m_agentId; } } public UUID ActiveGroupId { get { return m_activeGroupID; } } public string ActiveGroupName { get { return m_activeGroupName; } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 6232c48..eebbfa5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -149,6 +149,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private int m_defaultRTO = 3000; private int m_maxRTO = 60000; + public bool m_deliverPackets = true; /// /// Default constructor @@ -389,6 +390,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (category >= 0 && category < m_packetOutboxes.Length) { OpenSim.Framework.LocklessQueue queue = m_packetOutboxes[category]; + + if (m_deliverPackets == false) + { + queue.Enqueue(packet); + return true; + } + TokenBucket bucket = m_throttleCategories[category]; if (bucket.RemoveTokens(packet.Buffer.DataLength)) @@ -419,6 +427,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// True if any packets were sent, otherwise false public bool DequeueOutgoing() { + if (m_deliverPackets == false) return false; + OutgoingPacket packet; OpenSim.Framework.LocklessQueue queue; TokenBucket bucket; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index cda461c..3b63bcd 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -900,7 +900,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Start the IClientAPI // Spin it off so that it doesn't clog up the LLUDPServer - Util.FireAndForget(delegate(object o) { client.Start(); }); + + //First, and very importantly: + // + //Set our DeliverPackets flag in the client to *false* + //this will prevent us from missing important messages + //before the modules are bound + client.DeliverPackets = false; + + Util.FireAndForget( + delegate + { + try + { + client.Start(); + } + finally + { + //Now, release the hounds. er, packets. + client.DeliverPackets = true; + } + } + ); } else { -- cgit v1.1