aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
diff options
context:
space:
mode:
authorMelanie2009-10-02 04:04:14 +0100
committerMelanie2009-10-02 04:04:14 +0100
commit18a744cac10c797b67236988a84ab6d13a5543b8 (patch)
tree8333647698a7933ed6def48488380c72084f8360 /OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
parentRemoving console debug spew (diff)
downloadopensim-SC_OLD-18a744cac10c797b67236988a84ab6d13a5543b8.zip
opensim-SC_OLD-18a744cac10c797b67236988a84ab6d13a5543b8.tar.gz
opensim-SC_OLD-18a744cac10c797b67236988a84ab6d13a5543b8.tar.bz2
opensim-SC_OLD-18a744cac10c797b67236988a84ab6d13a5543b8.tar.xz
Change texture sending to be driven by the queue empty event from the
packet queue, rather than a timer
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs64
1 files changed, 30 insertions, 34 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
index d4d654f..8484846 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
@@ -62,6 +62,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
62 private Queue<LLQueItem> TextureOutgoingPacketQueue; 62 private Queue<LLQueItem> TextureOutgoingPacketQueue;
63 private Queue<LLQueItem> AssetOutgoingPacketQueue; 63 private Queue<LLQueItem> AssetOutgoingPacketQueue;
64 64
65 private List<ThrottleOutPacketType> Empty = new List<ThrottleOutPacketType>();
66 // m_log.Info("[THROTTLE]: Entering Throttle");
65 // private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); 67 // private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
66 // private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); 68 // private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
67 69
@@ -85,20 +87,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
85 87
86 private Dictionary<uint,int> contents = new Dictionary<uint, int>(); 88 private Dictionary<uint,int> contents = new Dictionary<uint, int>();
87 89
88 /// <summary>
89 /// The number of packets in the OutgoingPacketQueue
90 ///
91 /// </summary>
92 internal int TextureOutgoingPacketQueueCount
93 {
94 get
95 {
96 if (TextureOutgoingPacketQueue == null)
97 return 0;
98 return TextureOutgoingPacketQueue.Count;
99 }
100 }
101
102 // private long LastThrottle; 90 // private long LastThrottle;
103 // private long ThrottleInterval; 91 // private long ThrottleInterval;
104 private Timer throttleTimer; 92 private Timer throttleTimer;
@@ -212,28 +200,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
212 switch (item.throttleType & ThrottleOutPacketType.TypeMask) 200 switch (item.throttleType & ThrottleOutPacketType.TypeMask)
213 { 201 {
214 case ThrottleOutPacketType.Resend: 202 case ThrottleOutPacketType.Resend:
215 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); 203 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item, ThrottleOutPacketType.Resend);
216 break; 204 break;
217 case ThrottleOutPacketType.Texture: 205 case ThrottleOutPacketType.Texture:
218 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); 206 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item, ThrottleOutPacketType.Texture);
219 break; 207 break;
220 case ThrottleOutPacketType.Task: 208 case ThrottleOutPacketType.Task:
221 if ((item.throttleType & ThrottleOutPacketType.LowPriority) != 0) 209 if ((item.throttleType & ThrottleOutPacketType.LowPriority) != 0)
222 ThrottleCheck(ref TaskThrottle, ref TaskLowpriorityPacketQueue, item); 210 ThrottleCheck(ref TaskThrottle, ref TaskLowpriorityPacketQueue, item, ThrottleOutPacketType.Task);
223 else 211 else
224 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); 212 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item, ThrottleOutPacketType.Task);
225 break; 213 break;
226 case ThrottleOutPacketType.Land: 214 case ThrottleOutPacketType.Land:
227 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); 215 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item, ThrottleOutPacketType.Land);
228 break; 216 break;
229 case ThrottleOutPacketType.Asset: 217 case ThrottleOutPacketType.Asset:
230 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); 218 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item, ThrottleOutPacketType.Asset);
231 break; 219 break;
232 case ThrottleOutPacketType.Cloud: 220 case ThrottleOutPacketType.Cloud:
233 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); 221 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item, ThrottleOutPacketType.Cloud);
234 break; 222 break;
235 case ThrottleOutPacketType.Wind: 223 case ThrottleOutPacketType.Wind:
236 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); 224 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item, ThrottleOutPacketType.Wind);
237 break; 225 break;
238 226
239 default: 227 default:
@@ -408,6 +396,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
408 396
409 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. 397 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once.
410 int throttleLoops = 0; 398 int throttleLoops = 0;
399 List<ThrottleOutPacketType> e;
411 400
412 // We're going to dequeue all of the saved up packets until 401 // We're going to dequeue all of the saved up packets until
413 // we've hit the throttle limit or there's no more packets to send 402 // we've hit the throttle limit or there's no more packets to send
@@ -420,8 +409,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
420 409
421 ResetCounters(); 410 ResetCounters();
422 411
423 List<ThrottleOutPacketType> Empty = new List<ThrottleOutPacketType>();
424 // m_log.Info("[THROTTLE]: Entering Throttle");
425 while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) 412 while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops)
426 { 413 {
427 qchanged = false; // We will break out of the loop if no work was accomplished 414 qchanged = false; // We will break out of the loop if no work was accomplished
@@ -448,7 +435,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
448 LandThrottle.AddBytes(qpack.Length); 435 LandThrottle.AddBytes(qpack.Length);
449 qchanged = true; 436 qchanged = true;
450 437
451 if (LandOutgoingPacketQueue.Count == 0) 438 if (LandOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Land))
452 Empty.Add(ThrottleOutPacketType.Land); 439 Empty.Add(ThrottleOutPacketType.Land);
453 } 440 }
454 441
@@ -461,7 +448,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
461 WindThrottle.AddBytes(qpack.Length); 448 WindThrottle.AddBytes(qpack.Length);
462 qchanged = true; 449 qchanged = true;
463 450
464 if (WindOutgoingPacketQueue.Count == 0) 451 if (WindOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Wind))
465 Empty.Add(ThrottleOutPacketType.Wind); 452 Empty.Add(ThrottleOutPacketType.Wind);
466 } 453 }
467 454
@@ -474,7 +461,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
474 CloudThrottle.AddBytes(qpack.Length); 461 CloudThrottle.AddBytes(qpack.Length);
475 qchanged = true; 462 qchanged = true;
476 463
477 if (CloudOutgoingPacketQueue.Count == 0) 464 if (CloudOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Cloud))
478 Empty.Add(ThrottleOutPacketType.Cloud); 465 Empty.Add(ThrottleOutPacketType.Cloud);
479 } 466 }
480 467
@@ -496,7 +483,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
496 TaskThrottle.AddBytes(qpack.Length); 483 TaskThrottle.AddBytes(qpack.Length);
497 qchanged = true; 484 qchanged = true;
498 485
499 if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0) 486 if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Task))
500 Empty.Add(ThrottleOutPacketType.Task); 487 Empty.Add(ThrottleOutPacketType.Task);
501 } 488 }
502 489
@@ -509,7 +496,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
509 TextureThrottle.AddBytes(qpack.Length); 496 TextureThrottle.AddBytes(qpack.Length);
510 qchanged = true; 497 qchanged = true;
511 498
512 if (TextureOutgoingPacketQueue.Count == 0) 499 if (TextureOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Texture))
513 Empty.Add(ThrottleOutPacketType.Texture); 500 Empty.Add(ThrottleOutPacketType.Texture);
514 } 501 }
515 502
@@ -522,16 +509,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
522 AssetThrottle.AddBytes(qpack.Length); 509 AssetThrottle.AddBytes(qpack.Length);
523 qchanged = true; 510 qchanged = true;
524 511
525 if (AssetOutgoingPacketQueue.Count == 0) 512 if (AssetOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Asset))
526 Empty.Add(ThrottleOutPacketType.Asset); 513 Empty.Add(ThrottleOutPacketType.Asset);
527 } 514 }
528 } 515 }
529 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); 516 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets");
530 517
531 foreach (ThrottleOutPacketType t in Empty) 518 e = new List<ThrottleOutPacketType>(Empty);
532 { 519 Empty.Clear();
520 }
521
522 foreach (ThrottleOutPacketType t in e)
523 {
524 if (GetQueueCount(t) == 0)
533 TriggerOnQueueEmpty(t); 525 TriggerOnQueueEmpty(t);
534 }
535 } 526 }
536 } 527 }
537 528
@@ -552,7 +543,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
552 ProcessThrottle(); 543 ProcessThrottle();
553 } 544 }
554 545
555 private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue<LLQueItem> q, LLQueItem item) 546 private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue<LLQueItem> q, LLQueItem item, ThrottleOutPacketType itemType)
556 { 547 {
557 // The idea.. is if the packet throttle queues are empty 548 // The idea.. is if the packet throttle queues are empty
558 // and the client is under throttle for the type. Queue 549 // and the client is under throttle for the type. Queue
@@ -568,6 +559,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
568 throttle.AddBytes(item.Length); 559 throttle.AddBytes(item.Length);
569 TotalThrottle.AddBytes(item.Length); 560 TotalThrottle.AddBytes(item.Length);
570 SendQueue.Enqueue(item); 561 SendQueue.Enqueue(item);
562 lock (this)
563 {
564 if (!Empty.Contains(itemType))
565 Empty.Add(itemType);
566 }
571 } 567 }
572 catch (Exception e) 568 catch (Exception e)
573 { 569 {