aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs33
1 files changed, 8 insertions, 25 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index ca9925c..458e78d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -202,7 +202,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
202 public void Shutdown() 202 public void Shutdown()
203 { 203 {
204 IsConnected = false; 204 IsConnected = false;
205 NeedAcks.Clear();
206 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) 205 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++)
207 { 206 {
208 m_packetOutboxes[i].Clear(); 207 m_packetOutboxes[i].Clear();
@@ -394,7 +393,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
394 { 393 {
395 // Not enough tokens in the bucket, queue this packet 394 // Not enough tokens in the bucket, queue this packet
396 queue.Enqueue(packet); 395 queue.Enqueue(packet);
397 m_udpServer.SignalOutgoingPacketHandler();
398 return true; 396 return true;
399 } 397 }
400 } 398 }
@@ -411,15 +409,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
411 /// </summary> 409 /// </summary>
412 /// <remarks>This function is only called from a synchronous loop in the 410 /// <remarks>This function is only called from a synchronous loop in the
413 /// UDPServer so we don't need to bother making this thread safe</remarks> 411 /// UDPServer so we don't need to bother making this thread safe</remarks>
414 /// <returns>The minimum amount of time before the next packet 412 /// <returns>True if any packets were sent, otherwise false</returns>
415 /// can be sent to this client</returns> 413 public bool DequeueOutgoing()
416 public int DequeueOutgoing()
417 { 414 {
418 OutgoingPacket packet; 415 OutgoingPacket packet;
419 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue; 416 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue;
420 TokenBucket bucket; 417 TokenBucket bucket;
421 int dataLength; 418 bool packetSent = false;
422 int minTimeout = Int32.MaxValue;
423 419
424 //string queueDebugOutput = String.Empty; // Serious debug business 420 //string queueDebugOutput = String.Empty; // Serious debug business
425 421
@@ -434,18 +430,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
434 // leaving a dequeued packet still waiting to be sent out. Try to 430 // leaving a dequeued packet still waiting to be sent out. Try to
435 // send it again 431 // send it again
436 OutgoingPacket nextPacket = m_nextPackets[i]; 432 OutgoingPacket nextPacket = m_nextPackets[i];
437 dataLength = nextPacket.Buffer.DataLength; 433 if (bucket.RemoveTokens(nextPacket.Buffer.DataLength))
438 if (bucket.RemoveTokens(dataLength))
439 { 434 {
440 // Send the packet 435 // Send the packet
441 m_udpServer.SendPacketFinal(nextPacket); 436 m_udpServer.SendPacketFinal(nextPacket);
442 m_nextPackets[i] = null; 437 m_nextPackets[i] = null;
443 minTimeout = 0; 438 packetSent = true;
444 }
445 else if (minTimeout != 0)
446 {
447 // Check the minimum amount of time we would have to wait before this packet can be sent out
448 minTimeout = Math.Min(minTimeout, ((dataLength - bucket.Content) / bucket.DripPerMS) + 1);
449 } 439 }
450 } 440 }
451 else 441 else
@@ -457,23 +447,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
457 { 447 {
458 // A packet was pulled off the queue. See if we have 448 // A packet was pulled off the queue. See if we have
459 // enough tokens in the bucket to send it out 449 // enough tokens in the bucket to send it out
460 dataLength = packet.Buffer.DataLength; 450 if (bucket.RemoveTokens(packet.Buffer.DataLength))
461 if (bucket.RemoveTokens(dataLength))
462 { 451 {
463 // Send the packet 452 // Send the packet
464 m_udpServer.SendPacketFinal(packet); 453 m_udpServer.SendPacketFinal(packet);
465 minTimeout = 0; 454 packetSent = true;
466 } 455 }
467 else 456 else
468 { 457 {
469 // Save the dequeued packet for the next iteration 458 // Save the dequeued packet for the next iteration
470 m_nextPackets[i] = packet; 459 m_nextPackets[i] = packet;
471
472 if (minTimeout != 0)
473 {
474 // Check the minimum amount of time we would have to wait before this packet can be sent out
475 minTimeout = Math.Min(minTimeout, ((dataLength - bucket.Content) / bucket.DripPerMS) + 1);
476 }
477 } 460 }
478 461
479 // If the queue is empty after this dequeue, fire the queue 462 // If the queue is empty after this dequeue, fire the queue
@@ -492,7 +475,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
492 } 475 }
493 476
494 //m_log.Info("[LLUDPCLIENT]: Queues: " + queueDebugOutput); // Serious debug business 477 //m_log.Info("[LLUDPCLIENT]: Queues: " + queueDebugOutput); // Serious debug business
495 return minTimeout; 478 return packetSent;
496 } 479 }
497 480
498 /// <summary> 481 /// <summary>