aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
diff options
context:
space:
mode:
authorteravus2013-01-16 17:52:02 -0500
committerteravus2013-01-16 17:52:02 -0500
commit670bb9cb8bb35df4787296f26224d9c89b6db9ca (patch)
tree4902d5bfbc1a632a979c38f26c8cca2ff0fb9de0 /OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
parent* Document the additional Visual Params of newer browsers in AvatarAppearance... (diff)
parentAdd a way to put things at the front of the queue for any throttle group. (diff)
downloadopensim-SC_OLD-670bb9cb8bb35df4787296f26224d9c89b6db9ca.zip
opensim-SC_OLD-670bb9cb8bb35df4787296f26224d9c89b6db9ca.tar.gz
opensim-SC_OLD-670bb9cb8bb35df4787296f26224d9c89b6db9ca.tar.bz2
opensim-SC_OLD-670bb9cb8bb35df4787296f26224d9c89b6db9ca.tar.xz
Merge remote-tracking branch 'remotes/origin/avination' into teravuswork
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs69
1 files changed, 46 insertions, 23 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index f675377..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 }
@@ -279,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
279 public string GetStats() 279 public string GetStats()
280 { 280 {
281 return string.Format( 281 return string.Format(
282 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7} {12,7}", 282 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}",
283 Util.EnvironmentTickCountSubtract(TickLastPacketReceived), 283 Util.EnvironmentTickCountSubtract(TickLastPacketReceived),
284 PacketsReceived, 284 PacketsReceived,
285 PacketsSent, 285 PacketsSent,
@@ -291,8 +291,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
291 m_packetOutboxes[(int)ThrottleOutPacketType.Cloud].Count, 291 m_packetOutboxes[(int)ThrottleOutPacketType.Cloud].Count,
292 m_packetOutboxes[(int)ThrottleOutPacketType.Task].Count, 292 m_packetOutboxes[(int)ThrottleOutPacketType.Task].Count,
293 m_packetOutboxes[(int)ThrottleOutPacketType.Texture].Count, 293 m_packetOutboxes[(int)ThrottleOutPacketType.Texture].Count,
294 m_packetOutboxes[(int)ThrottleOutPacketType.Asset].Count, 294 m_packetOutboxes[(int)ThrottleOutPacketType.Asset].Count);
295 m_packetOutboxes[(int)ThrottleOutPacketType.State].Count);
296 } 295 }
297 296
298 public void SendPacketStats() 297 public void SendPacketStats()
@@ -338,8 +337,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
338 int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; 337 int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
339 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; 338 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
340 int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); 339 int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
341 // State is a subcategory of task that we allocate a percentage to
342 int state = 0;
343 340
344 // Make sure none of the throttles are set below our packet MTU, 341 // Make sure none of the throttles are set below our packet MTU,
345 // otherwise a throttle could become permanently clogged 342 // otherwise a throttle could become permanently clogged
@@ -376,9 +373,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
376 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Task]; 373 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Task];
377 bucket.RequestedDripRate = task; 374 bucket.RequestedDripRate = task;
378 375
379 bucket = m_throttleCategories[(int)ThrottleOutPacketType.State];
380 bucket.RequestedDripRate = state;
381
382 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture]; 376 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture];
383 bucket.RequestedDripRate = texture; 377 bucket.RequestedDripRate = texture;
384 378
@@ -436,15 +430,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
436 /// </returns> 430 /// </returns>
437 public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue) 431 public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue)
438 { 432 {
433 return EnqueueOutgoing(packet, forceQueue, false);
434 }
435
436 public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue, bool highPriority)
437 {
439 int category = (int)packet.Category; 438 int category = (int)packet.Category;
440 439
441 if (category >= 0 && category < m_packetOutboxes.Length) 440 if (category >= 0 && category < m_packetOutboxes.Length)
442 { 441 {
443 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 442 DoubleLocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
444 443
445 if (m_deliverPackets == false) 444 if (m_deliverPackets == false)
446 { 445 {
447 queue.Enqueue(packet); 446 queue.Enqueue(packet, highPriority);
448 return true; 447 return true;
449 } 448 }
450 449
@@ -455,7 +454,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
455 // queued packets 454 // queued packets
456 if (queue.Count > 0) 455 if (queue.Count > 0)
457 { 456 {
458 queue.Enqueue(packet); 457 queue.Enqueue(packet, highPriority);
459 return true; 458 return true;
460 } 459 }
461 460
@@ -468,7 +467,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
468 else 467 else
469 { 468 {
470 // 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
471 queue.Enqueue(packet); 470 queue.Enqueue(packet, highPriority);
472 return true; 471 return true;
473 } 472 }
474 } 473 }
@@ -500,7 +499,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
500 if (m_deliverPackets == false) return false; 499 if (m_deliverPackets == false) return false;
501 500
502 OutgoingPacket packet = null; 501 OutgoingPacket packet = null;
503 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue; 502 DoubleLocklessQueue<OutgoingPacket> queue;
504 TokenBucket bucket; 503 TokenBucket bucket;
505 bool packetSent = false; 504 bool packetSent = false;
506 ThrottleOutPacketTypeFlags emptyCategories = 0; 505 ThrottleOutPacketTypeFlags emptyCategories = 0;
@@ -540,7 +539,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
540 } 539 }
541 catch 540 catch
542 { 541 {
543 m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); 542 m_packetOutboxes[i] = new DoubleLocklessQueue<OutgoingPacket>();
544 } 543 }
545 if (success) 544 if (success)
546 { 545 {
@@ -573,7 +572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
573 } 572 }
574 else 573 else
575 { 574 {
576 m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>(); 575 m_packetOutboxes[i] = new DoubleLocklessQueue<OutgoingPacket>();
577 emptyCategories |= CategoryToFlag(i); 576 emptyCategories |= CategoryToFlag(i);
578 } 577 }
579 } 578 }
@@ -709,9 +708,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
709 Texture = 5, 708 Texture = 5,
710 /// <summary>Non-texture assets</summary> 709 /// <summary>Non-texture assets</summary>
711 Asset = 6, 710 Asset = 6,
712 /// <summary>Avatar and primitive data</summary>
713 /// <remarks>This is a sub-category of Task</remarks>
714 State = 7,
715 */ 711 */
716 712
717 switch (category) 713 switch (category)
@@ -728,11 +724,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
728 return ThrottleOutPacketTypeFlags.Texture; 724 return ThrottleOutPacketTypeFlags.Texture;
729 case ThrottleOutPacketType.Asset: 725 case ThrottleOutPacketType.Asset:
730 return ThrottleOutPacketTypeFlags.Asset; 726 return ThrottleOutPacketTypeFlags.Asset;
731 case ThrottleOutPacketType.State:
732 return ThrottleOutPacketTypeFlags.State;
733 default: 727 default:
734 return 0; 728 return 0;
735 } 729 }
736 } 730 }
737 } 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 }
738} 761}