diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
3 files changed, 66 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs index 09edc94..5658dba 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs | |||
@@ -31,9 +31,10 @@ using OpenMetaverse.Packets; | |||
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | 32 | ||
33 | namespace OpenSim.Region.ClientStack.LindenUDP | 33 | namespace OpenSim.Region.ClientStack.LindenUDP |
34 | { | 34 | { |
35 | public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); | 35 | public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); |
36 | public delegate void PacketDrop(Packet pack, Object id); | 36 | public delegate void PacketDrop(Packet pack, Object id); |
37 | public delegate void QueueEmpty(ThrottleOutPacketType queue); | ||
37 | public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); | 38 | public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); |
38 | 39 | ||
39 | /// <summary> | 40 | /// <summary> |
@@ -44,6 +45,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
44 | { | 45 | { |
45 | event PacketStats OnPacketStats; | 46 | event PacketStats OnPacketStats; |
46 | event PacketDrop OnPacketDrop; | 47 | event PacketDrop OnPacketDrop; |
48 | event QueueEmpty OnQueueEmpty; | ||
47 | SynchronizeClientHandler SynchronizeClient { set; } | 49 | SynchronizeClientHandler SynchronizeClient { set; } |
48 | 50 | ||
49 | int PacketsReceived { get; } | 51 | int PacketsReceived { get; } |
@@ -61,7 +63,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
61 | /// <summary> | 63 | /// <summary> |
62 | /// Take action depending on the type and contents of an received packet. | 64 | /// Take action depending on the type and contents of an received packet. |
63 | /// </summary> | 65 | /// </summary> |
64 | /// <param name="item"></param> | 66 | /// <param name="item"></param> |
65 | void ProcessInPacket(LLQueItem item); | 67 | void ProcessInPacket(LLQueItem item); |
66 | 68 | ||
67 | void ProcessOutPacket(LLQueItem item); | 69 | void ProcessOutPacket(LLQueItem item); |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 67ece75..801e0c5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs | |||
@@ -129,6 +129,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
129 | // | 129 | // |
130 | public event PacketStats OnPacketStats; | 130 | public event PacketStats OnPacketStats; |
131 | public event PacketDrop OnPacketDrop; | 131 | public event PacketDrop OnPacketDrop; |
132 | public event QueueEmpty OnQueueEmpty; | ||
132 | 133 | ||
133 | 134 | ||
134 | //private SynchronizeClientHandler m_SynchronizeClient = null; | 135 | //private SynchronizeClientHandler m_SynchronizeClient = null; |
@@ -172,6 +173,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
172 | 173 | ||
173 | m_PacketQueue = new LLPacketQueue(client.AgentId, userSettings); | 174 | m_PacketQueue = new LLPacketQueue(client.AgentId, userSettings); |
174 | 175 | ||
176 | m_PacketQueue.OnQueueEmpty += TriggerOnQueueEmpty; | ||
177 | |||
175 | m_AckTimer.Elapsed += AckTimerElapsed; | 178 | m_AckTimer.Elapsed += AckTimerElapsed; |
176 | m_AckTimer.Start(); | 179 | m_AckTimer.Start(); |
177 | } | 180 | } |
@@ -769,6 +772,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
769 | handlerPacketDrop(packet, id); | 772 | handlerPacketDrop(packet, id); |
770 | } | 773 | } |
771 | 774 | ||
775 | private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) | ||
776 | { | ||
777 | QueueEmpty handlerQueueEmpty = OnQueueEmpty; | ||
778 | |||
779 | if (handlerQueueEmpty == null) | ||
780 | return; | ||
781 | |||
782 | handlerQueueEmpty(queue); | ||
783 | } | ||
784 | |||
772 | // Convert the packet to bytes and stuff it onto the send queue | 785 | // Convert the packet to bytes and stuff it onto the send queue |
773 | // | 786 | // |
774 | public void ProcessOutPacket(LLQueItem item) | 787 | public void ProcessOutPacket(LLQueItem item) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 6dd0697..f08f1b6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | |||
@@ -105,6 +105,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
105 | 105 | ||
106 | private UUID m_agentId; | 106 | private UUID m_agentId; |
107 | 107 | ||
108 | public event QueueEmpty OnQueueEmpty; | ||
109 | |||
108 | public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) | 110 | public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) |
109 | { | 111 | { |
110 | // While working on this, the BlockingQueue had me fooled for a bit. | 112 | // While working on this, the BlockingQueue had me fooled for a bit. |
@@ -293,30 +295,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
293 | if (LandOutgoingPacketQueue.Count > 0) | 295 | if (LandOutgoingPacketQueue.Count > 0) |
294 | { | 296 | { |
295 | SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); | 297 | SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); |
298 | TriggerOnQueueEmpty(ThrottleOutPacketType.Land); | ||
296 | } | 299 | } |
297 | if (WindOutgoingPacketQueue.Count > 0) | 300 | if (WindOutgoingPacketQueue.Count > 0) |
298 | { | 301 | { |
299 | SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); | 302 | SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); |
303 | TriggerOnQueueEmpty(ThrottleOutPacketType.Wind); | ||
300 | } | 304 | } |
301 | if (CloudOutgoingPacketQueue.Count > 0) | 305 | if (CloudOutgoingPacketQueue.Count > 0) |
302 | { | 306 | { |
303 | SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); | 307 | SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); |
308 | TriggerOnQueueEmpty(ThrottleOutPacketType.Cloud); | ||
304 | } | 309 | } |
310 | bool tasksSent = false; | ||
305 | if (TaskOutgoingPacketQueue.Count > 0) | 311 | if (TaskOutgoingPacketQueue.Count > 0) |
306 | { | 312 | { |
313 | tasksSent = true; | ||
307 | SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); | 314 | SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); |
308 | } | 315 | } |
309 | if (TaskLowpriorityPacketQueue.Count > 0) | 316 | if (TaskLowpriorityPacketQueue.Count > 0) |
310 | { | 317 | { |
318 | tasksSent = true; | ||
311 | SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); | 319 | SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); |
312 | } | 320 | } |
321 | if (tasksSent) | ||
322 | { | ||
323 | TriggerOnQueueEmpty(ThrottleOutPacketType.Task); | ||
324 | } | ||
313 | if (TextureOutgoingPacketQueue.Count > 0) | 325 | if (TextureOutgoingPacketQueue.Count > 0) |
314 | { | 326 | { |
315 | SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); | 327 | SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); |
328 | TriggerOnQueueEmpty(ThrottleOutPacketType.Texture); | ||
316 | } | 329 | } |
317 | if (AssetOutgoingPacketQueue.Count > 0) | 330 | if (AssetOutgoingPacketQueue.Count > 0) |
318 | { | 331 | { |
319 | SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); | 332 | SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); |
333 | TriggerOnQueueEmpty(ThrottleOutPacketType.Asset); | ||
320 | } | 334 | } |
321 | } | 335 | } |
322 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); | 336 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); |
@@ -405,6 +419,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
405 | bool qchanged = true; | 419 | bool qchanged = true; |
406 | 420 | ||
407 | ResetCounters(); | 421 | ResetCounters(); |
422 | |||
423 | List<ThrottleOutPacketType> Empty = new List<ThrottleOutPacketType>(); | ||
408 | // m_log.Info("[THROTTLE]: Entering Throttle"); | 424 | // m_log.Info("[THROTTLE]: Entering Throttle"); |
409 | while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) | 425 | while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) |
410 | { | 426 | { |
@@ -431,6 +447,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
431 | TotalThrottle.AddBytes(qpack.Length); | 447 | TotalThrottle.AddBytes(qpack.Length); |
432 | LandThrottle.AddBytes(qpack.Length); | 448 | LandThrottle.AddBytes(qpack.Length); |
433 | qchanged = true; | 449 | qchanged = true; |
450 | |||
451 | if (LandOutgoingPacketQueue.Count == 0) | ||
452 | Empty.Add(ThrottleOutPacketType.Land); | ||
434 | } | 453 | } |
435 | 454 | ||
436 | if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) | 455 | if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) |
@@ -441,6 +460,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
441 | TotalThrottle.AddBytes(qpack.Length); | 460 | TotalThrottle.AddBytes(qpack.Length); |
442 | WindThrottle.AddBytes(qpack.Length); | 461 | WindThrottle.AddBytes(qpack.Length); |
443 | qchanged = true; | 462 | qchanged = true; |
463 | |||
464 | if (WindOutgoingPacketQueue.Count == 0) | ||
465 | Empty.Add(ThrottleOutPacketType.Wind); | ||
444 | } | 466 | } |
445 | 467 | ||
446 | if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) | 468 | if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) |
@@ -451,6 +473,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
451 | TotalThrottle.AddBytes(qpack.Length); | 473 | TotalThrottle.AddBytes(qpack.Length); |
452 | CloudThrottle.AddBytes(qpack.Length); | 474 | CloudThrottle.AddBytes(qpack.Length); |
453 | qchanged = true; | 475 | qchanged = true; |
476 | |||
477 | if (CloudOutgoingPacketQueue.Count == 0) | ||
478 | Empty.Add(ThrottleOutPacketType.Cloud); | ||
454 | } | 479 | } |
455 | 480 | ||
456 | if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) | 481 | if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) |
@@ -470,6 +495,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
470 | TotalThrottle.AddBytes(qpack.Length); | 495 | TotalThrottle.AddBytes(qpack.Length); |
471 | TaskThrottle.AddBytes(qpack.Length); | 496 | TaskThrottle.AddBytes(qpack.Length); |
472 | qchanged = true; | 497 | qchanged = true; |
498 | |||
499 | if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0) | ||
500 | Empty.Add(ThrottleOutPacketType.Task); | ||
473 | } | 501 | } |
474 | 502 | ||
475 | if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) | 503 | if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) |
@@ -480,6 +508,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
480 | TotalThrottle.AddBytes(qpack.Length); | 508 | TotalThrottle.AddBytes(qpack.Length); |
481 | TextureThrottle.AddBytes(qpack.Length); | 509 | TextureThrottle.AddBytes(qpack.Length); |
482 | qchanged = true; | 510 | qchanged = true; |
511 | |||
512 | if (TextureOutgoingPacketQueue.Count == 0) | ||
513 | Empty.Add(ThrottleOutPacketType.Texture); | ||
483 | } | 514 | } |
484 | 515 | ||
485 | if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) | 516 | if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) |
@@ -490,12 +521,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
490 | TotalThrottle.AddBytes(qpack.Length); | 521 | TotalThrottle.AddBytes(qpack.Length); |
491 | AssetThrottle.AddBytes(qpack.Length); | 522 | AssetThrottle.AddBytes(qpack.Length); |
492 | qchanged = true; | 523 | qchanged = true; |
524 | |||
525 | if (AssetOutgoingPacketQueue.Count == 0) | ||
526 | Empty.Add(ThrottleOutPacketType.Asset); | ||
493 | } | 527 | } |
494 | } | 528 | } |
495 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); | 529 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); |
530 | |||
531 | foreach (ThrottleOutPacketType t in Empty) | ||
532 | { | ||
533 | TriggerOnQueueEmpty(t); | ||
534 | } | ||
496 | } | 535 | } |
497 | } | 536 | } |
498 | 537 | ||
538 | private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) | ||
539 | { | ||
540 | QueueEmpty handlerQueueEmpty = OnQueueEmpty; | ||
541 | |||
542 | if (handlerQueueEmpty == null) | ||
543 | return; | ||
544 | |||
545 | handlerQueueEmpty(queue); | ||
546 | } | ||
547 | |||
499 | private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) | 548 | private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) |
500 | { | 549 | { |
501 | // just to change the signature, and that ProcessThrottle | 550 | // just to change the signature, and that ProcessThrottle |