Author: alanmc
Date: 2006-11-09 13:34:44 -0500 (Thu, 09 Nov 2006)
New Revision: 67625

Modified:
   trunk/bitsharp/src/MonoTorrent.Client/RateLimiter.cs
Log:
Bugfix to prevent large negative numbers which would render the peer unable to 
send /receive messages again.

Modified: trunk/bitsharp/src/MonoTorrent.Client/RateLimiter.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.Client/RateLimiter.cs        2006-11-09 
18:30:07 UTC (rev 67624)
+++ trunk/bitsharp/src/MonoTorrent.Client/RateLimiter.cs        2006-11-09 
18:34:44 UTC (rev 67625)
@@ -39,6 +39,12 @@
             Interlocked.Add(ref this.UploadChunks, increaseAmount);
             if (this.UploadChunks > increaseAmount * 3)
                 Interlocked.Exchange(ref this.UploadChunks, (increaseAmount * 
3));
+
+            if (this.UploadChunks < (maxUploadSpeed / 
ConnectionManager.ChunkLength) / 2)
+                Interlocked.Exchange(ref this.UploadChunks, (maxUploadSpeed / 
ConnectionManager.ChunkLength / 2));
+
+            if (this.DownloadChunks < (maxDownloadSpeed / 
ConnectionManager.ChunkLength / 2))
+                Interlocked.Exchange(ref this.DownloadChunks, 
(maxDownloadSpeed / ConnectionManager.ChunkLength / 2));
         }
         #endregion
     }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to