Author: alanmc
Date: 2006-11-05 11:21:12 -0500 (Sun, 05 Nov 2006)
New Revision: 67383

Modified:
   trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs
Log:
Bugfix for both TorrentManager.Progress and for the case where we're requesting 
pieces off a peer and he never fulfills the request. Now torrents will *always* 
finish. Although the last few % may take up 5-10 minutes worst case scenario

Modified: trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs    
2006-11-05 16:03:02 UTC (rev 67382)
+++ trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs    
2006-11-05 16:21:12 UTC (rev 67383)
@@ -456,8 +456,17 @@
                             Debug.WriteLine("ReChoking: " + this.uploadingTo);
                         }
 
+                        if ((DateTime.Now - 
id.Peer.Connection.LastMessageReceived) > new TimeSpan(0, 2, 0) && 
id.Peer.Connection.AmRequestingPiecesCount > 0)
+                        {
+                            ClientEngine.ConnectionManager.CleanupSocket(id);
+                            continue;
+                        }
                         while (!id.Peer.Connection.IsChoking && 
id.Peer.Connection.AmRequestingPiecesCount < 6 && 
id.Peer.Connection.AmInterested)
                         {
+                            if (pieceManager.InEndGameMode)// In endgame we 
only want to queue 2 pieces
+                                if (id.Peer.Connection.AmRequestingPiecesCount 
> 2)
+                                    break;
+
                             msg = this.pieceManager.PickPiece(id, 
this.connectedPeers);
                             if (msg == null)
                                 break;
@@ -796,7 +805,7 @@
         /// </summary>
         public double Progress
         {
-            get { return ((this.pieceManager.MyBitField.TrueCount * 100.0) / 
this.pieceManager.MyBitField.Length); }
+            get { return (((this.pieceManager.MyBitField.TrueCount - 
this.pieceManager.CurrentRequestCount()) * 100.0) / 
this.pieceManager.MyBitField.Length); }
         }
 
 

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

Reply via email to