From 9469c62098b00d2322ac66d61d03689792d03de7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 02:07:51 +0100 Subject: improve locking of m_agentHandlers in BaseHttpServer --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 22417b6..fd0621b 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -66,7 +66,6 @@ namespace OpenSim.Framework.Servers.HttpServer protected Dictionary m_streamHandlers = new Dictionary(); protected Dictionary m_HTTPHandlers = new Dictionary(); protected Dictionary m_agentHandlers = new Dictionary(); - protected Dictionary m_pollHandlers = new Dictionary(); @@ -247,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer return new List(m_pollHandlers.Keys); } - // Note that the agent string is provided simply to differentiate // the handlers - it is NOT required to be an actual agent header // value. @@ -268,7 +266,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetAgentHandlerKeys() { - return new List(m_agentHandlers.Keys); + lock (m_agentHandlers) + return new List(m_agentHandlers.Keys); } public bool AddLLSDHandler(string path, LLSDMethod handler) @@ -749,7 +748,8 @@ namespace OpenSim.Framework.Servers.HttpServer private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) { agentHandler = null; - try + + lock (m_agentHandlers) { foreach (IHttpAgentHandler handler in m_agentHandlers.Values) { @@ -760,9 +760,6 @@ namespace OpenSim.Framework.Servers.HttpServer } } } - catch(KeyNotFoundException) - { - } return false; } @@ -1829,10 +1826,13 @@ namespace OpenSim.Framework.Servers.HttpServer { try { - if (handler == m_agentHandlers[agent]) + lock (m_agentHandlers) { - m_agentHandlers.Remove(agent); - return true; + if (handler == m_agentHandlers[agent]) + { + m_agentHandlers.Remove(agent); + return true; + } } } catch(KeyNotFoundException) -- cgit v1.1