From c730a24d0a0c12173ddcd105d6e5344205eb7503 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 16 Oct 2007 00:33:31 +0000 Subject: Fixed 24h clean bug. Allocate less memory for full scrape. Free torrents without any downloaders immediately. --- trackerlogic.c | 13 +++++++++---- 1 file 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 ) { torrent_count += all_torrents[i].size; // one extra for pro- and epilogue - if( !( r = *reply = malloc( 128*(1+torrent_count) ) ) ) return 0; + if( !( r = *reply = malloc( 100*(1+torrent_count) ) ) ) return 0; memmove( r, "d5:filesd", 9 ); r += 9; for( i=0; i<256; ++i ) { @@ -325,7 +325,7 @@ size_t return_fullscrape_for_tracker( char **reply ) { peers += peer_list->peers[k].size; seeds += peer_list->seed_count[k]; } - if( peers ) { + if( peers || peer_list->downloaded ) { *r++='2'; *r++='0'; *r++=':'; memmove( r, hash, 20 ); r+=20; 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 ) { /* Torrent has idled out */ if( timedout > OT_TORRENT_TIMEOUT ) { vector_remove_torrent( torrents_list, hash ); - --j; + --j; continue; } /* If nothing to be cleaned here, handle next torrent */ @@ -558,8 +558,13 @@ void clean_all_torrents( void ) { for( k = 0; k < OT_POOLS_COUNT; ++k ) peers_count += peer_list->peers[k].size; - if( !peers_count ) + if( !peers_count ) { + if( !peer_list->downloaded ) { + vector_remove_torrent( torrents_list, hash ); + --j; + } continue; + } timedout = OT_POOLS_COUNT; } -- cgit v1.2.3