]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Document isc_task_sendto properly, make sure that cpu we're sending to is always...
authorWitold Kręcicki <wpk@isc.org>
Thu, 25 Oct 2018 06:31:53 +0000 (06:31 +0000)
committerWitold Kręcicki <wpk@isc.org>
Tue, 6 Nov 2018 08:19:50 +0000 (08:19 +0000)
lib/isc/include/isc/task.h
lib/isc/task.c

index d3146f51a78ed97f9aba0367ac6e12c450d9cba1..4ee783aedc0718c49340017ff99b89af3e01aee6 100644 (file)
@@ -212,7 +212,8 @@ isc_task_send(isc_task_t *task, isc_event_t **eventp);
 void
 isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int c);
 /*%<
- * Send '*event' to 'task'.
+ * Send '*event' to 'task', if task is idle try starting it on cpu 'c'
+ * If 'c' is smaller than 0 then cpu is selected randomly.
  *
  * Requires:
  *
@@ -231,7 +232,8 @@ void
 isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
 /*%<
  * Send '*event' to '*taskp' and then detach '*taskp' from its
- * task.
+ * task. If task is idle try starting it on cpu 'c'
+ * If 'c' is smaller than 0 then cpu is selected randomly.
  *
  * Requires:
  *
index 55418590bf3c86b5292efeffc2e14d4bb4f3ac5c..e2124dd53c81fdadb81a46635f89e18913bad93f 100644 (file)
@@ -481,14 +481,13 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
         */
 
        REQUIRE(VALID_TASK(task));
+       XTRACE("isc_task_send");
 
-       if (c == -1) {
+       if (c < 0) {
                c = atomic_fetch_add_explicit(&task->manager->curq, 1,
-                                             memory_order_relaxed)
-                                             % task->manager->workers;
+                                             memory_order_relaxed);
        }
-
-       XTRACE("isc_task_send");
+       c %= task->manager->workers;
 
        /*
         * We're trying hard to hold locks for as short a time as possible.
@@ -532,13 +531,14 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
        REQUIRE(taskp != NULL);
        task = (isc__task_t *)*taskp;
        REQUIRE(VALID_TASK(task));
-       if (c == -1) {
+       XTRACE("isc_task_sendanddetach");
+
+       if (c < 0) {
                c = atomic_fetch_add_explicit(&task->manager->curq, 1,
-                                             memory_order_relaxed)
-                                             % task->manager->workers;
+                                             memory_order_relaxed);
        }
+       c %= task->manager->workers;
 
-       XTRACE("isc_task_sendanddetach");
        LOCK(&task->lock);
        idle1 = task_send(task, eventp, c);
        idle2 = task_detach(task);