]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_task_setquantum() and use it for post-init zone loading
authorOndřej Surý <ondrej@isc.org>
Fri, 1 Apr 2022 08:40:37 +0000 (10:40 +0200)
committerOndřej Surý <ondrej@isc.org>
Fri, 1 Apr 2022 21:45:23 +0000 (23:45 +0200)
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
lib/isc/task.c

index 9bff6f8b60fe493515d9c3349a9fb62c353b296f..923d39e18fad508af6badbad93104f8dacb8d635 100644 (file)
@@ -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);
 /*%<
index cc76a6541f9060227c64061bea72c6906aba560a..f2c60b9b8a9c1c10137430cb3f04a1d3d7871384 100644 (file)
@@ -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.