]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Loop run waits until pingers finish mq-wip-rcu-sync-deadlock
authorMaria Matejka <mq@ucw.cz>
Fri, 17 May 2024 21:21:38 +0000 (23:21 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 17 May 2024 21:21:38 +0000 (23:21 +0200)
This ensures that if somebody passes an event to a loop which
has just started executing, then the event gets picked up. Otherwise
there is a race condition causing stray events pending in queue
but without the ping (because the run actually finishes too fast
to pickup the later events).

sysdep/unix/io-loop.c

index be79946c6baf4b242e5f15ec49e5f215dc4a383c..f777d210eb3c2a5b20171386fa4a28f4b1d65925 100644 (file)
@@ -1449,6 +1449,17 @@ birdloop_run(void *_loop)
   account_to(&loop->locking);
   birdloop_enter(loop);
   this_birdloop = loop;
+
+  /* Wait until pingers end to wait for all events to actually arrive */
+  for (u32 ltt;
+      ltt = atomic_load_explicit(&loop->thread_transition, memory_order_acquire);
+      )
+  {
+    ASSERT_DIE(ltt == LTT_PING);
+    birdloop_yield();
+  }
+
+  /* Now we can actually do some work */
   u64 dif = account_to(&loop->working);
 
   if (dif > this_thread->max_loop_time_ns)