From: Jordan Lee Date: Fri, 4 Mar 2011 17:33:29 +0000 (+0000) Subject: (trunk libT) #3208 "Local Peer Discovery idea: prioritize LPD requests for downloads... X-Git-Tag: 2.30b1~191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9024cb29f9ac33a83ce02a672e0e495434501746;p=transmission (trunk libT) #3208 "Local Peer Discovery idea: prioritize LPD requests for downloads" -- add patch from Eszet --- diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index abc0b024a..430aa2dc5 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -63,7 +63,7 @@ enum UPKEEP_INTERVAL_SECS = 1, /* this is an upper limit for the frequency of LDS announces */ - LPD_HOUSEKEEPING_INTERVAL_SECS = 30 + LPD_HOUSEKEEPING_INTERVAL_SECS = 5 }; diff --git a/libtransmission/tr-lpd.c b/libtransmission/tr-lpd.c index f18524b68..bffcbe5ae 100644 --- a/libtransmission/tr-lpd.c +++ b/libtransmission/tr-lpd.c @@ -552,17 +552,32 @@ int tr_lpdAnnounceMore( const time_t now, const int interval ) { if( tr_isTorrent( tor ) ) { - if( !tr_torrentAllowsLPD( tor ) || ( - ( tr_torrentGetActivity( tor ) != TR_STATUS_DOWNLOAD ) && - ( tr_torrentGetActivity( tor ) != TR_STATUS_SEED ) ) ) + int announcePrio = 0; + + if( !tr_torrentAllowsLPD( tor ) ) continue; - if( tor->lpdAnnounceAt <= now ) + /* issue #3208: prioritize downloads before seeds */ + switch( tr_torrentGetActivity( tor ) ) + { + case TR_STATUS_DOWNLOAD: + announcePrio = 1; + break; + case TR_STATUS_SEED: + announcePrio = 2; + break; + default: /* fall through */ + break; + } + + if( announcePrio > 0 && tor->lpdAnnounceAt <= now ) { if( tr_lpdSendAnnounce( tor ) ) announcesSent++; - tor->lpdAnnounceAt = now + lpd_announceInterval; + tor->lpdAnnounceAt = now + + lpd_announceInterval * announcePrio; + break; /* that's enough; for this interval */ } }