diff options
Diffstat (limited to 'ot_clean.c')
-rw-r--r-- | ot_clean.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -20,7 +20,7 @@ | |||
20 | static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, time_t timedout, int *removed_seeders ) { | 20 | static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, time_t timedout, int *removed_seeders ) { |
21 | ot_peer *last_peer = peers + peer_count, *insert_point; | 21 | ot_peer *last_peer = peers + peer_count, *insert_point; |
22 | time_t timediff; | 22 | time_t timediff; |
23 | 23 | ||
24 | /* Two scan modes: unless there is one peer removed, just increase ot_peertime */ | 24 | /* Two scan modes: unless there is one peer removed, just increase ot_peertime */ |
25 | while( peers < last_peer ) { | 25 | while( peers < last_peer ) { |
26 | if( ( timediff = timedout + OT_PEERTIME( peers ) ) >= OT_PEER_TIMEOUT ) | 26 | if( ( timediff = timedout + OT_PEERTIME( peers ) ) >= OT_PEER_TIMEOUT ) |
@@ -105,17 +105,19 @@ static void * clean_worker( void * args ) { | |||
105 | while( bucket-- ) { | 105 | while( bucket-- ) { |
106 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | 106 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); |
107 | size_t toffs; | 107 | size_t toffs; |
108 | int delta_torrentcount = 0; | ||
108 | 109 | ||
109 | for( toffs=0; toffs<torrents_list->size; ++toffs ) { | 110 | for( toffs=0; toffs<torrents_list->size; ++toffs ) { |
110 | ot_torrent *torrent = ((ot_torrent*)(torrents_list->data)) + toffs; | 111 | ot_torrent *torrent = ((ot_torrent*)(torrents_list->data)) + toffs; |
111 | if( clean_single_torrent( torrent ) ) { | 112 | if( clean_single_torrent( torrent ) ) { |
112 | vector_remove_torrent( torrents_list, torrent ); | 113 | vector_remove_torrent( torrents_list, torrent ); |
114 | delta_torrentcount -= 1; | ||
113 | --toffs; continue; | 115 | --toffs; continue; |
114 | } | 116 | } |
115 | } | 117 | } |
116 | mutex_bucket_unlock( bucket ); | 118 | mutex_bucket_unlock( bucket, delta_torrentcount ); |
117 | if( !g_opentracker_running ) | 119 | if( !g_opentracker_running ) |
118 | return NULL; | 120 | return NULL; |
119 | usleep( OT_CLEAN_SLEEP ); | 121 | usleep( OT_CLEAN_SLEEP ); |
120 | } | 122 | } |
121 | } | 123 | } |