diff options
| author | erdgeist <> | 2008-12-07 03:50:51 +0000 |
|---|---|---|
| committer | erdgeist <> | 2008-12-07 03:50:51 +0000 |
| commit | c6947b160f99278057df0770b849b46264b72229 (patch) | |
| tree | 8c5e543648458f7368d51906c53a9e1b45a8c364 /ot_stats.c | |
| parent | ad8c9ee1efac171e5f3a8f41a630254ac88357a8 (diff) | |
Handle program end more politely
Diffstat (limited to 'ot_stats.c')
| -rw-r--r-- | ot_stats.c | 10 |
1 files changed, 10 insertions, 0 deletions
| @@ -188,6 +188,8 @@ size_t stats_top10_txt( char * reply ) { | |||
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | mutex_bucket_unlock( bucket ); | 190 | mutex_bucket_unlock( bucket ); |
| 191 | if( !g_opentracker_running ) | ||
| 192 | return 0; | ||
| 191 | } | 193 | } |
| 192 | 194 | ||
| 193 | r += sprintf( r, "Top 10 torrents by peers:\n" ); | 195 | 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 ) | |||
| 250 | } | 252 | } |
| 251 | } | 253 | } |
| 252 | mutex_bucket_unlock( bucket ); | 254 | mutex_bucket_unlock( bucket ); |
| 255 | if( !g_opentracker_running ) | ||
| 256 | goto bailout_cleanup; | ||
| 253 | } | 257 | } |
| 254 | #endif | 258 | #endif |
| 255 | 259 | ||
| @@ -381,6 +385,8 @@ static size_t stats_peers_mrtg( char * reply ) { | |||
| 381 | peer_count += peer_list->peer_count; seed_count += peer_list->seed_count; | 385 | peer_count += peer_list->peer_count; seed_count += peer_list->seed_count; |
| 382 | } | 386 | } |
| 383 | mutex_bucket_unlock( bucket ); | 387 | mutex_bucket_unlock( bucket ); |
| 388 | if( !g_opentracker_running ) | ||
| 389 | return 0; | ||
| 384 | } | 390 | } |
| 385 | return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", | 391 | return sprintf( reply, "%zd\n%zd\nopentracker serving %zd torrents\nopentracker", |
| 386 | peer_count, | 392 | peer_count, |
| @@ -399,6 +405,8 @@ static size_t stats_startstop_mrtg( char * reply ) | |||
| 399 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | 405 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); |
| 400 | torrent_count += torrents_list->size; | 406 | torrent_count += torrents_list->size; |
| 401 | mutex_bucket_unlock( bucket ); | 407 | mutex_bucket_unlock( bucket ); |
| 408 | if( !g_opentracker_running ) | ||
| 409 | return 0; | ||
| 402 | } | 410 | } |
| 403 | 411 | ||
| 404 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", | 412 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd torrents\nopentracker", |
| @@ -422,6 +430,8 @@ static size_t stats_toraddrem_mrtg( char * reply ) | |||
| 422 | peer_count += peer_list->peer_count; | 430 | peer_count += peer_list->peer_count; |
| 423 | } | 431 | } |
| 424 | mutex_bucket_unlock( bucket ); | 432 | mutex_bucket_unlock( bucket ); |
| 433 | if( !g_opentracker_running ) | ||
| 434 | return 0; | ||
| 425 | } | 435 | } |
| 426 | 436 | ||
| 427 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", | 437 | return sprintf( reply, "%zd\n%zd\nopentracker handling %zd peers\nopentracker", |
