From 97d320d7d122a5720770c77f91793ace1229a5ab Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 4 Nov 2008 20:23:18 +0000 Subject: [PATCH] * Practise some defensive programming - gracefully terminate the thread if there is a problm in the world map module rather than bringing down the whole server. --- .../Modules/World/WorldMap/WorldMapModule.cs | 48 +++++++++++-------- .../DotNetEngine/EventQueueThreadClass.cs | 4 +- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs index b6c36f8930..b277626b1a 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs @@ -390,32 +390,40 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap /// public void process() { - while (true) + try { - MapRequestState st = requests.Dequeue(); - - // end gracefully - if (st.agentID == UUID.Zero) + while (true) { - ThreadTracker.Remove(mapItemReqThread); - break; - } - - bool dorequest = true; - lock (m_rootAgents) - { - if (!m_rootAgents.Contains(st.agentID)) - dorequest = false; - } + MapRequestState st = requests.Dequeue(); + + // end gracefully + if (st.agentID == UUID.Zero) + { + ThreadTracker.Remove(mapItemReqThread); + break; + } + + bool dorequest = true; + lock (m_rootAgents) + { + if (!m_rootAgents.Contains(st.agentID)) + dorequest = false; + } - if (dorequest) - { - LLSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); - RequestMapItemsCompleted(response); + if (dorequest) + { + LLSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); + RequestMapItemsCompleted(response); + } } } + catch (Exception e) + { + m_log.ErrorFormat("[WorldMap]: Map item request thread terminated abnormally with exception {0}", e); + } + threadrunning = false; - m_log.Warn("[WorldMap]: Remote request thread exiting"); + m_log.Debug("[WorldMap]: Remote request thread exiting"); } /// diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs index 3adaf36640..b520cde376 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs @@ -17,7 +17,7 @@ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARThY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT @@ -203,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine catch (Exception e) { if (lastScriptEngine != null) - lastScriptEngine.Log.WarnFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString()); + lastScriptEngine.Log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString()); throw e; } }