aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs42
1 files changed, 27 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index 705d7ea..c5ef25a 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -273,8 +273,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
273 { 273 {
274 byte[] fileData = NewFiles[fileName].Data; 274 byte[] fileData = NewFiles[fileName].Data;
275 int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10; 275 int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10;
276 burstSize = burstSize * (remoteClient.PingTimeMS + 50); 276 burstSize *= remoteClient.PingTimeMS;
277 burstSize /= 1000; // ping is ms 277 burstSize >>= 9; // ping is ms, 2 round trips
278 XferDownLoad transaction = 278 XferDownLoad transaction =
279 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); 279 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize);
280 280
@@ -327,12 +327,14 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
327 public bool isDeleted = false; 327 public bool isDeleted = false;
328 328
329 private object myLock = new object(); 329 private object myLock = new object();
330 private double lastsendTimeMS; 330 private double lastACKTimeMS;
331 private int LastPacket; 331 private int LastPacket;
332 private int lastBytes; 332 private int lastBytes;
333 private int lastSentPacket; 333 private int lastSentPacket;
334 private int lastAckPacket; 334 private int lastAckPacket;
335 private int burstSize; // additional packets, so can be zero 335 private int burstSize; // additional packets, so can be zero
336 private int retries;
337 private bool inBurst;
336 338
337 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client, int burstsz) 339 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client, int burstsz)
338 { 340 {
@@ -394,12 +396,15 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
394 396
395 private void SendBurst(double now) 397 private void SendBurst(double now)
396 { 398 {
399 inBurst = true;
400 lastACKTimeMS = now; // reset timeout
397 int start = lastAckPacket + 1; 401 int start = lastAckPacket + 1;
398 int end = start + burstSize; 402 int end = start + burstSize;
399 if (end > LastPacket) 403 if (end > LastPacket)
400 end = LastPacket; 404 end = LastPacket;
401 while(start <= end) 405 while (start <= end)
402 SendPacket(start++ , now); 406 SendPacket(start++ , now);
407 inBurst = false;
403 } 408 }
404 409
405 private void SendPacket(int pkt, double now) 410 private void SendPacket(int pkt, double now)
@@ -422,8 +427,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
422 427
423 Client.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true); 428 Client.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true);
424 429
430 retries = 0;
425 lastSentPacket = pkt; 431 lastSentPacket = pkt;
426 lastsendTimeMS = now;
427 } 432 }
428 433
429 /// <summary> 434 /// <summary>
@@ -447,30 +452,37 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
447 done(); 452 done();
448 return true; 453 return true;
449 } 454 }
455
450 double now = Util.GetTimeStampMS(); 456 double now = Util.GetTimeStampMS();
451 SendPacket(lastSentPacket + 1, now); 457 lastACKTimeMS = now;
458 retries = 0;
459 if (!inBurst)
460 SendPacket(lastSentPacket + 1, now);
452 return false; 461 return false;
453 } 462 }
454 } 463 }
455 464
456 public bool checkTime(double now) 465 public bool checkTime(double now)
457 { 466 {
458 if(Monitor.TryEnter(myLock)) 467 if (Monitor.TryEnter(myLock))
459 { 468 {
460 if(!isDeleted) 469 if (!isDeleted && !inBurst)
461 { 470 {
462 double timeMS = now - lastsendTimeMS; 471 if (++retries >= 4)
463 if(timeMS > 90000.0)
464 done(); 472 done();
465 else if(timeMS > 3500.0) 473 else
466 { 474 {
467 burstSize = 0; // cancel burst mode 475 double timeMS = now - lastACKTimeMS;
468 SendBurst(now); 476 if(timeMS > 3000.0)
477 {
478 burstSize >>= 2;
479 SendBurst(now);
480 }
469 } 481 }
470 } 482 }
471 483 bool isdel = isDeleted;
472 Monitor.Exit(myLock); 484 Monitor.Exit(myLock);
473 return isDeleted; 485 return isdel;
474 } 486 }
475 return false; 487 return false;
476 } 488 }