]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
Fixed 24h clean bug. Allocate less memory for full scrape. Free torrents without...
authorerdgeist <>
Tue, 16 Oct 2007 00:33:31 +0000 (00:33 +0000)
committererdgeist <>
Tue, 16 Oct 2007 00:33:31 +0000 (00:33 +0000)
trackerlogic.c

index 37b3c4d9abd3f57786a715230e042f2852b15614..ee7b7fc3fcb702434e15220ee887d18533360878 100644 (file)
@@ -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;
       }