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/Environment/Modules/XferModule.cs | 38 ++++++++++++++++++----
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 7 +++-
2 files changed, 37 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Environment')
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