aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Util.cs12
-rw-r--r--OpenSim/Region/Application/OpenSim.cs7
2 files changed, 13 insertions, 6 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index d09bd6d..167e34d 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -69,8 +69,6 @@ namespace OpenSim.Framework
69 /// </summary> 69 /// </summary>
70 public class Util 70 public class Util
71 { 71 {
72 private static SmartThreadPool m_ThreadPool = null;
73
74 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 72 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
75 73
76 private static uint nextXferID = 5000; 74 private static uint nextXferID = 5000;
@@ -79,6 +77,9 @@ namespace OpenSim.Framework
79 private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; 77 private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]";
80 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; 78 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
81 private static object XferLock = new object(); 79 private static object XferLock = new object();
80 /// <summary>Thread pool used for Util.FireAndForget if
81 /// FireAndForgetMethod.SmartThreadPool is used</summary>
82 private static SmartThreadPool m_ThreadPool;
82 83
83 // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. 84 // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC.
84 private static readonly DateTime unixEpoch = 85 private static readonly DateTime unixEpoch =
@@ -1319,8 +1320,11 @@ namespace OpenSim.Framework
1319 FireAndForget(callback, null); 1320 FireAndForget(callback, null);
1320 } 1321 }
1321 1322
1322 public static void SetMaxThreads(int maxThreads) 1323 public static void InitThreadPool(int maxThreads)
1323 { 1324 {
1325 if (maxThreads < 2)
1326 throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
1327
1324 if (m_ThreadPool != null) 1328 if (m_ThreadPool != null)
1325 return; 1329 return;
1326 1330
@@ -1328,9 +1332,7 @@ namespace OpenSim.Framework
1328 startInfo.IdleTimeout = 2000; // 2 seconds 1332 startInfo.IdleTimeout = 2000; // 2 seconds
1329 startInfo.MaxWorkerThreads = maxThreads; 1333 startInfo.MaxWorkerThreads = maxThreads;
1330 startInfo.MinWorkerThreads = 2; 1334 startInfo.MinWorkerThreads = 2;
1331 startInfo.StackSize = 524288;
1332 startInfo.ThreadPriority = ThreadPriority.Normal; 1335 startInfo.ThreadPriority = ThreadPriority.Normal;
1333
1334 startInfo.StartSuspended = false; 1336 startInfo.StartSuspended = false;
1335 1337
1336 m_ThreadPool = new SmartThreadPool(startInfo); 1338 m_ThreadPool = new SmartThreadPool(startInfo);
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index c04b8c2..26298e7 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -67,7 +67,7 @@ namespace OpenSim
67 67
68 IConfig startupConfig = m_config.Source.Configs["Startup"]; 68 IConfig startupConfig = m_config.Source.Configs["Startup"];
69 69
70 Util.SetMaxThreads(startupConfig.GetInt("MaxPoolThreads", 15)); 70 int stpMaxThreads = 15;
71 71
72 if (startupConfig != null) 72 if (startupConfig != null)
73 { 73 {
@@ -100,8 +100,13 @@ namespace OpenSim
100 FireAndForgetMethod asyncCallMethod; 100 FireAndForgetMethod asyncCallMethod;
101 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) 101 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
102 Util.FireAndForgetMethod = asyncCallMethod; 102 Util.FireAndForgetMethod = asyncCallMethod;
103
104 stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15);
103 } 105 }
104 106
107 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
108 Util.InitThreadPool(stpMaxThreads);
109
105 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); 110 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
106 } 111 }
107 112