diff options
author | Justin Clark-Casey (justincc) | 2011-09-24 01:10:23 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-09-24 01:10:23 +0100 |
commit | 839c1cdcc4e9ce410636becb5b81190463dec5bf (patch) | |
tree | 3fee3b080031cf9af7a2ca5a5f80e2088f724c2c /OpenSim | |
parent | Clarify explanation of the "DeleteScriptsOnStartup" config switch and add thi... (diff) | |
download | opensim-SC-839c1cdcc4e9ce410636becb5b81190463dec5bf.zip opensim-SC-839c1cdcc4e9ce410636becb5b81190463dec5bf.tar.gz opensim-SC-839c1cdcc4e9ce410636becb5b81190463dec5bf.tar.bz2 opensim-SC-839c1cdcc4e9ce410636becb5b81190463dec5bf.tar.xz |
Improve locking when access queue in EventQueueGetModule
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 139d8b8..8d0c7a1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -179,9 +179,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
179 | { | 179 | { |
180 | Queue<OSD> queue = GetQueue(avatarID); | 180 | Queue<OSD> queue = GetQueue(avatarID); |
181 | if (queue != null) | 181 | if (queue != null) |
182 | queue.Enqueue(ev); | 182 | lock (queue) |
183 | queue.Enqueue(ev); | ||
183 | } | 184 | } |
184 | catch(NullReferenceException e) | 185 | catch (NullReferenceException e) |
185 | { | 186 | { |
186 | m_log.Error("[EVENTQUEUE] Caught exception: " + e); | 187 | m_log.Error("[EVENTQUEUE] Caught exception: " + e); |
187 | return false; | 188 | return false; |
@@ -338,12 +339,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
338 | Queue<OSD> queue = GetQueue(agentID); | 339 | Queue<OSD> queue = GetQueue(agentID); |
339 | if (queue != null) | 340 | if (queue != null) |
340 | lock (queue) | 341 | lock (queue) |
341 | { | 342 | return queue.Count > 0; |
342 | if (queue.Count > 0) | 343 | |
343 | return true; | ||
344 | else | ||
345 | return false; | ||
346 | } | ||
347 | return false; | 344 | return false; |
348 | } | 345 | } |
349 | 346 | ||
@@ -358,8 +355,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
358 | element = queue.Dequeue(); // 15s timeout | 355 | element = queue.Dequeue(); // 15s timeout |
359 | } | 356 | } |
360 | 357 | ||
361 | |||
362 | |||
363 | int thisID = 0; | 358 | int thisID = 0; |
364 | lock (m_ids) | 359 | lock (m_ids) |
365 | thisID = m_ids[pAgentId]; | 360 | thisID = m_ids[pAgentId]; |
@@ -431,7 +426,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
431 | // } | 426 | // } |
432 | 427 | ||
433 | Queue<OSD> queue = TryGetQueue(agentID); | 428 | Queue<OSD> queue = TryGetQueue(agentID); |
434 | OSD element = queue.Dequeue(); // 15s timeout | 429 | OSD element; |
430 | |||
431 | lock (queue) | ||
432 | element = queue.Dequeue(); // 15s timeout | ||
435 | 433 | ||
436 | Hashtable responsedata = new Hashtable(); | 434 | Hashtable responsedata = new Hashtable(); |
437 | 435 | ||
@@ -470,10 +468,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
470 | else | 468 | else |
471 | { | 469 | { |
472 | array.Add(element); | 470 | array.Add(element); |
473 | while (queue.Count > 0) | 471 | |
472 | lock (queue) | ||
474 | { | 473 | { |
475 | array.Add(queue.Dequeue()); | 474 | while (queue.Count > 0) |
476 | thisID++; | 475 | { |
476 | array.Add(queue.Dequeue()); | ||
477 | thisID++; | ||
478 | } | ||
477 | } | 479 | } |
478 | } | 480 | } |
479 | 481 | ||
@@ -520,6 +522,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
520 | AvatarID = m_QueueUUIDAvatarMapping[capUUID]; | 522 | AvatarID = m_QueueUUIDAvatarMapping[capUUID]; |
521 | } | 523 | } |
522 | } | 524 | } |
525 | |||
523 | if (AvatarID != UUID.Zero) | 526 | if (AvatarID != UUID.Zero) |
524 | { | 527 | { |
525 | return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); | 528 | return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); |