make Caps IDisposable
parent
36d005e1cc
commit
22c28a0260
|
@ -50,7 +50,7 @@ namespace OpenSim.Framework.Capabilities
|
|||
/// </summary>
|
||||
public delegate IClientAPI GetClientDelegate(UUID agentID);
|
||||
|
||||
public class Caps
|
||||
public class Caps : IDisposable
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -165,6 +165,23 @@ namespace OpenSim.Framework.Capabilities
|
|||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
Flags = CapsFlags.None;
|
||||
DeregisterHandlers();
|
||||
if (m_capsActive != null)
|
||||
{
|
||||
m_capsActive.Dispose();
|
||||
m_capsActive = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a handler. This allows modules to register handlers.
|
||||
/// </summary>
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
{
|
||||
// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/");
|
||||
|
||||
caps.RegisterSimpleHandler("ObjectAdd", new SimpleOSDMapHandler("POST", "/" + UUID.Random().ToString(),
|
||||
caps.RegisterSimpleHandler("ObjectAdd", new SimpleOSDMapHandler("POST", "/" + UUID.Random(),
|
||||
delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap map)
|
||||
{
|
||||
ProcessAdd(httpRequest, httpResponse, map, agentID);
|
||||
|
|
|
@ -191,11 +191,11 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
|
||||
lock (m_capsObjects)
|
||||
{
|
||||
if (m_capsObjects.ContainsKey(circuitCode))
|
||||
if (m_capsObjects.TryGetValue(circuitCode, out Caps cp))
|
||||
{
|
||||
m_capsObjects[circuitCode].DeregisterHandlers();
|
||||
m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[circuitCode]);
|
||||
m_scene.EventManager.TriggerOnDeregisterCaps(agentId, cp);
|
||||
m_capsObjects.Remove(circuitCode);
|
||||
cp.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -203,9 +203,9 @@ namespace OpenSim.Region.CoreModules.Framework
|
|||
{
|
||||
if (kvp.Value.AgentID == agentId)
|
||||
{
|
||||
kvp.Value.DeregisterHandlers();
|
||||
m_scene.EventManager.TriggerOnDeregisterCaps(agentId, kvp.Value);
|
||||
m_capsObjects.Remove(kvp.Key);
|
||||
kvp.Value.Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue