From 68abe3fa06a8ba2ff00320a3e9bf381de82c1aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 1 Apr 2022 10:40:37 +0200 Subject: [PATCH] Add isc_task_setquantum() and use it for post-init zone loading Add isc_task_setquantum() function that modifies quantum for the future isc_task_run() invocations. NOTE: The current isc_task_run() caches the task->quantum into a local variable and therefore the current event loop is not affected by any quantum change. (cherry picked from commit 15ea6f002ffbe1f3463639d3fe8c0bc07526a6d8) --- lib/isc/include/isc/task.h | 9 +++++++++ lib/isc/task.c | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index 973cb30284..75b7cdb9d1 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -488,6 +488,15 @@ isc_task_gettag(isc_task_t *task); *\li 'task' is a valid task. */ +void +isc_task_setquantum(isc_task_t *task, unsigned int quantum); +/*%< + * Set future 'task' quantum to 'quantum'. The current 'task' quantum will be + * kept for the current isc_task_run() loop, and will be changed for the next + * run. Therefore, the function is save to use from the event callback as it + * will not affect the current event loop processing. + */ + isc_result_t isc_task_beginexclusive(isc_task_t *task); /*%< diff --git a/lib/isc/task.c b/lib/isc/task.c index 7698c84492..439d430790 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -761,6 +761,16 @@ isc_task_getnetmgr(isc_task_t *task) { return (task->manager->netmgr); } +void +isc_task_setquantum(isc_task_t *task, unsigned int quantum) { + REQUIRE(VALID_TASK(task)); + + LOCK(&task->lock); + task->quantum = (quantum > 0) ? quantum + : task->manager->default_quantum; + UNLOCK(&task->lock); +} + /*** *** Task Manager. ***/ @@ -771,11 +781,13 @@ task_run(isc_task_t *task) { bool finished = false; isc_event_t *event = NULL; isc_result_t result = ISC_R_SUCCESS; + uint32_t quantum; REQUIRE(VALID_TASK(task)); LOCK(&task->lock); - /* FIXME */ + quantum = task->quantum; + if (task->state != task_state_ready) { goto done; } @@ -849,7 +861,7 @@ task_run(isc_task_t *task) { task->state = task_state_idle; } break; - } else if (dispatch_count >= task->quantum) { + } else if (dispatch_count >= quantum) { /* * Our quantum has expired, but there is more work to be * done. We'll requeue it to the ready queue later.