From 548bbc97e5d6e2ffaa3068aa0847eaa6c401345d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 6 Feb 2008 20:34:18 +0000
Subject: * Chasing down memory leak where memory used by a client is not
returned on client logout * This code may or may not be on the right track,
but I want to save my work so far.
---
OpenSim/Region/ClientStack/ClientView.cs | 5 +++
OpenSim/Region/ClientStack/PacketServer.cs | 8 ++++-
OpenSim/Region/Environment/Modules/XferModule.cs | 38 ++++++++++++++++++----
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 7 +++-
4 files changed, 49 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 10bf0d1..aeac1b2 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -51,6 +51,11 @@ namespace OpenSim.Region.ClientStack
///
public class ClientView : IClientAPI
{
+ ~ClientView()
+ {
+ m_log.Info("[CLIENTVIEW]: Dstructor called");
+ }
+
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/* static variables */
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index 7e01adf..9608ce5 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -36,6 +36,9 @@ namespace OpenSim.Region.ClientStack
{
public class PacketServer
{
+ private static readonly log4net.ILog m_log
+ = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+
private ClientStackNetworkHandler m_networkHandler;
private IScene m_scene;
@@ -132,8 +135,11 @@ namespace OpenSim.Region.ClientStack
public virtual void CloseClient(IClientAPI client)
{
+ //m_log.Info("PacketServer:CloseClient()");
+
CloseCircuit(client.CircuitCode);
client.Close(false);
+ m_scene.ClientManager.Remove(client.CircuitCode);
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs
index f8da9af..131e2b0 100644
--- a/OpenSim/Region/Environment/Modules/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/XferModule.cs
@@ -97,7 +97,11 @@ namespace OpenSim.Region.Environment.Modules
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
Transfers.Add(xferID, transaction);
NewFiles.Remove(fileName);
- transaction.StartSend();
+
+ if (transaction.StartSend())
+ {
+ Transfers.Remove(xferID);
+ }
}
}
}
@@ -107,7 +111,12 @@ namespace OpenSim.Region.Environment.Modules
{
if (Transfers.ContainsKey(xferID))
{
- Transfers[xferID].AckPacket(packet);
+ if (Transfers[xferID].AckPacket(packet))
+ {
+ {
+ Transfers.Remove(xferID);
+ }
+ }
}
}
@@ -137,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules
public uint Packet = 0;
public IClientAPI Client;
public uint Serial = 1;
- private bool complete = false;
+ private bool complete;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{
@@ -151,7 +160,11 @@ namespace OpenSim.Region.Environment.Modules
{
}
- public void StartSend()
+ ///
+ /// Start a transfer
+ ///
+ /// True if the transfer is complete, false if not
+ public bool StartSend()
{
if (Data.Length < 1000)
{
@@ -160,6 +173,7 @@ namespace OpenSim.Region.Environment.Modules
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, Data.Length);
Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
+
complete = true;
}
else
@@ -169,11 +183,18 @@ namespace OpenSim.Region.Environment.Modules
Array.Copy(Data, 0, transferData, 4, 1000);
Client.SendXferPacket(XferID, 0, transferData);
Packet++;
- DataPointer = 1000;
+ DataPointer = 1000;
}
+
+ return complete;
}
- public void AckPacket(uint packet)
+ ///
+ /// Respond to an ack packet from the client
+ ///
+ ///
+ /// True if the transfer is complete, false otherwise
+ public bool AckPacket(uint packet)
{
if (!complete)
{
@@ -193,10 +214,13 @@ namespace OpenSim.Region.Environment.Modules
Client.SendXferPacket(XferID, endPacket, transferData);
Packet++;
DataPointer += (Data.Length - DataPointer);
+
complete = true;
}
}
+
+ return complete;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 109f23c..4062ef6 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -39,6 +39,11 @@ namespace OpenSim.Region.Environment.Scenes
{
public class ScenePresence : EntityBase
{
+ ~ScenePresence()
+ {
+ m_log.Info("[ScenePresence] Destructor called");
+ }
+
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static AvatarAnimations Animations = new AvatarAnimations();
@@ -1728,4 +1733,4 @@ namespace OpenSim.Region.Environment.Scenes
RemoveFromPhysicalScene();
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1