summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trackerlogic.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 37b3c4d..ee7b7fc 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -312,7 +312,7 @@ size_t return_fullscrape_for_tracker( char **reply ) {
312 torrent_count += all_torrents[i].size; 312 torrent_count += all_torrents[i].size;
313 313
314 // one extra for pro- and epilogue 314 // one extra for pro- and epilogue
315 if( !( r = *reply = malloc( 128*(1+torrent_count) ) ) ) return 0; 315 if( !( r = *reply = malloc( 100*(1+torrent_count) ) ) ) return 0;
316 316
317 memmove( r, "d5:filesd", 9 ); r += 9; 317 memmove( r, "d5:filesd", 9 ); r += 9;
318 for( i=0; i<256; ++i ) { 318 for( i=0; i<256; ++i ) {
@@ -325,7 +325,7 @@ size_t return_fullscrape_for_tracker( char **reply ) {
325 peers += peer_list->peers[k].size; 325 peers += peer_list->peers[k].size;
326 seeds += peer_list->seed_count[k]; 326 seeds += peer_list->seed_count[k];
327 } 327 }
328 if( peers ) { 328 if( peers || peer_list->downloaded ) {
329 *r++='2'; *r++='0'; *r++=':'; 329 *r++='2'; *r++='0'; *r++=':';
330 memmove( r, hash, 20 ); r+=20; 330 memmove( r, hash, 20 ); r+=20;
331 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", seeds, peer_list->downloaded, peers-seeds ); 331 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", seeds, peer_list->downloaded, peers-seeds );
@@ -548,7 +548,7 @@ void clean_all_torrents( void ) {
548 /* Torrent has idled out */ 548 /* Torrent has idled out */
549 if( timedout > OT_TORRENT_TIMEOUT ) { 549 if( timedout > OT_TORRENT_TIMEOUT ) {
550 vector_remove_torrent( torrents_list, hash ); 550 vector_remove_torrent( torrents_list, hash );
551 --j; 551 --j; continue;
552 } 552 }
553 553
554 /* If nothing to be cleaned here, handle next torrent */ 554 /* If nothing to be cleaned here, handle next torrent */
@@ -558,8 +558,13 @@ void clean_all_torrents( void ) {
558 for( k = 0; k < OT_POOLS_COUNT; ++k ) 558 for( k = 0; k < OT_POOLS_COUNT; ++k )
559 peers_count += peer_list->peers[k].size; 559 peers_count += peer_list->peers[k].size;
560 560
561 if( !peers_count ) 561 if( !peers_count ) {
562 if( !peer_list->downloaded ) {
563 vector_remove_torrent( torrents_list, hash );
564 --j;
565 }
562 continue; 566 continue;
567 }
563 568
564 timedout = OT_POOLS_COUNT; 569 timedout = OT_POOLS_COUNT;
565 } 570 }