From 6cbd21542cf7a751e6f0f38864e7e9eae8fa3b14 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 27 Oct 2026 21:32:24 +0100 Subject: Plug in the new per-thread stats counter, also make sure that the ot_clean sleep does not stall tracker exit --- ot_mutex.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ot_mutex.c') diff --git a/ot_mutex.c b/ot_mutex.c index 37d9962..c44efed 100644 --- a/ot_mutex.c +++ b/ot_mutex.c @@ -6,6 +6,7 @@ /* System */ #include #include +#include #include #include #include @@ -145,9 +146,13 @@ ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype) { break; } - /* Wait until the next task is being fed */ - if (!taskid) + /* Wait until the next task is being fed, unless the tracker is on its + way out, in which case the worker is meant to leave rather than wait */ + if (!taskid) { + if (!g_opentracker_running) + break; pthread_cond_wait(&tasklist_being_filled, &tasklist_mutex); + } } /* Release lock */ @@ -271,6 +276,13 @@ void mutex_init(void) { memset(all_torrents, 0, sizeof(all_torrents)); } +/* Let every worker parked on the queue see that the tracker is stopping */ +void mutex_workqueue_wakeall(void) { + pthread_mutex_lock(&tasklist_mutex); + pthread_cond_broadcast(&tasklist_being_filled); + pthread_mutex_unlock(&tasklist_mutex); +} + void mutex_deinit(void) { size_t i; for (i = 0; i < OT_BUCKET_COUNT; ++i) -- cgit v1.3