aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2019-06-13 00:08:51 +0100
committerUbitUmarov2019-06-13 00:08:51 +0100
commit086248c13b750e7e6ba2ffb7365611b72a2bc4be (patch)
tree404618a643c614ffc234a887e36f99c26f3c4100
parenttest... (diff)
downloadopensim-SC-086248c13b750e7e6ba2ffb7365611b72a2bc4be.zip
opensim-SC-086248c13b750e7e6ba2ffb7365611b72a2bc4be.tar.gz
opensim-SC-086248c13b750e7e6ba2ffb7365611b72a2bc4be.tar.bz2
opensim-SC-086248c13b750e7e6ba2ffb7365611b72a2bc4be.tar.xz
minor cleanup
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs84
1 files changed, 39 insertions, 45 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index 8b7a82d..32b3523 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -50,8 +50,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private object timeTickLock = new object(); 52 private object timeTickLock = new object();
53 private double lastTimeTick = 0.0; 53 private int lastTimeTick = 0;
54 private double lastFilesExpire = 0.0; 54 private int lastFilesExpire = 0;
55 private bool inTimeTick = false; 55 private bool inTimeTick = false;
56 56
57 public struct XferRequest 57 public struct XferRequest
@@ -66,15 +66,15 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
66 { 66 {
67 public byte[] Data; 67 public byte[] Data;
68 public int refsCount; 68 public int refsCount;
69 public double timeStampMS; 69 public int timeStampMS;
70 } 70 }
71 71
72 #region INonSharedRegionModule Members 72 #region INonSharedRegionModule Members
73 73
74 public void Initialise(IConfigSource config) 74 public void Initialise(IConfigSource config)
75 { 75 {
76 lastTimeTick = Util.GetTimeStampMS() + 30000.0; 76 lastTimeTick = (int)Util.GetTimeStampMS() + 30000;
77 lastFilesExpire = lastTimeTick + 180000.0; 77 lastFilesExpire = lastTimeTick + 180000;
78 } 78 }
79 79
80 public void AddRegion(Scene scene) 80 public void AddRegion(Scene scene)
@@ -121,10 +121,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
121 { 121 {
122 if(!inTimeTick) 122 if(!inTimeTick)
123 { 123 {
124 double now = Util.GetTimeStampMS(); 124 int now = (int)Util.GetTimeStampMS();
125 if(now - lastTimeTick > 750.0) 125 if(now - lastTimeTick > 750)
126 { 126 {
127
128 if(Transfers.Count == 0 && NewFiles.Count == 0) 127 if(Transfers.Count == 0 && NewFiles.Count == 0)
129 lastTimeTick = now; 128 lastTimeTick = now;
130 else 129 else
@@ -163,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
163 { 162 {
164 lock (NewFiles) 163 lock (NewFiles)
165 { 164 {
166 double now = Util.GetTimeStampMS(); 165 int now = (int)Util.GetTimeStampMS();
167 if (NewFiles.ContainsKey(fileName)) 166 if (NewFiles.ContainsKey(fileName))
168 { 167 {
169 NewFiles[fileName].refsCount++; 168 NewFiles[fileName].refsCount++;
@@ -183,18 +182,18 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
183 } 182 }
184 183
185 #endregion 184 #endregion
186 public void expireFiles(double now) 185 public void expireFiles(int now)
187 { 186 {
188 lock (NewFiles) 187 lock (NewFiles)
189 { 188 {
190 // hopefully we will not have many files so nasty code will do it 189 // hopefully we will not have many files so nasty code will do it
191 if(now - lastFilesExpire > 120000.0) 190 if(now - lastFilesExpire > 120000)
192 { 191 {
193 lastFilesExpire = now; 192 lastFilesExpire = now;
194 List<string> expires = new List<string>(); 193 List<string> expires = new List<string>();
195 foreach(string fname in NewFiles.Keys) 194 foreach(string fname in NewFiles.Keys)
196 { 195 {
197 if(NewFiles[fname].refsCount == 0 && now - NewFiles[fname].timeStampMS > 120000.0) 196 if(NewFiles[fname].refsCount == 0 && now - NewFiles[fname].timeStampMS > 120000)
198 expires.Add(fname); 197 expires.Add(fname);
199 } 198 }
200 foreach(string fname in expires) 199 foreach(string fname in expires)
@@ -230,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
230 } 229 }
231 } 230 }
232 231
233 public void transfersTimeTick(double now) 232 public void transfersTimeTick(int now)
234 { 233 {
235 XferDownLoad[] xfrs; 234 XferDownLoad[] xfrs;
236 lock(Transfers) 235 lock(Transfers)
@@ -241,6 +240,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
241 xfrs = new XferDownLoad[Transfers.Count]; 240 xfrs = new XferDownLoad[Transfers.Count];
242 Transfers.Values.CopyTo(xfrs,0); 241 Transfers.Values.CopyTo(xfrs,0);
243 } 242 }
243
244 foreach(XferDownLoad xfr in xfrs) 244 foreach(XferDownLoad xfr in xfrs)
245 { 245 {
246 if(xfr.checkTime(now)) 246 if(xfr.checkTime(now))
@@ -274,12 +274,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
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 *= remoteClient.PingTimeMS; 276 burstSize *= remoteClient.PingTimeMS;
277 burstSize >>= 10; // ping is ms, 1 round trips 277 burstSize >>= 10; // ping is ms, 1 round trip
278 if(burstSize > 32)
279 burstSize = 32;
278 XferDownLoad transaction = 280 XferDownLoad transaction =
279 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); 281 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize);
280 282
281 Transfers.Add(xferID, transaction); 283 Transfers.Add(xferID, transaction);
282
283 transaction.StartSend(); 284 transaction.StartSend();
284 285
285 // The transaction for this file is on its way 286 // The transaction for this file is on its way
@@ -327,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
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;
@@ -385,30 +386,25 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
385 386
386 lastAckPacket = -1; 387 lastAckPacket = -1;
387 lastSentPacket = -1; 388 lastSentPacket = -1;
388
389 double now = Util.GetTimeStampMS();
390 retries = 0; 389 retries = 0;
391 390
392 SendBurst(now); 391 SendBurst();
393 return; 392 return;
394 } 393 }
395 } 394 }
396 395
397 private void SendBurst(double now) 396 private void SendBurst()
398 { 397 {
399 lock(myLock) 398 int start = lastAckPacket + 1;
400 { 399 int end = start + burstSize;
401 lastACKTimeMS = (int)now; // reset timeout 400 if (end > LastPacket)
402 int start = lastAckPacket + 1; 401 end = LastPacket;
403 int end = start + burstSize; 402 while (start <= end)
404 if (end > LastPacket) 403 SendPacket(start++);
405 end = LastPacket; 404 lastACKTimeMS = (int)Util.GetTimeStampMS(); // reset timeout
406 while (start <= end)
407 SendPacket(start++ , now);
408 }
409 } 405 }
410 406
411 private void SendPacket(int pkt, double now) 407 private void SendPacket(int pkt)
412 { 408 {
413 if(pkt > LastPacket) 409 if(pkt > LastPacket)
414 return; 410 return;
@@ -443,45 +439,43 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
443 if(isDeleted) 439 if(isDeleted)
444 return true; 440 return true;
445 441
446 packet &= 0x7fffffff; 442 packet &= 0x7fffffff;
447 if(lastAckPacket < packet) 443 if (lastAckPacket < packet)
448 lastAckPacket = (int)packet; 444 lastAckPacket = (int)packet;
449 445 else if (lastAckPacket == LastPacket)
450 if(lastAckPacket == LastPacket)
451 { 446 {
452 done(); 447 done();
453 return true; 448 return true;
454 } 449 }
455 450
456 double now = Util.GetTimeStampMS(); 451 lastACKTimeMS = (int)Util.GetTimeStampMS();
457 lastACKTimeMS = (int)now;
458 retries = 0; 452 retries = 0;
459 SendPacket(lastSentPacket + 1, now); 453 SendPacket(lastSentPacket + 1);
460 return false; 454 return false;
461 } 455 }
462 } 456 }
463 457
464 public bool checkTime(double now) 458 public bool checkTime(int now)
465 { 459 {
466 if (Monitor.TryEnter(myLock)) 460 if (Monitor.TryEnter(myLock))
467 { 461 {
468 if (!isDeleted) 462 if (!isDeleted)
469 { 463 {
470 double timeMS = now - lastACKTimeMS; 464 int timeMS = now - lastACKTimeMS;
471 465 int tout = 5 * remoteClient.PingTimeMS;
472 double tout = 5 * remoteClient.PingTimeMS;
473 if(tout > 10000) 466 if(tout > 10000)
474 tout = 10000; 467 tout = 10000;
475 else if (tout < 1000) 468 else if (tout < 1000)
476 tout = 1000; 469 tout = 1000;
470
477 if (timeMS > tout) 471 if (timeMS > tout)
478 { 472 {
479 if (++retries >= 4) 473 if (++retries > 4)
480 done(); 474 done();
481 else 475 else
482 { 476 {
483 burstSize >>= 2; 477 burstSize = lastSentPacket - lastAckPacket - 1;
484 SendBurst(now); 478 SendBurst();
485 } 479 }
486 } 480 }
487 } 481 }