Changeset 5979 for trunk/libtransmission/session.c
- Timestamp:
- May 30, 2008, 5:22:26 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/session.c
r5975 r5979 398 398 } 399 399 400 /* close the biggest torrents first */ 401 static int 402 compareTorrentByCur( const void * va, const void * vb ) 403 { 404 const tr_torrent * a = *(const tr_torrent**)va; 405 const tr_torrent * b = *(const tr_torrent**)vb; 406 return -tr_compareUint64( a->downloadedCur + a->uploadedCur, 407 b->downloadedCur + b->uploadedCur ); 408 } 409 400 410 static void 401 411 tr_closeAllConnections( void * vh ) … … 403 413 tr_handle * h = vh; 404 414 tr_torrent * tor; 415 int i, n; 416 tr_torrent ** torrents; 405 417 406 418 tr_sharedShuttingDown( h->shared ); … … 408 420 tr_rpcClose( &h->rpcServer ); 409 421 410 while(( tor = tr_torrentNext( h, NULL ))) 411 tr_torrentFree( tor ); 422 /* close the torrents. get the most active ones first so that 423 * if we can't get them all closed in a reasonable amount of time, 424 * at least we get the most important ones first. */ 425 tor = NULL; 426 n = h->torrentCount; 427 torrents = tr_new( tr_torrent*, h->torrentCount ); 428 for( i=0; i<n; ++i ) 429 torrents[i] = tr_torrentNext( h, tor ); 430 qsort( torrents, n, sizeof(tr_torrent*), compareTorrentByCur ); 431 for( i=0; i<n; ++i ) 432 tr_torrentFree( torrents[i] ); 433 tr_free( torrents ); 412 434 413 435 tr_peerMgrFree( h->peerMgr );
Note: See TracChangeset
for help on using the changeset viewer.