From: Alan T. DeKok Date: Fri, 23 Jun 2023 18:22:57 +0000 (-0400) Subject: don't exit until all detached requests have stopped X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14ddc663bc17ccdc6a7c860cfb188c58fb5536d1;p=thirdparty%2Ffreeradius-server.git don't exit until all detached requests have stopped which (for now) also means keeping detached requests in the time_order list. That seems reasonable, as that list measures the total amount of work that this thread is doing --- diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index 8f08644613a..f83c3300eaa 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -1195,9 +1195,9 @@ static void _worker_request_done_detached(request_t *request, UNUSED rlm_rcode_t /** Make us responsible for running the request * */ -static void _worker_request_detach(request_t *request, void *uctx) +static void _worker_request_detach(request_t *request, UNUSED void *uctx) { - fr_worker_t *worker = talloc_get_type_abort(uctx, fr_worker_t); +// fr_worker_t *worker = talloc_get_type_abort(uctx, fr_worker_t); RDEBUG3("Request is detached"); fr_assert(request_is_detached(request)); @@ -1207,7 +1207,7 @@ static void _worker_request_detach(request_t *request, void *uctx) * because they don't contribute for the time consumed by an * external request. */ - worker_request_time_tracking_end(worker, request, fr_time()); +// worker_request_time_tracking_end(worker, request, fr_time()); return; } @@ -1465,7 +1465,11 @@ nomem: } -/** The main loop and entry point of the worker thread. +/** The main loop and entry point of the stand-alone worker thread. + * + * Where there is only one thread, the event loop runs fr_worker_pre_event() and fr_worker_post_event() + * instead, And then fr_worker_post_event() takes care of calling worker_run_request() to actually run the + * request. * * @param[in] worker the worker data structure to manage */ @@ -1473,7 +1477,7 @@ void fr_worker(fr_worker_t *worker) { WORKER_VERIFY; - while (!worker->exiting) { + while (true) { bool wait_for_event; int num_events; @@ -1485,6 +1489,8 @@ void fr_worker(fr_worker_t *worker) */ wait_for_event = (fr_heap_num_elements(worker->runnable) == 0); if (wait_for_event) { + if (worker->exiting && (fr_minmax_heap_num_elements(worker->time_order) == 0)) break; + DEBUG4("Ready to process requests"); }