]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
IO loop picker fixed
authorMaria Matejka <mq@ucw.cz>
Sat, 8 Jun 2024 22:43:14 +0000 (00:43 +0200)
committerMaria Matejka <mq@ucw.cz>
Wed, 12 Jun 2024 12:48:33 +0000 (14:48 +0200)
Now if the thread finds out that it actually isn't busy,
it unsets the business status and picks something up right away.

sysdep/unix/io-loop.c

index 9d0fa138f62584172287ba96a4528426812454b1..236272a731b3f254325933312478267ac68a74a1 100644 (file)
@@ -573,6 +573,7 @@ sockets_fire(struct birdloop *loop)
  */
 
 static void bird_thread_start_event(void *_data);
+static void bird_thread_busy_update(struct bird_thread *thr, int timeout_ms);
 
 struct birdloop_pickup_group {
   DOMAIN(attrs) domain;
@@ -671,18 +672,16 @@ birdloop_take(struct birdloop_pickup_group *group)
   struct birdloop *loop = NULL;
 
   LOCK_DOMAIN(attrs, group->domain);
-  int drop =
-    this_thread->busy_active &&
-    (group->thread_busy_count < group->thread_count) &&
-    (this_thread->loop_count > 1);
-  int take = !EMPTY_LIST(group->loops);
 
-  if (drop)
+  if (this_thread->busy_active &&
+      (group->thread_busy_count < group->thread_count) &&
+      (this_thread->loop_count > 1))
   {
     THREAD_TRACE(DL_SCHEDULING, "Loop drop requested (tbc=%d, tc=%d, lc=%d)",
        group->thread_busy_count, group->thread_count, this_thread->loop_count);
     UNLOCK_DOMAIN(attrs, group->domain);
 
+    int dropped = 0;
     node *n;
     WALK_LIST2(loop, n, this_thread->loops, n)
     {
@@ -702,15 +701,20 @@ birdloop_take(struct birdloop_pickup_group *group)
        LOCK_DOMAIN(attrs, group->domain);
        bird_thread_pickup_next(group);
        UNLOCK_DOMAIN(attrs, group->domain);
+       dropped = 1;
        break;
       }
       birdloop_leave(loop);
     }
 
-    return;
+    if (dropped)
+      return;
+
+    bird_thread_busy_update(this_thread, -1);
+    LOCK_DOMAIN(attrs, group->domain);
   }
 
-  if (take)
+  if (!EMPTY_LIST(group->loops))
   {
     THREAD_TRACE(DL_SCHEDULING, "Loop take requested");