summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c
index 59b561b..642815a 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -40,12 +40,14 @@
40#include "ot_iovec.h" 40#include "ot_iovec.h"
41#include "ot_accesslist.h" 41#include "ot_accesslist.h"
42#include "ot_mutex.h" 42#include "ot_mutex.h"
43#include "ot_clean.h"
43 44
44/* Globals */ 45/* Globals */
45static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; 46static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
46static const size_t SUCCESS_HTTP_SIZE_OFF = 17; 47static const size_t SUCCESS_HTTP_SIZE_OFF = 17;
47static uint32_t g_adminip_addresses[OT_ADMINIP_MAX]; 48static uint32_t g_adminip_addresses[OT_ADMINIP_MAX];
48static unsigned int g_adminip_count = 0; 49static unsigned int g_adminip_count = 0;
50static time_t ot_last_clean_time;
49time_t ot_start_time; 51time_t ot_start_time;
50time_t g_now; 52time_t g_now;
51 53
@@ -623,6 +625,7 @@ ANNOUNCE_WORKAROUND:
623static void signal_handler( int s ) { 625static void signal_handler( int s ) {
624 if( s == SIGINT ) { 626 if( s == SIGINT ) {
625 signal( SIGINT, SIG_IGN); 627 signal( SIGINT, SIG_IGN);
628
626 trackerlogic_deinit(); 629 trackerlogic_deinit();
627 exit( 0 ); 630 exit( 0 );
628 } else if( s == SIGALRM ) { 631 } else if( s == SIGALRM ) {
@@ -783,7 +786,10 @@ static void server_mainloop( ) {
783 } 786 }
784 787
785 /* See if we need to move our pools */ 788 /* See if we need to move our pools */
786 clean_all_torrents(); 789 if( g_now != ot_last_clean_time ) {
790 ot_last_clean_time = g_now;
791 clean_all_torrents();
792 }
787 } 793 }
788} 794}
789 795
@@ -872,9 +878,7 @@ int main( int argc, char **argv ) {
872 if( trackerlogic_init( serverdir ) == -1 ) 878 if( trackerlogic_init( serverdir ) == -1 )
873 panic( "Logic not started" ); 879 panic( "Logic not started" );
874 880
875 fullscrape_init( ); 881 g_now = ot_start_time = ot_last_clean_time = time( NULL );
876
877 g_now = ot_start_time = time( NULL );
878 alarm(5); 882 alarm(5);
879 883
880 server_mainloop( ); 884 server_mainloop( );