]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed loop movement to not collide on LTT_MOVE
authorMaria Matejka <mq@ucw.cz>
Fri, 5 May 2023 14:08:50 +0000 (16:08 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 7 May 2023 14:58:56 +0000 (16:58 +0200)
sysdep/unix/io-loop.c

index 594709d4ee488f26b580ee84f4dc773f49b45021..a923267ccdb8fa5e0aaa4110ffa14c6ce02f3ecf 100644 (file)
@@ -355,7 +355,7 @@ birdloop_try_ping(struct birdloop *loop, u32 ltt)
     return 1;
   }
 
-  /* Do the real ping */
+  /* Do the real ping of Meta or Main */
   LOOP_TRACE(loop, "sending pipe ping");
   wakeup_do_kick(loop->thread);
   return 0;
@@ -617,6 +617,7 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
   u32 ltt = atomic_fetch_or_explicit(&loop->thread_transition, LTT_MOVE, memory_order_acq_rel);
   ASSERT_DIE((ltt & LTT_MOVE) == 0);
 
+  /* Wait until all previously started pings end */
   while (ltt & LTT_PING)
   {
     birdloop_yield();
@@ -625,9 +626,22 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
   }
   /* Now we are free of running pings */
 
+  if (!thr)
+  {
+    /* Unschedule from Meta */
+    ev_postpone(&loop->event);
+    tm_stop(&loop->timer);
+
+    /* Request local socket reload */
+    this_thread->sock_changed = 1;
+  }
+
   /* Update the thread value */
   loop->thread = thr;
 
+  /* Allow pings */
+  atomic_fetch_and_explicit(&loop->thread_transition, ~LTT_MOVE, memory_order_acq_rel);
+
   /* Put into appropriate lists */
   if (thr)
   {
@@ -637,21 +651,11 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
   }
   else
   {
-    /* Unschedule from Meta */
-    ev_postpone(&loop->event);
-    tm_stop(&loop->timer);
-
-    /* Request local socket reload */
-    this_thread->sock_changed = 1;
-
     /* Put into pickup list */
     LOCK_DOMAIN(resource, group->domain);
     add_tail(&group->loops, &loop->n);
     UNLOCK_DOMAIN(resource, group->domain);
   }
-
-  /* Allow pings */
-  atomic_fetch_and_explicit(&loop->thread_transition, ~LTT_MOVE, memory_order_acq_rel);
 }
 
 static void
@@ -878,6 +882,7 @@ poll_retry:;
       wakeup_drain(thr);
     }
 
+    /* Unset ping information for Meta */
     atomic_fetch_and_explicit(&thr->meta->thread_transition, ~LTT_PING, memory_order_acq_rel);
 
     /* Schedule loops with active sockets */