From 7df54d4ad2b874eed0e93f13a6bdc06cccf2077e Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Oct 2009 04:52:11 +0000 Subject: Thank you, RemedyTomm, for a patch to handle Xfer requests being dropped before the file data to be transfered is ready. --- .../Region/CoreModules/Agent/Xfer/XferModule.cs | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index 834aa14..d275b7f 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -40,6 +40,12 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer private Scene m_scene; public Dictionary NewFiles = new Dictionary(); public Dictionary Transfers = new Dictionary(); + public Dictionary Requests = new Dictionary(); + public struct XferRequest + { + public IClientAPI remoteClient; + public ulong xferID; + } #region IRegionModule Members @@ -86,6 +92,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer NewFiles.Add(fileName, data); } } + + if (Requests.ContainsKey(fileName)) + { + RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName); + Requests.Remove(fileName); + } + return true; } @@ -105,7 +118,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer /// public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) { - lock (NewFiles) { if (NewFiles.ContainsKey(fileName)) @@ -114,6 +126,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { byte[] fileData = NewFiles[fileName]; XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); + Transfers.Add(xferID, transaction); NewFiles.Remove(fileName); @@ -123,6 +136,16 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer } } } + else + { + if (!Requests.ContainsKey(fileName)) + { + XferRequest nRequest = new XferRequest(); + nRequest.remoteClient = remoteClient; + nRequest.xferID = xferID; + Requests.Add(fileName, nRequest); + } + } } } @@ -177,7 +200,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); Array.Copy(Data, 0, transferData, 4, Data.Length); Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); - complete = true; } else -- cgit v1.1 From 1209db6dcd9e9d8ff15ddbdbb246506817ef9b23 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Oct 2009 15:51:28 +0000 Subject: Thank you, RemedyTomm, for an update to your previous patch. Garbage-collect the transfers that never happen. --- .../Region/CoreModules/Agent/Xfer/XferModule.cs | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index d275b7f..ef7dce8 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -38,15 +38,20 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer public class XferModule : IRegionModule, IXfer { private Scene m_scene; + private Dictionary Requests = new Dictionary(); + private List RequestTime = new List(); public Dictionary NewFiles = new Dictionary(); public Dictionary Transfers = new Dictionary(); - public Dictionary Requests = new Dictionary(); + + public struct XferRequest { public IClientAPI remoteClient; public ulong xferID; + public string fileName; + public DateTime timeStamp; } - + #region IRegionModule Members public void Initialise(Scene scene, IConfigSource config) @@ -138,13 +143,27 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer } else { + if (RequestTime.Count > 0) + { + TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); + if (ts.TotalSeconds > 30) + { + Requests.Remove(RequestTime[0].fileName); + RequestTime.RemoveAt(0); + } + } + if (!Requests.ContainsKey(fileName)) { XferRequest nRequest = new XferRequest(); nRequest.remoteClient = remoteClient; nRequest.xferID = xferID; + nRequest.fileName = fileName; + nRequest.timeStamp = DateTime.UtcNow; Requests.Add(fileName, nRequest); + RequestTime.Add(nRequest); } + } } } -- cgit v1.1