From 492c4bbe0bb83c5923f20849f36d3d314e9df877 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 12 Dec 2010 23:27:30 +0000 Subject: [PATCH] (trunk libT) #3658 "don't initiate new peer connections if our bandwidth is maxed out" -- added to trunk for nightly build users to kick around a bit. this is an experimental patch and I'm not sure how I feel about it. --- libtransmission/peer-mgr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 7ee2fefdb..31ca64c75 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -3479,7 +3479,7 @@ getPeerCandidates( tr_session * session, int * candidateCount ) /* leave 5% of connection slots for incoming connections -- ticket #2609 */ const int maxCandidates = tr_sessionGetPeerLimit( session ) * 0.95; - /* don't start any new handshakes if we're full up */ + /* don't start any new handshakes if we have enough peers */ n = 0; tor= NULL; while(( tor = tr_torrentNext( session, tor ))) @@ -3501,6 +3501,8 @@ getPeerCandidates( tr_session * session, int * candidateCount ) while(( tor = tr_torrentNext( session, tor ))) { int i, nAtoms; + tr_bool full_up; + tr_bool full_dn; struct peer_atom ** atoms; if( !tor->torrentPeers->isRunning ) @@ -3511,7 +3513,11 @@ getPeerCandidates( tr_session * session, int * candidateCount ) continue; /* if we've already got enough speed in this torrent... */ - if( tr_torrentIsSeed( tor ) && isBandwidthMaxedOut( tor->bandwidth, now_msec, TR_UP ) ) + full_up = isBandwidthMaxedOut( tor->bandwidth, now_msec, TR_UP ); + full_dn = isBandwidthMaxedOut( tor->bandwidth, now_msec, TR_DOWN ); + if( full_up && full_dn ) + continue; + if( full_up && tr_torrentIsSeed( tor ) ) continue; atoms = (struct peer_atom**) tr_ptrArrayPeek( &tor->torrentPeers->pool, &nAtoms );