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.cs11
1 files changed, 7 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 71f4c47..2d86a40 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -531,11 +531,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
531 /// as an object to match the WaitCallback delegate signature</param> 531 /// as an object to match the WaitCallback delegate signature</param>
532 private void FireQueueEmpty(object o) 532 private void FireQueueEmpty(object o)
533 { 533 {
534 const int MIN_CALLBACK_MS = 30;
535
534 int i = (int)o; 536 int i = (int)o;
535 ThrottleOutPacketType type = (ThrottleOutPacketType)i; 537 ThrottleOutPacketType type = (ThrottleOutPacketType)i;
536 QueueEmpty callback = OnQueueEmpty; 538 QueueEmpty callback = OnQueueEmpty;
537 539
538 int start = Environment.TickCount; 540 int start = Environment.TickCount & Int32.MaxValue;
539 541
540 if (callback != null) 542 if (callback != null)
541 { 543 {
@@ -543,10 +545,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
543 catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); } 545 catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); }
544 } 546 }
545 547
546 // Make sure all queue empty calls take at least a measurable amount of time, 548 // Make sure all queue empty calls take at least some amount of time,
547 // otherwise we'll peg a CPU trying to fire these too fast 549 // otherwise we'll peg a CPU trying to fire these too fast
548 if (Environment.TickCount == start) 550 int elapsedMS = (Environment.TickCount & Int32.MaxValue) - start;
549 System.Threading.Thread.Sleep((int)m_udpServer.TickCountResolution); 551 if (elapsedMS < MIN_CALLBACK_MS)
552 System.Threading.Thread.Sleep(MIN_CALLBACK_MS - elapsedMS);
550 553
551 m_onQueueEmptyRunning[i] = false; 554 m_onQueueEmptyRunning[i] = false;
552 } 555 }