]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't loop indefinitely when isc_task quantum is 'unlimited'
authorOndřej Surý <ondrej@isc.org>
Thu, 7 Mar 2024 12:39:46 +0000 (13:39 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 7 Aug 2024 06:27:15 +0000 (08:27 +0200)
Don't run more events than already scheduled.  If the quantum is set to
a high value, the task_run() would execute already scheduled, and all
new events that result from running event->ev_action().

Setting quantum to a number of scheduled events will postpone events
scheduled after we enter the loop here to the next task_run()
invocation.

lib/isc/task.c

index 48c3e790f4fc085cf038164f37cbb338b69890df..fbee3f03a903f1f4bed7ec37776998d4439006c9 100644 (file)
@@ -793,6 +793,18 @@ task_run(isc_task_t *task) {
        LOCK(&task->lock);
        quantum = task->quantum;
 
+       /*
+        * Don't run more events than already scheduled.  If the quantum is set
+        * to a high value, the following code would execute already scheduled,
+        * and all events that result from running event->ev_action().  Setting
+        * quantum to a number of scheduled events will postpone events
+        * scheduled after we enter the loop here to the next task_run()
+        * invocation.
+        */
+       if (quantum > task->nevents) {
+               quantum = task->nevents;
+       }
+
        if (task->state != task_state_ready) {
                goto done;
        }