/* Clean up all peers in current bucket, remove timedout pools and torrents */ static void * clean_worker( void * args ) { (void) args; while( 1 ) { int bucket = OT_BUCKET_COUNT; while( bucket-- ) { ot_vector *torrents_list = mutex_bucket_lock( bucket ); size_t toffs; int delta_torrentcount = 0; for( toffs=0; toffs<torrents_list->size; ++toffs ) { ot_torrent *torrent = ((ot_torrent*)(torrents_list->data)) + toffs; if( clean_single_torrent( torrent ) ) { vector_remove_torrent( torrents_list, torrent ); --delta_torrentcount; --toffs; } } mutex_bucket_unlock( bucket, delta_torrentcount ); if( !g_opentracker_running ) return NULL; usleep( OT_CLEAN_SLEEP ); } stats_cleanup(); } return NULL; }
/* Clean up all peers in current bucket, remove timedout pools and torrents */ static void * clean_worker( void * args ) { #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: start"); #endif (void) args; while( 1 ) { int bucket = OT_BUCKET_COUNT; while( bucket-- ) { ot_vector *torrents_list = mutex_bucket_lock( bucket ); size_t toffs; int delta_torrentcount = 0; for( toffs=0; toffs<torrents_list->size; ++toffs ) { ot_torrent *torrent = ((ot_torrent*)(torrents_list->data)) + toffs; if( clean_single_torrent( torrent ) ) { /* terasaur -- begin mod */ /* torrent->peer_list->peer_count = 0; torrent->peer_list->seed_count = 0; #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: calling ts_update_torrent_stats"); #endif ts_update_torrent_stats(torrent, 0); #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: after ts_update_torrent_stats"); #endif */ /* terasaur -- end mod */ vector_remove_torrent( torrents_list, torrent ); #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: after vector_remove_torrent"); #endif --delta_torrentcount; --toffs; } #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: after if clean_single_torrent block"); #endif } mutex_bucket_unlock( bucket, delta_torrentcount ); if( !g_opentracker_running ) return NULL; usleep( OT_CLEAN_SLEEP ); } #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: calling stats_cleanup"); #endif stats_cleanup(); } #ifdef _DEBUG ts_log_debug("ot_clean::clean_worker: returning"); #endif return NULL; }
static void clean_make() { int bucket; for( bucket = OT_BUCKET_COUNT - 1; bucket >= 0; --bucket ) { ot_vector *torrents_list = mutex_bucket_lock( bucket ); size_t toffs; for( toffs=0; toffs<torrents_list->size; ++toffs ) { ot_torrent *torrent = ((ot_torrent*)(torrents_list->data)) + toffs; if( clean_single_torrent( torrent ) ) { vector_remove_torrent( torrents_list, torrent ); --toffs; continue; } } mutex_bucket_unlock( bucket ); } }