diff options
author | erdgeist <> | 2007-11-19 21:10:53 +0000 |
---|---|---|
committer | erdgeist <> | 2007-11-19 21:10:53 +0000 |
commit | 49ba269b9d09746e90e153f3e245eaf3f97e35cc (patch) | |
tree | f4847038b777d85dccc3f0ac594ef28d88f4ec40 /opentracker.c | |
parent | 3528752c7b82d23b4cf9331a6df56e2cc8db9239 (diff) |
Cleanup now moved to its own thread, too
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 12 |
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 */ |
45 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; | 46 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; |
46 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; | 47 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; |
47 | static uint32_t g_adminip_addresses[OT_ADMINIP_MAX]; | 48 | static uint32_t g_adminip_addresses[OT_ADMINIP_MAX]; |
48 | static unsigned int g_adminip_count = 0; | 49 | static unsigned int g_adminip_count = 0; |
50 | static time_t ot_last_clean_time; | ||
49 | time_t ot_start_time; | 51 | time_t ot_start_time; |
50 | time_t g_now; | 52 | time_t g_now; |
51 | 53 | ||
@@ -623,6 +625,7 @@ ANNOUNCE_WORKAROUND: | |||
623 | static void signal_handler( int s ) { | 625 | static 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( ); |