aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Util.cs21
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs8
2 files changed, 29 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 10f38ab..87ba5a8 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1330,6 +1330,27 @@ namespace OpenSim.Framework
1330 m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); 1330 m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
1331 } 1331 }
1332 1332
1333 public static int FireAndForgetCount()
1334 {
1335 const int MAX_SYSTEM_THREADS = 200;
1336
1337 switch (FireAndForgetMethod)
1338 {
1339 case FireAndForgetMethod.UnsafeQueueUserWorkItem:
1340 case FireAndForgetMethod.QueueUserWorkItem:
1341 case FireAndForgetMethod.BeginInvoke:
1342 int workerThreads, iocpThreads;
1343 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
1344 return workerThreads;
1345 case FireAndForgetMethod.SmartThreadPool:
1346 return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads;
1347 case FireAndForgetMethod.Thread:
1348 return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
1349 default:
1350 throw new NotImplementedException();
1351 }
1352 }
1353
1333 public static void FireAndForget(System.Threading.WaitCallback callback, object obj) 1354 public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
1334 { 1355 {
1335 switch (FireAndForgetMethod) 1356 switch (FireAndForgetMethod)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index e3233da..74d3262 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -801,6 +801,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
801 { 801 {
802 IncomingPacket incomingPacket = null; 802 IncomingPacket incomingPacket = null;
803 803
804 // HACK: This is a test to try and rate limit packet handling on Mono.
805 // If it works, a more elegant solution can be devised
806 if (Util.FireAndForgetCount() < 2)
807 {
808 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
809 Thread.Sleep(30);
810 }
811
804 if (packetInbox.Dequeue(100, ref incomingPacket)) 812 if (packetInbox.Dequeue(100, ref incomingPacket))
805 Util.FireAndForget(ProcessInPacket, incomingPacket); 813 Util.FireAndForget(ProcessInPacket, incomingPacket);
806 } 814 }