aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie Thielker2008-12-17 21:00:18 +0000
committerMelanie Thielker2008-12-17 21:00:18 +0000
commita9e38bcafcb14700fd707a74311f0e7588791014 (patch)
treeee5a95b2ad712af9b1f6ef1896fedef702cdcc37 /OpenSim/Region
parent* minor: Comment out "Informing neighbours" debug message that pops up whenev... (diff)
downloadopensim-SC_OLD-a9e38bcafcb14700fd707a74311f0e7588791014.zip
opensim-SC_OLD-a9e38bcafcb14700fd707a74311f0e7588791014.tar.gz
opensim-SC_OLD-a9e38bcafcb14700fd707a74311f0e7588791014.tar.bz2
opensim-SC_OLD-a9e38bcafcb14700fd707a74311f0e7588791014.tar.xz
Reapply the packet optimization patch, with changes
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs58
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs39
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs2
3 files changed, 42 insertions, 57 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index 5f26469..89f3339 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
@@ -99,26 +99,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
99 // 99 //
100 private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>(); 100 private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>();
101 101
102 // Dictionary of the packets that need acks from the client. 102 private Dictionary<uint, LLQueItem> m_NeedAck =
103 // 103 new Dictionary<uint, LLQueItem>();
104 private class AckData
105 {
106 public AckData(Packet packet, Object identifier, int tickCount, int resends)
107 {
108 Packet = packet;
109 Identifier = identifier;
110 TickCount = tickCount;
111 Resends = resends;
112 }
113
114 public Packet Packet;
115 public Object Identifier;
116 public int TickCount;
117 public int Resends;
118 }
119
120 private Dictionary<uint, AckData> m_NeedAck =
121 new Dictionary<uint, AckData>();
122 104
123 /// <summary> 105 /// <summary>
124 /// The number of milliseconds that can pass before a packet that needs an ack is resent. 106 /// The number of milliseconds that can pass before a packet that needs an ack is resent.
@@ -314,6 +296,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
314 item.throttleType = throttlePacketType; 296 item.throttleType = throttlePacketType;
315 item.TickCount = System.Environment.TickCount; 297 item.TickCount = System.Environment.TickCount;
316 item.Identifier = id; 298 item.Identifier = id;
299 item.Resends = 0;
300 item.Length = packet.ToBytes().Length;
317 301
318 m_PacketQueue.Enqueue(item); 302 m_PacketQueue.Enqueue(item);
319 m_PacketsSent++; 303 m_PacketsSent++;
@@ -333,7 +317,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
333 if (m_DropSafeTimeout > now || 317 if (m_DropSafeTimeout > now ||
334 intervalMs > 500) // We were frozen! 318 intervalMs > 500) // We were frozen!
335 { 319 {
336 foreach (AckData data in new List<AckData> 320 foreach (LLQueItem data in new List<LLQueItem>
337 (m_NeedAck.Values)) 321 (m_NeedAck.Values))
338 { 322 {
339 if (m_DropSafeTimeout > now) 323 if (m_DropSafeTimeout > now)
@@ -364,7 +348,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
364 348
365 int resent = 0; 349 int resent = 0;
366 350
367 foreach (AckData data in new List<AckData>(m_NeedAck.Values)) 351 foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
368 { 352 {
369 Packet packet = data.Packet; 353 Packet packet = data.Packet;
370 354
@@ -630,7 +614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
630 614
631 private void ProcessAck(uint id) 615 private void ProcessAck(uint id)
632 { 616 {
633 AckData data; 617 LLQueItem data;
634 Packet packet; 618 Packet packet;
635 619
636 lock (m_NeedAck) 620 lock (m_NeedAck)
@@ -640,11 +624,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
640 if (!m_NeedAck.TryGetValue(id, out data)) 624 if (!m_NeedAck.TryGetValue(id, out data))
641 return; 625 return;
642 626
643 packet = data.Packet;
644
645 m_NeedAck.Remove(id); 627 m_NeedAck.Remove(id);
646 m_UnackedBytes -= packet.ToBytes().Length;
647 PacketPool.Instance.ReturnPacket(data.Packet); 628 PacketPool.Instance.ReturnPacket(data.Packet);
629 m_UnackedBytes -= data.Length;
648 } 630 }
649 } 631 }
650 632
@@ -697,7 +679,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
697 public void SetClientInfo(ClientInfo info) 679 public void SetClientInfo(ClientInfo info)
698 { 680 {
699 m_PendingAcks = info.pendingAcks; 681 m_PendingAcks = info.pendingAcks;
700 m_NeedAck = new Dictionary<uint, AckData>(); 682 m_NeedAck = new Dictionary<uint, LLQueItem>();
701 683
702 Packet packet = null; 684 Packet packet = null;
703 int packetEnd = 0; 685 int packetEnd = 0;
@@ -716,7 +698,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
716 { 698 {
717 } 699 }
718 700
719 m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0)); 701 LLQueItem item = new LLQueItem();
702 item.Packet = packet;
703 item.Incoming = false;
704 item.throttleType = 0;
705 item.TickCount = System.Environment.TickCount;
706 item.Identifier = 0;
707 item.Resends = 0;
708 item.Length = packet.ToBytes().Length;
709 m_NeedAck.Add(key, item);
720 } 710 }
721 711
722 m_Sequence = info.sequence; 712 m_Sequence = info.sequence;
@@ -740,7 +730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
740 730
741 private void DropResend(Object id) 731 private void DropResend(Object id)
742 { 732 {
743 foreach (AckData data in new List<AckData>(m_NeedAck.Values)) 733 foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
744 { 734 {
745 if (data.Identifier != null && data.Identifier == id) 735 if (data.Identifier != null && data.Identifier == id)
746 { 736 {
@@ -777,12 +767,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
777 // We want to see that packet arrive if it's reliable 767 // We want to see that packet arrive if it's reliable
778 if (packet.Header.Reliable) 768 if (packet.Header.Reliable)
779 { 769 {
780 m_UnackedBytes += packet.ToBytes().Length; 770 m_UnackedBytes += item.Length;
781 771
782 // Keep track of when this packet was sent out 772 // Keep track of when this packet was sent out
783 m_NeedAck[packet.Header.Sequence] = new AckData(packet, 773 item.TickCount = System.Environment.TickCount;
784 item.Identifier, System.Environment.TickCount, 774
785 0); 775 m_NeedAck[packet.Header.Sequence] = item;
786 } 776 }
787 } 777 }
788 } 778 }
@@ -792,7 +782,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
792 Abort(); 782 Abort();
793 783
794 // Actually make the byte array and send it 784 // Actually make the byte array and send it
795 byte[] sendbuffer = packet.ToBytes(); 785 byte[] sendbuffer = item.Packet.ToBytes();
796 786
797 //m_log.DebugFormat( 787 //m_log.DebugFormat(
798 // "[CLIENT]: In {0} sending packet {1}", 788 // "[CLIENT]: In {0} sending packet {1}",
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
index 2d02dfc..4383493 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
@@ -345,9 +345,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
345 LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); 345 LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue();
346 346
347 SendQueue.Enqueue(qpack); 347 SendQueue.Enqueue(qpack);
348 int qpackSize = qpack.Packet.ToBytes().Length; 348 TotalThrottle.AddBytes(qpack.Length);
349 TotalThrottle.AddBytes(qpackSize); 349 ResendThrottle.AddBytes(qpack.Length);
350 ResendThrottle.AddBytes(qpackSize);
351 350
352 qchanged = true; 351 qchanged = true;
353 } 352 }
@@ -357,9 +356,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
357 LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); 356 LLQueItem qpack = LandOutgoingPacketQueue.Dequeue();
358 357
359 SendQueue.Enqueue(qpack); 358 SendQueue.Enqueue(qpack);
360 int qpackSize = qpack.Packet.ToBytes().Length; 359 TotalThrottle.AddBytes(qpack.Length);
361 TotalThrottle.AddBytes(qpackSize); 360 LandThrottle.AddBytes(qpack.Length);
362 LandThrottle.AddBytes(qpackSize);
363 qchanged = true; 361 qchanged = true;
364 } 362 }
365 363
@@ -368,9 +366,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
368 LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); 366 LLQueItem qpack = WindOutgoingPacketQueue.Dequeue();
369 367
370 SendQueue.Enqueue(qpack); 368 SendQueue.Enqueue(qpack);
371 int qpackSize = qpack.Packet.ToBytes().Length; 369 TotalThrottle.AddBytes(qpack.Length);
372 TotalThrottle.AddBytes(qpackSize); 370 WindThrottle.AddBytes(qpack.Length);
373 WindThrottle.AddBytes(qpackSize);
374 qchanged = true; 371 qchanged = true;
375 } 372 }
376 373
@@ -379,9 +376,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
379 LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); 376 LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue();
380 377
381 SendQueue.Enqueue(qpack); 378 SendQueue.Enqueue(qpack);
382 int qpackSize = qpack.Packet.ToBytes().Length; 379 TotalThrottle.AddBytes(qpack.Length);
383 TotalThrottle.AddBytes(qpackSize); 380 CloudThrottle.AddBytes(qpack.Length);
384 CloudThrottle.AddBytes(qpackSize);
385 qchanged = true; 381 qchanged = true;
386 } 382 }
387 383
@@ -399,9 +395,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
399 SendQueue.Enqueue(qpack); 395 SendQueue.Enqueue(qpack);
400 } 396 }
401 397
402 int qpackSize = qpack.Packet.ToBytes().Length; 398 TotalThrottle.AddBytes(qpack.Length);
403 TotalThrottle.AddBytes(qpackSize); 399 TaskThrottle.AddBytes(qpack.Length);
404 TaskThrottle.AddBytes(qpackSize);
405 qchanged = true; 400 qchanged = true;
406 } 401 }
407 402
@@ -410,9 +405,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
410 LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); 405 LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue();
411 406
412 SendQueue.Enqueue(qpack); 407 SendQueue.Enqueue(qpack);
413 int qpackSize = qpack.Packet.ToBytes().Length; 408 TotalThrottle.AddBytes(qpack.Length);
414 TotalThrottle.AddBytes(qpackSize); 409 TextureThrottle.AddBytes(qpack.Length);
415 TextureThrottle.AddBytes(qpackSize);
416 qchanged = true; 410 qchanged = true;
417 } 411 }
418 412
@@ -421,9 +415,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
421 LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); 415 LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue();
422 416
423 SendQueue.Enqueue(qpack); 417 SendQueue.Enqueue(qpack);
424 int qpackSize = qpack.Packet.ToBytes().Length; 418 TotalThrottle.AddBytes(qpack.Length);
425 TotalThrottle.AddBytes(qpackSize); 419 AssetThrottle.AddBytes(qpack.Length);
426 AssetThrottle.AddBytes(qpackSize);
427 qchanged = true; 420 qchanged = true;
428 } 421 }
429 } 422 }
@@ -451,8 +444,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
451 try 444 try
452 { 445 {
453 Monitor.Enter(this); 446 Monitor.Enter(this);
454 throttle.AddBytes(item.Packet.ToBytes().Length); 447 throttle.AddBytes(item.Length);
455 TotalThrottle.AddBytes(item.Packet.ToBytes().Length); 448 TotalThrottle.AddBytes(item.Length);
456 SendQueue.Enqueue(item); 449 SendQueue.Enqueue(item);
457 } 450 }
458 catch (Exception e) 451 catch (Exception e)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs
index 494d62b..a5dcf55 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs
@@ -42,5 +42,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
42 public ThrottleOutPacketType throttleType; 42 public ThrottleOutPacketType throttleType;
43 public int TickCount; 43 public int TickCount;
44 public Object Identifier; 44 public Object Identifier;
45 public int Resends;
46 public int Length;
45 } 47 }
46} 48}