From 4ccac88cf662b8f50afeaea13451550ae4c0b21e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 17 Oct 2008 20:30:50 +0000 Subject: [PATCH] * Don't worry about trying to populate the other dictionaries if a client's circuitcode is already found in the first one --- .../ClientStack/LindenUDP/LLUDPServer.cs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 01a4dd6db5..a4a6b93245 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -46,12 +46,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// The client circuits established with this UDP server. If a client exists here we can also assume that + /// it is populated in clientCircuits_reverse and proxyCircuits (if relevant) + /// protected Dictionary clientCircuits = new Dictionary(); - - //public Dictionary clientCircuits_reverse = new Dictionary(); public Hashtable clientCircuits_reverse = Hashtable.Synchronized(new Hashtable()); - protected Dictionary proxyCircuits = new Dictionary(); + private Socket m_socket; protected IPEndPoint ServerIncoming; protected byte[] RecvBuffer = new byte[4096]; @@ -360,7 +362,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //Slave regions don't accept new clients if (m_localScene.Region_Status != RegionStatus.SlaveScene) - { + { + bool foundExistingCircuit = false; + lock (clientCircuits) { if (!clientCircuits.ContainsKey(epSender)) @@ -370,20 +374,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + + foundExistingCircuit = true; } } - // This doesn't need locking as it's synchronized data - if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) - clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); - - lock (proxyCircuits) + if (!foundExistingCircuit) { - if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) - proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); - } + // This doesn't need locking as it's synchronized data + if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) + clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); - PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy); + lock (proxyCircuits) + { + if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) + proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); + } + + PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy); + } } // Ack the UseCircuitCode packet