aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs67
1 files changed, 49 insertions, 18 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index 621e0fd..f1a1812 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
@@ -158,6 +158,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
158 158
159 private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC 159 private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC
160 private int m_maxRTO = 60000; 160 private int m_maxRTO = 60000;
161 public bool m_deliverPackets = true;
161 162
162 /// <summary> 163 /// <summary>
163 /// Default constructor 164 /// Default constructor
@@ -434,6 +435,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
434 if (category >= 0 && category < m_packetOutboxes.Length) 435 if (category >= 0 && category < m_packetOutboxes.Length)
435 { 436 {
436 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 437 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
438
439 if (m_deliverPackets == false)
440 {
441 queue.Enqueue(packet);
442 return true;
443 }
444
437 TokenBucket bucket = m_throttleCategories[category]; 445 TokenBucket bucket = m_throttleCategories[category];
438 446
439 // Don't send this packet if there is already a packet waiting in the queue 447 // Don't send this packet if there is already a packet waiting in the queue
@@ -483,7 +491,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
483 /// <returns>True if any packets were sent, otherwise false</returns> 491 /// <returns>True if any packets were sent, otherwise false</returns>
484 public bool DequeueOutgoing() 492 public bool DequeueOutgoing()
485 { 493 {
486 OutgoingPacket packet; 494 if (m_deliverPackets == false) return false;
495
496 OutgoingPacket packet = null;
487 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue; 497 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue;
488 TokenBucket bucket; 498 TokenBucket bucket;
489 bool packetSent = false; 499 bool packetSent = false;
@@ -515,32 +525,49 @@ namespace OpenSim.Region.ClientStack.LindenUDP
515 // No dequeued packet waiting to be sent, try to pull one off 525 // No dequeued packet waiting to be sent, try to pull one off
516 // this queue 526 // this queue
517 queue = m_packetOutboxes[i]; 527 queue = m_packetOutboxes[i];
518 if (queue.Dequeue(out packet)) 528 if (queue != null)
519 { 529 {
520 // A packet was pulled off the queue. See if we have 530 bool success = false;
521 // enough tokens in the bucket to send it out 531 try
522 if (bucket.RemoveTokens(packet.Buffer.DataLength))
523 { 532 {
524 // Send the packet 533 success = queue.Dequeue(out packet);
525 m_udpServer.SendPacketFinal(packet);
526 packetSent = true;
527 } 534 }
528 else 535 catch
529 { 536 {
530 // Save the dequeued packet for the next iteration 537 m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>();
531 m_nextPackets[i] = packet;
532 } 538 }
533 539 if (success)
534 // If the queue is empty after this dequeue, fire the queue 540 {
535 // empty callback now so it has a chance to fill before we 541 // A packet was pulled off the queue. See if we have
536 // get back here 542 // enough tokens in the bucket to send it out
537 if (queue.Count == 0) 543 if (bucket.RemoveTokens(packet.Buffer.DataLength))
544 {
545 // Send the packet
546 m_udpServer.SendPacketFinal(packet);
547 packetSent = true;
548 }
549 else
550 {
551 // Save the dequeued packet for the next iteration
552 m_nextPackets[i] = packet;
553 }
554
555 // If the queue is empty after this dequeue, fire the queue
556 // empty callback now so it has a chance to fill before we
557 // get back here
558 if (queue.Count == 0)
559 emptyCategories |= CategoryToFlag(i);
560 }
561 else
562 {
563 // No packets in this queue. Fire the queue empty callback
564 // if it has not been called recently
538 emptyCategories |= CategoryToFlag(i); 565 emptyCategories |= CategoryToFlag(i);
566 }
539 } 567 }
540 else 568 else
541 { 569 {
542 // No packets in this queue. Fire the queue empty callback 570 m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue<OutgoingPacket>();
543 // if it has not been called recently
544 emptyCategories |= CategoryToFlag(i); 571 emptyCategories |= CategoryToFlag(i);
545 } 572 }
546 } 573 }
@@ -649,6 +676,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
649 if (m_nextOnQueueEmpty == 0) 676 if (m_nextOnQueueEmpty == 0)
650 m_nextOnQueueEmpty = 1; 677 m_nextOnQueueEmpty = 1;
651 } 678 }
679 internal void ForceThrottleSetting(int throttle, int setting)
680 {
681 m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); ;
682 }
652 683
653 /// <summary> 684 /// <summary>
654 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a 685 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a