aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-18 21:24:34 +0000
committerTeravus Ovares2008-02-18 21:24:34 +0000
commitd0b218f667bfd796257634e3b352ca195d7d02b2 (patch)
treecc00f8b96f57176fa4e1f3a559d73a272dd0d57d
parent* Probably fixed the corner freeze bug. On uninitialized avatar, ODEPlugin ... (diff)
downloadopensim-SC-d0b218f667bfd796257634e3b352ca195d7d02b2.zip
opensim-SC-d0b218f667bfd796257634e3b352ca195d7d02b2.tar.gz
opensim-SC-d0b218f667bfd796257634e3b352ca195d7d02b2.tar.bz2
opensim-SC-d0b218f667bfd796257634e3b352ca195d7d02b2.tar.xz
Committing ahzz's patch #619 - Description:
Patch provided by Openlifegrid.com Adds locks around clientCircuits and clientCircuits_reverse Adds existance check on adding to clientCircuits for clients resending UseCircuit packet. Adds locks around Clientmanager.m_clients for add/remove/tryGet calls
-rw-r--r--OpenSim/Framework/ClientManager.cs33
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs34
2 files changed, 48 insertions, 19 deletions
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index 51ebc9b..3df883d 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -72,20 +72,28 @@ namespace OpenSim.Framework
72 public void Remove(uint id) 72 public void Remove(uint id)
73 { 73 {
74 //m_log.InfoFormat("[CLIENT]: Removing client with code {0}, current count {1}", id, m_clients.Count); 74 //m_log.InfoFormat("[CLIENT]: Removing client with code {0}, current count {1}", id, m_clients.Count);
75 m_clients.Remove(id); 75 lock (m_clients)
76 {
77 m_clients.Remove(id);
78 }
76 m_log.InfoFormat("[CLIENT]: Removed client with code {0}, new client count {1}", id, m_clients.Count); 79 m_log.InfoFormat("[CLIENT]: Removed client with code {0}, new client count {1}", id, m_clients.Count);
77 } 80 }
78 81
79 public void Add(uint id, IClientAPI client) 82 public void Add(uint id, IClientAPI client)
80 { 83 {
81 m_clients.Add(id, client); 84 lock (m_clients)
85 {
86 m_clients.Add(id, client);
87 }
82 } 88 }
83 89
84 public void InPacket(uint circuitCode, Packet packet) 90 public void InPacket(uint circuitCode, Packet packet)
85 { 91 {
86 IClientAPI client; 92 IClientAPI client;
87 93 bool tryGetRet = false;
88 if (m_clients.TryGetValue(circuitCode, out client)) 94 lock (m_clients)
95 tryGetRet = m_clients.TryGetValue(circuitCode, out client);
96 if(tryGetRet)
89 { 97 {
90 client.InPacket(packet); 98 client.InPacket(packet);
91 } 99 }
@@ -94,8 +102,10 @@ namespace OpenSim.Framework
94 public void CloseAllAgents(uint circuitCode) 102 public void CloseAllAgents(uint circuitCode)
95 { 103 {
96 IClientAPI client; 104 IClientAPI client;
97 105 bool tryGetRet = false;
98 if (m_clients.TryGetValue(circuitCode, out client)) 106 lock (m_clients)
107 tryGetRet = m_clients.TryGetValue(circuitCode, out client);
108 if (tryGetRet)
99 { 109 {
100 CloseAllCircuits(client.AgentId); 110 CloseAllCircuits(client.AgentId);
101 } 111 }
@@ -111,8 +121,10 @@ namespace OpenSim.Framework
111 IClientAPI client; 121 IClientAPI client;
112 try 122 try
113 { 123 {
114 124 bool tryGetRet = false;
115 if (m_clients.TryGetValue(circuits[i], out client)) 125 lock (m_clients)
126 tryGetRet = m_clients.TryGetValue(circuits[i], out client);
127 if(tryGetRet)
116 { 128 {
117 Remove(client.CircuitCode); 129 Remove(client.CircuitCode);
118 client.Close(false); 130 client.Close(false);
@@ -176,7 +188,10 @@ namespace OpenSim.Framework
176 188
177 public bool TryGetClient(uint circuitId, out IClientAPI user) 189 public bool TryGetClient(uint circuitId, out IClientAPI user)
178 { 190 {
179 return m_clients.TryGetValue(circuitId, out user); 191 lock (m_clients)
192 {
193 return m_clients.TryGetValue(circuitId, out user);
194 }
180 } 195 }
181 } 196 }
182} 197}
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 7b32490..1997453 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -311,9 +311,12 @@ namespace OpenSim.Region.ClientStack
311 private void CloseEndPoint(EndPoint sender) 311 private void CloseEndPoint(EndPoint sender)
312 { 312 {
313 uint circuit; 313 uint circuit;
314 if (clientCircuits.TryGetValue(sender, out circuit)) 314 lock (clientCircuits)
315 { 315 {
316 m_packetServer.CloseCircuit(circuit); 316 if (clientCircuits.TryGetValue(sender, out circuit))
317 {
318 m_packetServer.CloseCircuit(circuit);
319 }
317 } 320 }
318 } 321 }
319 322
@@ -322,12 +325,17 @@ namespace OpenSim.Region.ClientStack
322 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; 325 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
323 lock (clientCircuits) 326 lock (clientCircuits)
324 { 327 {
325 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 328 if (!clientCircuits.ContainsKey(epSender))
329 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
330 else
331 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
326 } 332 }
327 lock (clientCircuits_reverse) 333 lock (clientCircuits_reverse)
328 { 334 {
329 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) 335 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
330 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); 336 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender);
337 else
338 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
331 } 339 }
332 340
333 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); 341 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass);
@@ -380,22 +388,28 @@ namespace OpenSim.Region.ClientStack
380 { 388 {
381 // find the endpoint for this circuit 389 // find the endpoint for this circuit
382 EndPoint sendto = null; 390 EndPoint sendto = null;
383 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 391 lock (clientCircuits_reverse)
384 { 392 {
385 //we found the endpoint so send the packet to it 393 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
386 Server.SendTo(buffer, size, flags, sendto); 394 {
395 //we found the endpoint so send the packet to it
396 Server.SendTo(buffer, size, flags, sendto);
397 }
387 } 398 }
388 } 399 }
389 400
390 public virtual void RemoveClientCircuit(uint circuitcode) 401 public virtual void RemoveClientCircuit(uint circuitcode)
391 { 402 {
392 EndPoint sendto = null; 403 EndPoint sendto = null;
393 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 404 lock (clientCircuits_reverse)
394 { 405 {
395 clientCircuits.Remove(sendto); 406 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
407 {
408 clientCircuits.Remove(sendto);
396 409
397 410
398 clientCircuits_reverse.Remove(circuitcode); 411 clientCircuits_reverse.Remove(circuitcode);
412 }
399 } 413 }
400 } 414 }
401 } 415 }