a few more changes to lludp Xfer download

0.9.1.0-post-fixes
UbitUmarov 2019-06-11 01:19:57 +01:00
parent 017253fae9
commit 238efad690
1 changed files with 22 additions and 15 deletions

View File

@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
if(!inTimeTick) if(!inTimeTick)
{ {
double now = Util.GetTimeStampMS(); double now = Util.GetTimeStampMS();
if(now - lastTimeTick > 1750.0) if(now - lastTimeTick > 500.0)
{ {
if(Transfers.Count == 0 && NewFiles.Count == 0) if(Transfers.Count == 0 && NewFiles.Count == 0)
@ -233,6 +233,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
public void transfersTimeTick(double now) public void transfersTimeTick(double now)
{ {
XferDownLoad[] xfrs; XferDownLoad[] xfrs;
int inow = (int)now;
lock(Transfers) lock(Transfers)
{ {
if(Transfers.Count == 0) if(Transfers.Count == 0)
@ -243,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
} }
foreach(XferDownLoad xfr in xfrs) foreach(XferDownLoad xfr in xfrs)
{ {
if(xfr.checkTime(now)) if(xfr.checkTime(inow))
{ {
ulong xfrID = xfr.XferID; ulong xfrID = xfr.XferID;
lock(Transfers) lock(Transfers)
@ -274,7 +275,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
byte[] fileData = NewFiles[fileName].Data; byte[] fileData = NewFiles[fileName].Data;
int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10; int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10;
burstSize *= remoteClient.PingTimeMS; burstSize *= remoteClient.PingTimeMS;
burstSize >>= 9; // ping is ms, 2 round trips burstSize >>= 10; // ping is ms, 1 round trips
XferDownLoad transaction = XferDownLoad transaction =
new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize);
@ -320,14 +321,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
public class XferDownLoad public class XferDownLoad
{ {
public IClientAPI Client; public IClientAPI remoteClient;
public byte[] Data = new byte[0]; public byte[] Data = new byte[0];
public string FileName = String.Empty; public string FileName = String.Empty;
public ulong XferID = 0; public ulong XferID = 0;
public bool isDeleted = false; public bool isDeleted = false;
private object myLock = new object(); private object myLock = new object();
private double lastACKTimeMS; private int lastACKTimeMS;
private int LastPacket; private int LastPacket;
private int lastBytes; private int lastBytes;
private int lastSentPacket; private int lastSentPacket;
@ -341,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
FileName = fileName; FileName = fileName;
Data = data; Data = data;
XferID = xferID; XferID = xferID;
Client = client; remoteClient = client;
burstSize = burstsz; burstSize = burstsz;
} }
@ -397,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
private void SendBurst(double now) private void SendBurst(double now)
{ {
inBurst = true; inBurst = true;
lastACKTimeMS = now; // reset timeout lastACKTimeMS = (int)now; // reset timeout
int start = lastAckPacket + 1; int start = lastAckPacket + 1;
int end = start + burstSize; int end = start + burstSize;
if (end > LastPacket) if (end > LastPacket)
@ -425,7 +426,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
pktid = (uint)pkt; pktid = (uint)pkt;
} }
Client.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true); remoteClient.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true);
retries = 0; retries = 0;
lastSentPacket = pkt; lastSentPacket = pkt;
@ -454,7 +455,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
} }
double now = Util.GetTimeStampMS(); double now = Util.GetTimeStampMS();
lastACKTimeMS = now; lastACKTimeMS = (int)now;
retries = 0; retries = 0;
if (!inBurst) if (!inBurst)
SendPacket(lastSentPacket + 1, now); SendPacket(lastSentPacket + 1, now);
@ -462,18 +463,24 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
} }
} }
public bool checkTime(double now) public bool checkTime(int now)
{ {
if (Monitor.TryEnter(myLock)) if (Monitor.TryEnter(myLock))
{ {
if (!isDeleted && !inBurst) if (!isDeleted && !inBurst)
{ {
if (++retries >= 4) int timeMS = now - lastACKTimeMS;
done();
else int tout = 5 * remoteClient.PingTimeMS;
if(tout > 10000)
tout = 10000;
else if (tout < 500)
tout = 500;
if (timeMS > tout)
{ {
double timeMS = now - lastACKTimeMS; if (++retries >= 4)
if(timeMS > 3000.0) done();
else
{ {
burstSize >>= 2; burstSize >>= 2;
SendBurst(now); SendBurst(now);