From 15ea6f002ffbe1f3463639d3fe8c0bc07526a6d8 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. --- 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 9bff6f8b60..923d39e18f 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -398,6 +398,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 cc76a6541f..f2c60b9b8a 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -660,6 +660,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. ***/ @@ -670,11 +680,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; } @@ -747,7 +759,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.