From 135b012bbd44ba04eca52fb901a93faca97cf02d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 23 Dec 2010 19:31:37 -0800 Subject: Hopefully this fixes all prim inventory issues. No more abort, no more keeping track of time. Simply handle the issues, which are: (1) rapid double requests from the viewer for the same file; (2) sometimes the file generation takes too long and the Xfer request arrives at the XferModule before the file name is added. This still has debug messages commented out, in case this needs more debugging. Pushing it so others can test. --- .../Region/CoreModules/Agent/Xfer/XferModule.cs | 84 +++++++++++++--------- 1 file changed, 49 insertions(+), 35 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index 4f9e32b..df4ff05 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -37,9 +37,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { public class XferModule : IRegionModule, IXfer { + private static uint counter = 0; private Scene m_scene; private Dictionary Requests = new Dictionary(); - private List RequestTime = new List(); private Dictionary NewFiles = new Dictionary(); private Dictionary Transfers = new Dictionary(); @@ -95,18 +95,29 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer lock (NewFiles) { if (NewFiles.ContainsKey(fileName)) + { NewFiles[fileName].Count++; + //Console.WriteLine("AddNewFile " + fileName + " counter=" + NewFiles[fileName].Count); + } else { FileData fd = new FileData(); fd.Count = 1; fd.Data = data; NewFiles.Add(fileName, fd); + //Console.WriteLine("AddNewFile " + fileName); } } + // This happens when the Xfer request ends up coming before + // the fileName is added by this method. That may happen when + // the file generation (the event that calle this method) + // takes a long time. In this case, we need to kick the + // Xfer request mannually. if (Requests.ContainsKey(fileName)) { + //Console.WriteLine("*** AddNewFile Requests.Contains " + fileName); + RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName); Requests.Remove(fileName); } @@ -133,22 +144,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { lock (NewFiles) { - if (RequestTime.Count > 0) - { - TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); - if (ts.TotalSeconds > 30) - { - ulong zxferid = RequestTime[0].xferID; - remoteClient.SendAbortXferPacket(zxferid); - RemoveXferData(zxferid); - RemoveOrDecrement(fileName); - } - } + //Console.WriteLine("---- RequestXfer " + fileName + " ----"); if (NewFiles.ContainsKey(fileName)) { + //Console.WriteLine("NewFiles.ContainsKey " + fileName + " with count=" + NewFiles[fileName].Count); if (!Transfers.ContainsKey(xferID)) { + //Console.WriteLine("!Transfers.ContainsKey("+xferID+")"); byte[] fileData = NewFiles[fileName].Data; XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); @@ -166,27 +169,38 @@ 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); - // Do we want to abort this here? - //remoteClient.SendAbortXfer(xferID); - } - } + ////Console.WriteLine("*** ! NewFiles.ContainsKey " + fileName); + //if (RequestTime.Count > 0) + //{ + // //Console.WriteLine("RequestTime.Count > 0"); + // TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); + // if (ts.TotalSeconds > 30) + // { + // Console.WriteLine("ts.TotalSeconds > 30"); + // Requests.Remove(RequestTime[0].fileName); + // RequestTime.RemoveAt(0); + // // Do we want to abort this here? + // //remoteClient.SendAbortXfer(xferID); + // } + //} + + XferRequest nRequest = new XferRequest(); + nRequest.remoteClient = remoteClient; + nRequest.xferID = xferID; + nRequest.fileName = fileName; + nRequest.timeStamp = DateTime.UtcNow; + nRequest.fileName = fileName; if (!Requests.ContainsKey(fileName)) { - XferRequest nRequest = new XferRequest(); - nRequest.remoteClient = remoteClient; - nRequest.xferID = xferID; - nRequest.fileName = fileName; - nRequest.timeStamp = DateTime.UtcNow; + //Console.WriteLine("**** !Requests.ContainsKey(" + fileName + ")"); Requests.Add(fileName, nRequest); - RequestTime.Add(nRequest); + } + else + { + //Console.WriteLine("**** Requests.ContainsKey(" + fileName + ")"); + Requests.Add(fileName + "-" + counter.ToString(), nRequest); + counter++; } } @@ -203,17 +217,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer XferDownLoad dl = Transfers[xferID]; if (Transfers[xferID].AckPacket(packet)) { - { - RemoveXferData(xferID); - RemoveOrDecrement(dl.FileName); - } + RemoveXferData(xferID); + RemoveOrDecrement(dl.FileName); } else { - if (Requests.ContainsKey(dl.FileName)) { - // XferRequest req = Requests[dl.FileName]; req.timeStamp = DateTime.UtcNow; Requests[dl.FileName] = req; @@ -262,9 +272,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer if (NewFiles.ContainsKey(fileName)) { if (NewFiles[fileName].Count == 1) + { NewFiles.Remove(fileName); + } else + { NewFiles[fileName].Count--; + } } } -- cgit v1.1