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_fullscrape.c | |
parent | ad8c9ee1efac171e5f3a8f41a630254ac88357a8 (diff) |
Handle program end more politely
Diffstat (limited to 'ot_fullscrape.c')
-rw-r--r-- | ot_fullscrape.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 5f61afd..9a6effb 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c | |||
@@ -65,6 +65,8 @@ static void * fullscrape_worker( void * args ) { | |||
65 | fullscrape_make( &iovec_entries, &iovector, tasktype ); | 65 | fullscrape_make( &iovec_entries, &iovector, tasktype ); |
66 | if( mutex_workqueue_pushresult( taskid, iovec_entries, iovector ) ) | 66 | if( mutex_workqueue_pushresult( taskid, iovec_entries, iovector ) ) |
67 | iovec_free( &iovec_entries, &iovector ); | 67 | iovec_free( &iovec_entries, &iovector ); |
68 | if( !g_opentracker_running ) | ||
69 | return NULL; | ||
68 | } | 70 | } |
69 | return NULL; | 71 | return NULL; |
70 | } | 72 | } |
@@ -150,7 +152,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas | |||
150 | /* Get exclusive access to that bucket */ | 152 | /* Get exclusive access to that bucket */ |
151 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | 153 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); |
152 | size_t tor_offset; | 154 | size_t tor_offset; |
153 | 155 | ||
154 | /* For each torrent in this bucket.. */ | 156 | /* For each torrent in this bucket.. */ |
155 | for( tor_offset=0; tor_offset<torrents_list->size; ++tor_offset ) { | 157 | for( tor_offset=0; tor_offset<torrents_list->size; ++tor_offset ) { |
156 | /* Address torrents members */ | 158 | /* Address torrents members */ |
@@ -202,8 +204,12 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas | |||
202 | IF_COMPRESSION( r = compress_buffer; ) | 204 | IF_COMPRESSION( r = compress_buffer; ) |
203 | } | 205 | } |
204 | 206 | ||
205 | /* All torrents done: release lock on currenct bucket */ | 207 | /* All torrents done: release lock on current bucket */ |
206 | mutex_bucket_unlock( bucket ); | 208 | mutex_bucket_unlock( bucket ); |
209 | |||
210 | /* Parent thread died? */ | ||
211 | if( !g_opentracker_running ) | ||
212 | return; | ||
207 | } | 213 | } |
208 | 214 | ||
209 | if( ( mode & TASK_TASK_MASK ) == TASK_FULLSCRAPE ) | 215 | if( ( mode & TASK_TASK_MASK ) == TASK_FULLSCRAPE ) |