diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index f1a1812..e52ac37 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -92,7 +92,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
92 | /// <summary>Packets we have sent that need to be ACKed by the client</summary> | 92 | /// <summary>Packets we have sent that need to be ACKed by the client</summary> |
93 | public readonly UnackedPacketCollection NeedAcks = new UnackedPacketCollection(); | 93 | public readonly UnackedPacketCollection NeedAcks = new UnackedPacketCollection(); |
94 | /// <summary>ACKs that are queued up, waiting to be sent to the client</summary> | 94 | /// <summary>ACKs that are queued up, waiting to be sent to the client</summary> |
95 | public readonly OpenSim.Framework.LocklessQueue<uint> PendingAcks = new OpenSim.Framework.LocklessQueue<uint>(); | 95 | public readonly DoubleLocklessQueue<uint> PendingAcks = new DoubleLocklessQueue<uint>(); |
96 | 96 | ||
97 | /// <summary>Current packet sequence number</summary> | 97 | /// <summary>Current packet sequence number</summary> |
98 | public int CurrentSequence; | 98 | public int CurrentSequence; |
@@ -146,7 +146,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
146 | /// <summary>Throttle buckets for each packet category</summary> | 146 | /// <summary>Throttle buckets for each packet category</summary> |
147 | private readonly TokenBucket[] m_throttleCategories; | 147 | private readonly TokenBucket[] m_throttleCategories; |
148 | /// <summary>Outgoing queues for throttled packets</summary> | 148 | /// <summary>Outgoing queues for throttled packets</summary> |
149 | private readonly OpenSim.Framework.LocklessQueue<OutgoingPacket>[] m_packetOutboxes = new OpenSim.Framework.LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; | 149 | private readonly DoubleLocklessQueue<OutgoingPacket>[] m_packetOutboxes = new DoubleLocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; |
150 | /// <summary>A container that can hold one packet for each outbox, used to store | 150 | /// <summary>A container that can hold one packet for each outbox, used to store |
151 | /// dequeued packets that are being held for throttling</summary> | 151 | /// dequeued packets that are being held for throttling</summary> |
152 | private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; | 152 | private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; |
@@ -202,7 +202,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
202 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; | 202 | ThrottleOutPacketType type = (ThrottleOutPacketType)i; |
203 | 203 | ||
204 | // Initialize the packet outboxes, where packets sit while they are waiting for tokens | 204 | // Initialize the packet outboxes, where packets sit while they are waiting for tokens |
205 | m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); | 205 | m_packetOutboxes[i] = new DoubleLocklessQueue<OutgoingPacket>(); |
206 | // Initialize the token buckets that control the throttling for each category | 206 | // Initialize the token buckets that control the throttling for each category |
207 | m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetRate(type)); | 207 | m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetRate(type)); |
208 | } | 208 | } |
@@ -430,15 +430,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
430 | /// </returns> | 430 | /// </returns> |
431 | public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue) | 431 | public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue) |
432 | { | 432 | { |
433 | return EnqueueOutgoing(packet, forceQueue, false); | ||
434 | } | ||
435 | |||
436 | public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue, bool highPriority) | ||
437 | { | ||
433 | int category = (int)packet.Category; | 438 | int category = (int)packet.Category; |
434 | 439 | ||
435 | if (category >= 0 && category < m_packetOutboxes.Length) | 440 | if (category >= 0 && category < m_packetOutboxes.Length) |
436 | { | 441 | { |
437 | OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; | 442 | DoubleLocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; |
438 | 443 | ||
439 | if (m_deliverPackets == false) | 444 | if (m_deliverPackets == false) |
440 | { | 445 | { |
441 | queue.Enqueue(packet); | 446 | queue.Enqueue(packet, highPriority); |
442 | return true; | 447 | return true; |
443 | } | 448 | } |
444 | 449 | ||
@@ -449,7 +454,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
449 | // queued packets | 454 | // queued packets |
450 | if (queue.Count > 0) | 455 | if (queue.Count > 0) |
451 | { | 456 | { |
452 | queue.Enqueue(packet); | 457 | queue.Enqueue(packet, highPriority); |
453 | return true; | 458 | return true; |
454 | } | 459 | } |
455 | 460 | ||
@@ -462,7 +467,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
462 | else | 467 | else |
463 | { | 468 | { |
464 | // Force queue specified or not enough tokens in the bucket, queue this packet | 469 | // Force queue specified or not enough tokens in the bucket, queue this packet |
465 | queue.Enqueue(packet); | 470 | queue.Enqueue(packet, highPriority); |
466 | return true; | 471 | return true; |
467 | } | 472 | } |
468 | } | 473 | } |
@@ -494,7 +499,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
494 | if (m_deliverPackets == false) return false; | 499 | if (m_deliverPackets == false) return false; |
495 | 500 | ||
496 | OutgoingPacket packet = null; | 501 | OutgoingPacket packet = null; |
497 | OpenSim.Framework.LocklessQueue<OutgoingPacket> queue; | 502 | DoubleLocklessQueue<OutgoingPacket> queue; |
498 | TokenBucket bucket; | 503 | TokenBucket bucket; |
499 | bool packetSent = false; | 504 | bool packetSent = false; |
500 | ThrottleOutPacketTypeFlags emptyCategories = 0; | 505 | ThrottleOutPacketTypeFlags emptyCategories = 0; |
@@ -534,7 +539,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
534 | } | 539 | } |
535 | catch | 540 | catch |
536 | { | 541 | { |
537 | m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); | 542 | m_packetOutboxes[i] = new DoubleLocklessQueue<OutgoingPacket>(); |
538 | } | 543 | } |
539 | if (success) | 544 | if (success) |
540 | { | 545 | { |
@@ -567,7 +572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
567 | } | 572 | } |
568 | else | 573 | else |
569 | { | 574 | { |
570 | m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); | 575 | m_packetOutboxes[i] = new DoubleLocklessQueue<OutgoingPacket>(); |
571 | emptyCategories |= CategoryToFlag(i); | 576 | emptyCategories |= CategoryToFlag(i); |
572 | } | 577 | } |
573 | } | 578 | } |
@@ -724,4 +729,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
724 | } | 729 | } |
725 | } | 730 | } |
726 | } | 731 | } |
732 | |||
733 | public class DoubleLocklessQueue<T> : OpenSim.Framework.LocklessQueue<T> | ||
734 | { | ||
735 | OpenSim.Framework.LocklessQueue<T> highQueue = new OpenSim.Framework.LocklessQueue<T>(); | ||
736 | |||
737 | public override int Count | ||
738 | { | ||
739 | get | ||
740 | { | ||
741 | return base.Count + highQueue.Count; | ||
742 | } | ||
743 | } | ||
744 | |||
745 | public override bool Dequeue(out T item) | ||
746 | { | ||
747 | if (highQueue.Dequeue(out item)) | ||
748 | return true; | ||
749 | |||
750 | return base.Dequeue(out item); | ||
751 | } | ||
752 | |||
753 | public void Enqueue(T item, bool highPriority) | ||
754 | { | ||
755 | if (highPriority) | ||
756 | highQueue.Enqueue(item); | ||
757 | else | ||
758 | Enqueue(item); | ||
759 | } | ||
760 | } | ||
727 | } | 761 | } |