Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2010-12-24 02:23:26 +00:00
commit 2e3d0fb276
1 changed files with 49 additions and 35 deletions

View File

@ -37,9 +37,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
{ {
public class XferModule : IRegionModule, IXfer public class XferModule : IRegionModule, IXfer
{ {
private static uint counter = 0;
private Scene m_scene; private Scene m_scene;
private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>(); private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>();
private List<XferRequest> RequestTime = new List<XferRequest>();
private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>();
private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
@ -95,18 +95,29 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
lock (NewFiles) lock (NewFiles)
{ {
if (NewFiles.ContainsKey(fileName)) if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName].Count++; NewFiles[fileName].Count++;
//Console.WriteLine("AddNewFile " + fileName + " counter=" + NewFiles[fileName].Count);
}
else else
{ {
FileData fd = new FileData(); FileData fd = new FileData();
fd.Count = 1; fd.Count = 1;
fd.Data = data; fd.Data = data;
NewFiles.Add(fileName, fd); 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)) if (Requests.ContainsKey(fileName))
{ {
//Console.WriteLine("*** AddNewFile Requests.Contains " + fileName);
RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName); RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName);
Requests.Remove(fileName); Requests.Remove(fileName);
} }
@ -133,22 +144,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
{ {
lock (NewFiles) lock (NewFiles)
{ {
if (RequestTime.Count > 0) //Console.WriteLine("---- RequestXfer " + fileName + " ----");
{
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);
}
}
if (NewFiles.ContainsKey(fileName)) if (NewFiles.ContainsKey(fileName))
{ {
//Console.WriteLine("NewFiles.ContainsKey " + fileName + " with count=" + NewFiles[fileName].Count);
if (!Transfers.ContainsKey(xferID)) if (!Transfers.ContainsKey(xferID))
{ {
//Console.WriteLine("!Transfers.ContainsKey("+xferID+")");
byte[] fileData = NewFiles[fileName].Data; byte[] fileData = NewFiles[fileName].Data;
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
@ -166,27 +169,38 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
} }
else else
{ {
if (RequestTime.Count > 0) ////Console.WriteLine("*** ! NewFiles.ContainsKey " + fileName);
{ //if (RequestTime.Count > 0)
TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); //{
if (ts.TotalSeconds > 30) // //Console.WriteLine("RequestTime.Count > 0");
{ // TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks);
Requests.Remove(RequestTime[0].fileName); // if (ts.TotalSeconds > 30)
RequestTime.RemoveAt(0); // {
// Do we want to abort this here? // Console.WriteLine("ts.TotalSeconds > 30");
//remoteClient.SendAbortXfer(xferID); // Requests.Remove(RequestTime[0].fileName);
} // RequestTime.RemoveAt(0);
} // // Do we want to abort this here?
// //remoteClient.SendAbortXfer(xferID);
// }
//}
if (!Requests.ContainsKey(fileName))
{
XferRequest nRequest = new XferRequest(); XferRequest nRequest = new XferRequest();
nRequest.remoteClient = remoteClient; nRequest.remoteClient = remoteClient;
nRequest.xferID = xferID; nRequest.xferID = xferID;
nRequest.fileName = fileName; nRequest.fileName = fileName;
nRequest.timeStamp = DateTime.UtcNow; nRequest.timeStamp = DateTime.UtcNow;
nRequest.fileName = fileName;
if (!Requests.ContainsKey(fileName))
{
//Console.WriteLine("**** !Requests.ContainsKey(" + fileName + ")");
Requests.Add(fileName, nRequest); Requests.Add(fileName, nRequest);
RequestTime.Add(nRequest); }
else
{
//Console.WriteLine("**** Requests.ContainsKey(" + fileName + ")");
Requests.Add(fileName + "-" + counter.ToString(), nRequest);
counter++;
} }
} }
@ -202,18 +216,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
{ {
XferDownLoad dl = Transfers[xferID]; XferDownLoad dl = Transfers[xferID];
if (Transfers[xferID].AckPacket(packet)) if (Transfers[xferID].AckPacket(packet))
{
{ {
RemoveXferData(xferID); RemoveXferData(xferID);
RemoveOrDecrement(dl.FileName); RemoveOrDecrement(dl.FileName);
} }
}
else else
{ {
if (Requests.ContainsKey(dl.FileName)) if (Requests.ContainsKey(dl.FileName))
{ {
//
XferRequest req = Requests[dl.FileName]; XferRequest req = Requests[dl.FileName];
req.timeStamp = DateTime.UtcNow; req.timeStamp = DateTime.UtcNow;
Requests[dl.FileName] = req; Requests[dl.FileName] = req;
@ -262,11 +272,15 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
if (NewFiles.ContainsKey(fileName)) if (NewFiles.ContainsKey(fileName))
{ {
if (NewFiles[fileName].Count == 1) if (NewFiles[fileName].Count == 1)
{
NewFiles.Remove(fileName); NewFiles.Remove(fileName);
}
else else
{
NewFiles[fileName].Count--; NewFiles[fileName].Count--;
} }
} }
}
#region Nested type: XferDownLoad #region Nested type: XferDownLoad