From c6947b160f99278057df0770b849b46264b72229 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sun, 7 Dec 2008 03:50:51 +0000 Subject: Handle program end more politely --- ot_stats.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ot_stats.c') diff --git a/ot_stats.c b/ot_stats.c index f456d46..a4596c6 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -188,6 +188,8 @@ size_t stats_top10_txt( char * reply ) { } } mutex_bucket_unlock( bucket ); + if( !g_opentracker_running ) + return 0; } r += sprintf( r, "Top 10 torrents by peers:\n" ); @@ -250,6 +252,8 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh ) } } mutex_bucket_unlock( bucket ); + if( !g_opentracker_running ) + goto bailout_cleanup; } #endif @@ -381,6 +385,8 @@ static size_t stats_peers_mrtg( char * reply ) { peer_count += peer_list->peer_count; seed_count += peer_list->seed_count; } mutex_bucket_unlock( bucket ); + if( !g_opentracker_running ) + return 0; } return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", peer_count, @@ -399,6 +405,8 @@ static size_t stats_startstop_mrtg( char * reply ) ot_vector *torrents_list = mutex_bucket_lock( bucket ); torrent_count += torrents_list->size; mutex_bucket_unlock( bucket ); + if( !g_opentracker_running ) + return 0; } return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", @@ -422,6 +430,8 @@ static size_t stats_toraddrem_mrtg( char * reply ) peer_count += peer_list->peer_count; } mutex_bucket_unlock( bucket ); + if( !g_opentracker_running ) + return 0; } return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", -- cgit v1.2.3