diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index c5ef25a..dd37263 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
122 | if(!inTimeTick) | 122 | if(!inTimeTick) |
123 | { | 123 | { |
124 | double now = Util.GetTimeStampMS(); | 124 | double now = Util.GetTimeStampMS(); |
125 | if(now - lastTimeTick > 1750.0) | 125 | if(now - lastTimeTick > 500.0) |
126 | { | 126 | { |
127 | 127 | ||
128 | if(Transfers.Count == 0 && NewFiles.Count == 0) | 128 | if(Transfers.Count == 0 && NewFiles.Count == 0) |
@@ -233,6 +233,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
233 | public void transfersTimeTick(double now) | 233 | public void transfersTimeTick(double now) |
234 | { | 234 | { |
235 | XferDownLoad[] xfrs; | 235 | XferDownLoad[] xfrs; |
236 | int inow = (int)now; | ||
236 | lock(Transfers) | 237 | lock(Transfers) |
237 | { | 238 | { |
238 | if(Transfers.Count == 0) | 239 | if(Transfers.Count == 0) |
@@ -243,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
243 | } | 244 | } |
244 | foreach(XferDownLoad xfr in xfrs) | 245 | foreach(XferDownLoad xfr in xfrs) |
245 | { | 246 | { |
246 | if(xfr.checkTime(now)) | 247 | if(xfr.checkTime(inow)) |
247 | { | 248 | { |
248 | ulong xfrID = xfr.XferID; | 249 | ulong xfrID = xfr.XferID; |
249 | lock(Transfers) | 250 | lock(Transfers) |
@@ -274,7 +275,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
274 | byte[] fileData = NewFiles[fileName].Data; | 275 | byte[] fileData = NewFiles[fileName].Data; |
275 | int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10; | 276 | int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10; |
276 | burstSize *= remoteClient.PingTimeMS; | 277 | burstSize *= remoteClient.PingTimeMS; |
277 | burstSize >>= 9; // ping is ms, 2 round trips | 278 | burstSize >>= 10; // ping is ms, 1 round trips |
278 | XferDownLoad transaction = | 279 | XferDownLoad transaction = |
279 | new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); | 280 | new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); |
280 | 281 | ||
@@ -320,14 +321,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
320 | 321 | ||
321 | public class XferDownLoad | 322 | public class XferDownLoad |
322 | { | 323 | { |
323 | public IClientAPI Client; | 324 | public IClientAPI remoteClient; |
324 | public byte[] Data = new byte[0]; | 325 | public byte[] Data = new byte[0]; |
325 | public string FileName = String.Empty; | 326 | public string FileName = String.Empty; |
326 | public ulong XferID = 0; | 327 | public ulong XferID = 0; |
327 | public bool isDeleted = false; | 328 | public bool isDeleted = false; |
328 | 329 | ||
329 | private object myLock = new object(); | 330 | private object myLock = new object(); |
330 | private double lastACKTimeMS; | 331 | private int lastACKTimeMS; |
331 | private int LastPacket; | 332 | private int LastPacket; |
332 | private int lastBytes; | 333 | private int lastBytes; |
333 | private int lastSentPacket; | 334 | private int lastSentPacket; |
@@ -341,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
341 | FileName = fileName; | 342 | FileName = fileName; |
342 | Data = data; | 343 | Data = data; |
343 | XferID = xferID; | 344 | XferID = xferID; |
344 | Client = client; | 345 | remoteClient = client; |
345 | burstSize = burstsz; | 346 | burstSize = burstsz; |
346 | } | 347 | } |
347 | 348 | ||
@@ -397,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
397 | private void SendBurst(double now) | 398 | private void SendBurst(double now) |
398 | { | 399 | { |
399 | inBurst = true; | 400 | inBurst = true; |
400 | lastACKTimeMS = now; // reset timeout | 401 | lastACKTimeMS = (int)now; // reset timeout |
401 | int start = lastAckPacket + 1; | 402 | int start = lastAckPacket + 1; |
402 | int end = start + burstSize; | 403 | int end = start + burstSize; |
403 | if (end > LastPacket) | 404 | if (end > LastPacket) |
@@ -425,7 +426,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
425 | pktid = (uint)pkt; | 426 | pktid = (uint)pkt; |
426 | } | 427 | } |
427 | 428 | ||
428 | Client.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true); | 429 | remoteClient.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true); |
429 | 430 | ||
430 | retries = 0; | 431 | retries = 0; |
431 | lastSentPacket = pkt; | 432 | lastSentPacket = pkt; |
@@ -454,7 +455,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
454 | } | 455 | } |
455 | 456 | ||
456 | double now = Util.GetTimeStampMS(); | 457 | double now = Util.GetTimeStampMS(); |
457 | lastACKTimeMS = now; | 458 | lastACKTimeMS = (int)now; |
458 | retries = 0; | 459 | retries = 0; |
459 | if (!inBurst) | 460 | if (!inBurst) |
460 | SendPacket(lastSentPacket + 1, now); | 461 | SendPacket(lastSentPacket + 1, now); |
@@ -462,18 +463,24 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
462 | } | 463 | } |
463 | } | 464 | } |
464 | 465 | ||
465 | public bool checkTime(double now) | 466 | public bool checkTime(int now) |
466 | { | 467 | { |
467 | if (Monitor.TryEnter(myLock)) | 468 | if (Monitor.TryEnter(myLock)) |
468 | { | 469 | { |
469 | if (!isDeleted && !inBurst) | 470 | if (!isDeleted && !inBurst) |
470 | { | 471 | { |
471 | if (++retries >= 4) | 472 | int timeMS = now - lastACKTimeMS; |
472 | done(); | 473 | |
473 | else | 474 | int tout = 5 * remoteClient.PingTimeMS; |
475 | if(tout > 10000) | ||
476 | tout = 10000; | ||
477 | else if (tout < 500) | ||
478 | tout = 500; | ||
479 | if (timeMS > tout) | ||
474 | { | 480 | { |
475 | double timeMS = now - lastACKTimeMS; | 481 | if (++retries >= 4) |
476 | if(timeMS > 3000.0) | 482 | done(); |
483 | else | ||
477 | { | 484 | { |
478 | burstSize >>= 2; | 485 | burstSize >>= 2; |
479 | SendBurst(now); | 486 | SendBurst(now); |