diff --git a/libtransmission/internal.h b/libtransmission/internal.h index e0398129f..cb5db5db7 100644 --- a/libtransmission/internal.h +++ b/libtransmission/internal.h @@ -43,6 +43,8 @@ typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t; #define FALSE 0 #endif +int tr_torrentIsPrivate( const tr_torrent * ); + void tr_torrentRecheckCompleteness( tr_torrent * ); int tr_trackerInfoInit( struct tr_tracker_info * info, diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 0cada8122..e2f0b5e35 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -1442,12 +1442,23 @@ sendKeepalive( tr_peermsgs * msgs ) *** **/ +static int +isSwiftEnabled( const tr_peermsgs * msgs ) +{ + /* rationale: SWIFT is good for getting rid of deadbeats, but most + * private trackers have ratios where you _want_ to feed deadbeats + * as much as possible. So we disable SWIFT on private torrents */ + return SWIFT_ENABLED + && !tr_torrentIsSeed( msgs->torrent ) + && !tr_torrentIsPrivate( msgs->torrent ); +} + static size_t getUploadMax( const tr_peermsgs * msgs ) { static const size_t maxval = ~0; const tr_torrent * tor = msgs->torrent; - const int useSwift = SWIFT_ENABLED && !tr_torrentIsSeed( msgs->torrent ); + const int useSwift = isSwiftEnabled( msgs ); const size_t swiftLeft = msgs->info->credit; size_t speedLeft; size_t bufLeft; diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index f9291cc97..6b6507ffd 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -641,10 +641,19 @@ tr_torrentChangeMyPort( tr_torrent * tor ) tr_trackerChangeMyPort( tor->tracker ); } +int +tr_torrentIsPrivate( const tr_torrent * tor ) +{ + return tor + && tor->info.isPrivate; +} + int tr_torrentIsPexEnabled( const tr_torrent * tor ) { - return !tor->info.isPrivate && !tor->pexDisabled; + return tor + && !tr_torrentIsPrivate( tor ) + && !tor->pexDisabled; } void