Created
October 26, 2012 15:10
-
-
Save anonymous/3959327 to your computer and use it in GitHub Desktop.
Transmission sequential download patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: libtransmission/peer-mgr.c | |
=================================================================== | |
--- libtransmission/peer-mgr.c (revision 13594) | |
+++ libtransmission/peer-mgr.c (working copy) | |
@@ -982,6 +982,27 @@ | |
} | |
static int | |
+comparePieceForSequential( const void * va, const void * vb ) | |
+{ | |
+ const struct weighted_piece * a = va; | |
+ const struct weighted_piece * b = vb; | |
+ int ia, ib; | |
+ const tr_torrent * tor = weightTorrent; | |
+ | |
+ /* primary key: higher priorities go first */ | |
+ ia = tor->info.pieces[a->index].priority; | |
+ ib = tor->info.pieces[b->index].priority; | |
+ if( ia > ib ) return -1; | |
+ if( ia < ib ) return 1; | |
+ | |
+ /* secondary key: sequential */ | |
+ if( a->index < b->index ) return -1; | |
+ if( a->index > b->index ) return 1; | |
+ | |
+ return 0; | |
+} | |
+ | |
+static int | |
comparePieceByIndex( const void * va, const void * vb ) | |
{ | |
const struct weighted_piece * a = va; | |
@@ -1001,7 +1022,7 @@ | |
if( state == PIECES_SORTED_BY_WEIGHT ) | |
{ | |
setComparePieceByWeightTorrent( t ); | |
- qsort( t->pieces, t->pieceCount, sizeof( struct weighted_piece ), comparePieceByWeight ); | |
+ qsort( t->pieces, t->pieceCount, sizeof( struct weighted_piece ), comparePieceForSequential ); | |
} | |
else | |
qsort( t->pieces, t->pieceCount, sizeof( struct weighted_piece ), comparePieceByIndex ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment