aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2011-02-08 17:53:01 -0800
committerDiva Canto2011-02-08 17:53:01 -0800
commit117462cba18fd0f9610d854760b92362b3beea7c (patch)
tree1ed1532ce8bd68b70dda52aacf5599f81c8af8c8 /OpenSim/Region
parentMinor addition to the previous commit (diff)
downloadopensim-SC_OLD-117462cba18fd0f9610d854760b92362b3beea7c.zip
opensim-SC_OLD-117462cba18fd0f9610d854760b92362b3beea7c.tar.gz
opensim-SC_OLD-117462cba18fd0f9610d854760b92362b3beea7c.tar.bz2
opensim-SC_OLD-117462cba18fd0f9610d854760b92362b3beea7c.tar.xz
Avoid potential race conditions on UseCircuitCode. I artificially made the race condition happen, and got very similar results to those described in mantis #5365 -- no prims/avie sent back.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs51
1 files changed, 28 insertions, 23 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index bfbe959..04fec95 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -640,10 +640,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
640 { 640 {
641 object[] array = new object[] { buffer, packet }; 641 object[] array = new object[] { buffer, packet };
642 642
643 if (m_asyncPacketHandling) 643 Util.FireAndForget(HandleUseCircuitCode, array);
644 Util.FireAndForget(HandleUseCircuitCode, array);
645 else
646 HandleUseCircuitCode(array);
647 644
648 return; 645 return;
649 } 646 }
@@ -857,11 +854,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
857 854
858 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; 855 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
859 856
857 // Acknowledge the UseCircuitCode packet immediately, even before processing further
858 // This is so that the client doesn't send another one
859 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
860
860 // Begin the process of adding the client to the simulator 861 // Begin the process of adding the client to the simulator
861 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 862 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
862
863 // Acknowledge the UseCircuitCode packet
864 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
865 863
866// m_log.DebugFormat( 864// m_log.DebugFormat(
867// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 865// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
@@ -927,25 +925,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
927 925
928 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 926 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
929 { 927 {
930 // Create the LLUDPClient 928 // In priciple there shouldn't be more than one thread here, ever.
931 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); 929 // But in case that happens, we need to synchronize this piece of code
932 IClientAPI existingClient; 930 // because it's too important
933 931 lock (this)
934 if (!m_scene.TryGetClient(agentID, out existingClient))
935 { 932 {
936 // Create the LLClientView 933 IClientAPI existingClient;
937 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
938 client.OnLogout += LogoutHandler;
939 934
940 client.DisableFacelights = m_disableFacelights; 935 if (!m_scene.TryGetClient(agentID, out existingClient))
936 {
937 // Create the LLUDPClient
938 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
939 // Create the LLClientView
940 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
941 client.OnLogout += LogoutHandler;
941 942
942 // Start the IClientAPI 943 client.DisableFacelights = m_disableFacelights;
943 client.Start(); 944
944 } 945 // Start the IClientAPI
945 else 946 client.Start();
946 { 947
947 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}", 948 }
948 udpClient.AgentID, remoteEndPoint, circuitCode); 949 else
950 {
951 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
952 existingClient.AgentId, remoteEndPoint, circuitCode);
953 }
949 } 954 }
950 } 955 }
951 956