aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-17 20:30:50 +0000
committerJustin Clarke Casey2008-10-17 20:30:50 +0000
commit4ccac88cf662b8f50afeaea13451550ae4c0b21e (patch)
treecaee41de6264f0a48060851529d47ff038ef5fe3 /OpenSim/Region/ClientStack
parent* close two potential race conditions where a new asynchronous UDP recieve co... (diff)
downloadopensim-SC-4ccac88cf662b8f50afeaea13451550ae4c0b21e.zip
opensim-SC-4ccac88cf662b8f50afeaea13451550ae4c0b21e.tar.gz
opensim-SC-4ccac88cf662b8f50afeaea13451550ae4c0b21e.tar.bz2
opensim-SC-4ccac88cf662b8f50afeaea13451550ae4c0b21e.tar.xz
* Don't worry about trying to populate the other dictionaries if a client's circuitcode is already found in the first one
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs35
1 files changed, 22 insertions, 13 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 01a4dd6..a4a6b93 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -46,12 +46,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 /// <value>
50 /// The client circuits established with this UDP server. If a client exists here we can also assume that
51 /// it is populated in clientCircuits_reverse and proxyCircuits (if relevant)
52 /// </value>
49 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 53 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
50
51 //public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>();
52 public Hashtable clientCircuits_reverse = Hashtable.Synchronized(new Hashtable()); 54 public Hashtable clientCircuits_reverse = Hashtable.Synchronized(new Hashtable());
53
54 protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>(); 55 protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>();
56
55 private Socket m_socket; 57 private Socket m_socket;
56 protected IPEndPoint ServerIncoming; 58 protected IPEndPoint ServerIncoming;
57 protected byte[] RecvBuffer = new byte[4096]; 59 protected byte[] RecvBuffer = new byte[4096];
@@ -360,7 +362,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
360 { 362 {
361 //Slave regions don't accept new clients 363 //Slave regions don't accept new clients
362 if (m_localScene.Region_Status != RegionStatus.SlaveScene) 364 if (m_localScene.Region_Status != RegionStatus.SlaveScene)
363 { 365 {
366 bool foundExistingCircuit = false;
367
364 lock (clientCircuits) 368 lock (clientCircuits)
365 { 369 {
366 if (!clientCircuits.ContainsKey(epSender)) 370 if (!clientCircuits.ContainsKey(epSender))
@@ -370,20 +374,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
370 useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); 374 useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code);
371 375
372 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 376 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
377
378 foundExistingCircuit = true;
373 } 379 }
374 } 380 }
375 381
376 // This doesn't need locking as it's synchronized data 382 if (!foundExistingCircuit)
377 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
378 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender);
379
380 lock (proxyCircuits)
381 { 383 {
382 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) 384 // This doesn't need locking as it's synchronized data
383 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); 385 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
384 } 386 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender);
385 387
386 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy); 388 lock (proxyCircuits)
389 {
390 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
391 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy);
392 }
393
394 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy);
395 }
387 } 396 }
388 397
389 // Ack the UseCircuitCode packet 398 // Ack the UseCircuitCode packet