aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-22 12:33:23 -0700
committerJohn Hurliman2009-10-22 12:33:23 -0700
commitb2ed348aa2746fbf034b713d006e40366c479d5a (patch)
tree26c114e88f54e64e1fdf17dcc7de1e54165db2bc /OpenSim/Region/CoreModules
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.zip
opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.gz
opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.bz2
opensim-SC_OLD-b2ed348aa2746fbf034b713d006e40366c479d5a.tar.xz
Implemented a Watchdog class. Do not manually create Thread objects anymore, use Watchdog.StartThread(). While your thread is running call Watchdog.UpdateThread(). When it is shutting down call Watchdog.RemoveThread(). Most of the threads in OpenSim have been updated
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs13
3 files changed, 19 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index d636b1c..62500a2 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -1208,10 +1208,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
1208 if (homeScene.TryGetAvatar(avatarId,out avatar)) 1208 if (homeScene.TryGetAvatar(avatarId,out avatar))
1209 { 1209 {
1210 KillAUser ku = new KillAUser(avatar,mod); 1210 KillAUser ku = new KillAUser(avatar,mod);
1211 Thread ta = new Thread(ku.ShutdownNoLogout); 1211 Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true);
1212 ta.IsBackground = true;
1213 ta.Name = "ShutdownThread";
1214 ta.Start();
1215 } 1212 }
1216 } 1213 }
1217 1214
@@ -1261,7 +1258,13 @@ namespace OpenSim.Region.CoreModules.InterGrid
1261 1258
1262 avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false; 1259 avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false;
1263 1260
1264 Thread.Sleep(30000); 1261 int sleepMS = 30000;
1262 while (sleepMS > 0)
1263 {
1264 Watchdog.UpdateThread();
1265 Thread.Sleep(1000);
1266 sleepMS -= 1000;
1267 }
1265 1268
1266 // test for child agent because they might have come back 1269 // test for child agent because they might have come back
1267 if (avToBeKilled.IsChildAgent) 1270 if (avToBeKilled.IsChildAgent)
@@ -1270,6 +1273,8 @@ namespace OpenSim.Region.CoreModules.InterGrid
1270 avToBeKilled.ControllingClient.Close(); 1273 avToBeKilled.ControllingClient.Close();
1271 } 1274 }
1272 } 1275 }
1276
1277 Watchdog.RemoveThread();
1273 } 1278 }
1274 1279
1275 } 1280 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index fe9c8d9..c9fce91 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
128 if (m_repliesRequired == 0) 128 if (m_repliesRequired == 0)
129 { 129 {
130 m_requestState = RequestState.Completed; 130 m_requestState = RequestState.Completed;
131 PerformAssetsRequestCallback(); 131 PerformAssetsRequestCallback(null);
132 return; 132 return;
133 } 133 }
134 134
@@ -246,9 +246,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
246 246
247 // We want to stop using the asset cache thread asap 247 // We want to stop using the asset cache thread asap
248 // as we now need to do the work of producing the rest of the archive 248 // as we now need to do the work of producing the rest of the archive
249 Thread newThread = new Thread(PerformAssetsRequestCallback); 249 Util.FireAndForget(PerformAssetsRequestCallback);
250 newThread.Name = "OpenSimulator archiving thread post assets receipt";
251 newThread.Start();
252 } 250 }
253 else 251 else
254 { 252 {
@@ -265,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
265 /// <summary> 263 /// <summary>
266 /// Perform the callback on the original requester of the assets 264 /// Perform the callback on the original requester of the assets
267 /// </summary> 265 /// </summary>
268 protected void PerformAssetsRequestCallback() 266 protected void PerformAssetsRequestCallback(object o)
269 { 267 {
270 try 268 try
271 { 269 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 4e40084..a4bcbad 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -74,7 +74,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
74 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); 74 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>();
75 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); 75 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>();
76 private List<UUID> m_rootAgents = new List<UUID>(); 76 private List<UUID> m_rootAgents = new List<UUID>();
77 private Thread mapItemReqThread;
78 private volatile bool threadrunning = false; 77 private volatile bool threadrunning = false;
79 78
80 //private int CacheRegionsDistance = 256; 79 //private int CacheRegionsDistance = 256;
@@ -338,13 +337,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
338 { 337 {
339 if (threadrunning) return; 338 if (threadrunning) return;
340 threadrunning = true; 339 threadrunning = true;
340
341 m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); 341 m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
342 mapItemReqThread = new Thread(new ThreadStart(process)); 342
343 mapItemReqThread.IsBackground = true; 343 Watchdog.StartThread(process, "MapItemRequestThread", ThreadPriority.BelowNormal, true);
344 mapItemReqThread.Name = "MapItemRequestThread";
345 mapItemReqThread.Priority = ThreadPriority.BelowNormal;
346 mapItemReqThread.SetApartmentState(ApartmentState.MTA);
347 mapItemReqThread.Start();
348 } 344 }
349 345
350 /// <summary> 346 /// <summary>
@@ -461,6 +457,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
461 OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); 457 OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
462 RequestMapItemsCompleted(response); 458 RequestMapItemsCompleted(response);
463 } 459 }
460
461 Watchdog.UpdateThread();
464 } 462 }
465 } 463 }
466 catch (Exception e) 464 catch (Exception e)
@@ -469,6 +467,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
469 } 467 }
470 468
471 threadrunning = false; 469 threadrunning = false;
470 Watchdog.RemoveThread();
472 } 471 }
473 472
474 /// <summary> 473 /// <summary>