properly lock CapsHandlers.m_capsHandlers

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-12-07 14:55:01 +00:00
parent 235147c857
commit 3ebb56734d
1 changed files with 41 additions and 27 deletions

View File

@ -51,11 +51,10 @@ namespace OpenSim.Framework.Capabilities
/// supplied BaseHttpServer. /// supplied BaseHttpServer.
/// </summary> /// </summary>
/// <param name="httpListener">base HTTP server</param> /// <param name="httpListener">base HTTP server</param>
/// <param name="httpListenerHostname">host name of the HTTP /// <param name="httpListenerHostname">host name of the HTTP server</param>
/// server</param>
/// <param name="httpListenerPort">HTTP port</param> /// <param name="httpListenerPort">HTTP port</param>
public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort)
: this (httpListener,httpListenerHostname,httpListenerPort, false) : this(httpListener,httpListenerHostname,httpListenerPort, false)
{ {
} }
@ -87,14 +86,18 @@ namespace OpenSim.Framework.Capabilities
/// <param name="capsName">name of the capability of the cap /// <param name="capsName">name of the capability of the cap
/// handler to be removed</param> /// handler to be removed</param>
public void Remove(string capsName) public void Remove(string capsName)
{
lock (m_capsHandlers)
{ {
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path);
m_capsHandlers.Remove(capsName); m_capsHandlers.Remove(capsName);
} }
}
public bool ContainsCap(string cap) public bool ContainsCap(string cap)
{ {
lock (m_capsHandlers)
return m_capsHandlers.ContainsKey(cap); return m_capsHandlers.ContainsKey(cap);
} }
@ -102,19 +105,22 @@ namespace OpenSim.Framework.Capabilities
/// The indexer allows us to treat the CapsHandlers object /// The indexer allows us to treat the CapsHandlers object
/// in an intuitive dictionary like way. /// in an intuitive dictionary like way.
/// </summary> /// </summary>
/// <Remarks> /// <remarks>
/// The indexer will throw an exception when you try to /// The indexer will throw an exception when you try to
/// retrieve a cap handler for a cap that is not contained in /// retrieve a cap handler for a cap that is not contained in
/// CapsHandlers. /// CapsHandlers.
/// </Remarks> /// </remarks>
public IRequestHandler this[string idx] public IRequestHandler this[string idx]
{ {
get get
{ {
lock (m_capsHandlers)
return m_capsHandlers[idx]; return m_capsHandlers[idx];
} }
set set
{
lock (m_capsHandlers)
{ {
if (m_capsHandlers.ContainsKey(idx)) if (m_capsHandlers.ContainsKey(idx))
{ {
@ -128,6 +134,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListener.AddStreamHandler(value); m_httpListener.AddStreamHandler(value);
} }
} }
}
/// <summary> /// <summary>
/// Return the list of cap names for which this CapsHandlers /// Return the list of cap names for which this CapsHandlers
@ -136,12 +143,15 @@ namespace OpenSim.Framework.Capabilities
public string[] Caps public string[] Caps
{ {
get get
{
lock (m_capsHandlers)
{ {
string[] __keys = new string[m_capsHandlers.Keys.Count]; string[] __keys = new string[m_capsHandlers.Keys.Count];
m_capsHandlers.Keys.CopyTo(__keys, 0); m_capsHandlers.Keys.CopyTo(__keys, 0);
return __keys; return __keys;
} }
} }
}
/// <summary> /// <summary>
/// Return an LLSD-serializable Hashtable describing the /// Return an LLSD-serializable Hashtable describing the
@ -157,6 +167,9 @@ namespace OpenSim.Framework.Capabilities
protocol = "https://"; protocol = "https://";
string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString();
lock (m_capsHandlers)
{
foreach (string capsName in m_capsHandlers.Keys) foreach (string capsName in m_capsHandlers.Keys)
{ {
if (excludeSeed && "SEED" == capsName) if (excludeSeed && "SEED" == capsName)
@ -164,6 +177,7 @@ namespace OpenSim.Framework.Capabilities
caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
} }
}
return caps; return caps;
} }