aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorMelanie2013-01-16 19:29:27 +0100
committerMelanie2013-01-16 19:29:27 +0100
commit582cb89beb597247ceb6d82cdfc8fc983ffe8496 (patch)
tree3356edc5d30a637d82d3fc7e4d1783abcf3c362c /OpenSim/Region/ClientStack
parentMerge branch 'ubitwork' into avination (diff)
downloadopensim-SC-582cb89beb597247ceb6d82cdfc8fc983ffe8496.zip
opensim-SC-582cb89beb597247ceb6d82cdfc8fc983ffe8496.tar.gz
opensim-SC-582cb89beb597247ceb6d82cdfc8fc983ffe8496.tar.bz2
opensim-SC-582cb89beb597247ceb6d82cdfc8fc983ffe8496.tar.xz
Add a way to put things at the front of the queue for any throttle group.
Adds a DoubleLocklessQueue and uses it for the outgoing buckets. Added a flag value to the Throttle Type (again) because although it's hacky, it's the best of a bad bunch to get the message through the UDP stack to where it's needed.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs8
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs54
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs10
3 files changed, 57 insertions, 15 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 956c2c9..9550b5a 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -2788,7 +2788,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2788 Transfer.TransferInfo.Size = req.AssetInf.Data.Length; 2788 Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
2789 Transfer.TransferInfo.TransferID = req.TransferRequestID; 2789 Transfer.TransferInfo.TransferID = req.TransferRequestID;
2790 Transfer.Header.Zerocoded = true; 2790 Transfer.Header.Zerocoded = true;
2791 OutPacket(Transfer, isWearable ? ThrottleOutPacketType.Task : ThrottleOutPacketType.Asset); 2791 OutPacket(Transfer, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2792 2792
2793 if (req.NumPackets == 1) 2793 if (req.NumPackets == 1)
2794 { 2794 {
@@ -2799,7 +2799,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2799 TransferPacket.TransferData.Data = req.AssetInf.Data; 2799 TransferPacket.TransferData.Data = req.AssetInf.Data;
2800 TransferPacket.TransferData.Status = 1; 2800 TransferPacket.TransferData.Status = 1;
2801 TransferPacket.Header.Zerocoded = true; 2801 TransferPacket.Header.Zerocoded = true;
2802 OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task : ThrottleOutPacketType.Asset); 2802 OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2803 } 2803 }
2804 else 2804 else
2805 { 2805 {
@@ -2832,7 +2832,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2832 TransferPacket.TransferData.Status = 1; 2832 TransferPacket.TransferData.Status = 1;
2833 } 2833 }
2834 TransferPacket.Header.Zerocoded = true; 2834 TransferPacket.Header.Zerocoded = true;
2835 OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task : ThrottleOutPacketType.Asset); 2835 OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2836 2836
2837 processedLength += chunkSize; 2837 processedLength += chunkSize;
2838 packetNumber++; 2838 packetNumber++;
@@ -3605,7 +3605,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3605 } 3605 }
3606 } 3606 }
3607 3607
3608 OutPacket(aw, ThrottleOutPacketType.Task); 3608 OutPacket(aw, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3609 } 3609 }
3610 3610
3611 public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) 3611 public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
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}
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 9a4abd4..6c72edc 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -803,6 +803,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
803 803
804 #region Queue or Send 804 #region Queue or Send
805 805
806 bool highPriority = false;
807
808 if (category != ThrottleOutPacketType.Unknown && (category & ThrottleOutPacketType.HighPriority) != 0)
809 {
810 category = (ThrottleOutPacketType)((int)category & 127);
811 highPriority = true;
812 }
813
806 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category, null); 814 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category, null);
807 // If we were not provided a method for handling unacked, use the UDPServer default method 815 // If we were not provided a method for handling unacked, use the UDPServer default method
808 outgoingPacket.UnackedMethod = ((method == null) ? delegate(OutgoingPacket oPacket) { ResendUnacked(oPacket); } : method); 816 outgoingPacket.UnackedMethod = ((method == null) ? delegate(OutgoingPacket oPacket) { ResendUnacked(oPacket); } : method);
@@ -811,7 +819,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
811 // continue to display the deleted object until relog. Therefore, we need to always queue a kill object 819 // continue to display the deleted object until relog. Therefore, we need to always queue a kill object
812 // packet so that it isn't sent before a queued update packet. 820 // packet so that it isn't sent before a queued update packet.
813 bool requestQueue = type == PacketType.KillObject; 821 bool requestQueue = type == PacketType.KillObject;
814 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue)) 822 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue, highPriority))
815 SendPacketFinal(outgoingPacket); 823 SendPacketFinal(outgoingPacket);
816 824
817 #endregion Queue or Send 825 #endregion Queue or Send