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