]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Flock: Fixed the exposed process mainloop
authorMaria Matejka <mq@ucw.cz>
Tue, 10 Sep 2024 09:27:28 +0000 (11:27 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 18:07:35 +0000 (19:07 +0100)
flock/flock.c
flock/hypervisor.c

index daf8dc8c5e282f2bb20142982d1dfd2827839a6c..24837720de0c8a6fc3a255dd77e6d975461d63d1 100644 (file)
@@ -251,33 +251,5 @@ main(int argc, char **argv, char **argh UNUSED)
 
   /* Wait for Godot */
   log(L_INFO "Hypervisor running");
-  while (1)
-  {
-    times_update();
-    ev_run_list(&global_event_list);
-    ev_run_list(&global_work_list);
-    ev_run_list(&main_birdloop.event_list);
-    timers_fire(&main_birdloop.time);
-
-    bool events =
-      !ev_list_empty(&global_event_list) ||
-      !ev_list_empty(&global_work_list) ||
-      !ev_list_empty(&main_birdloop.event_list);
-
-    int poll_tout = (events ? 0 : 3000); /* Time in milliseconds */
-    timer *t;
-    if (t = timers_first(&main_birdloop.time))
-    {
-      times_update();
-      int timeout = (tm_remains(t) TO_MS) + 1;
-      poll_tout = MIN(poll_tout, timeout);
-    }
-
-    struct pollfd pfd = {
-      .fd = main_birdloop.thread->wakeup.fd[0],
-      .events = POLLIN,
-    };
-
-    poll(&pfd, 1, poll_tout);
-  }
+  birdloop_minimalist_main();
 }
index a6e87b7dafb3169d5a704af13bd1ba85c0d8a3f8..26d5e45552c83311d04fe6cbe486daa3088b279f 100644 (file)
@@ -175,13 +175,14 @@ hypervisor_exposed_fork(void)
   if (e < 0)
     die("Failed to fork exposed: %m");
 
-  /* Create the communication channel (both sides at once) */
+  /* Create the communication channel (this runs twice!) */
   he.loop = birdloop_new(&root_pool, DOMAIN_ORDER(proto), 0, "Exposed interlink");
 
   birdloop_enter(he.loop);
   he.p = rp_new(birdloop_pool(he.loop), birdloop_domain(he.loop), "Exposed interlink pool");
   he.s = sk_new(he.p);
   he.s->type = SK_MAGIC;
+  /* Set the hooks and fds according to the side we are at */
   he.s->rx_hook = e ? hypervisor_exposed_parent_rx : hypervisor_exposed_child_rx;
   he.s->err_hook = e ? hypervisor_exposed_parent_err : hypervisor_exposed_child_err;
   he.s->fd = fds[!!e];
@@ -198,7 +199,14 @@ hypervisor_exposed_fork(void)
   if (e)
     return;
 
-  /* Child-only */
-  while (1)
-    pause();
+  /**
+   * Child only
+   **/
+
+  /* Run worker threads */
+  struct thread_config tc = {};
+  bird_thread_commit(&tc);
+
+  /* Wait for Godot */
+  birdloop_minimalist_main();
 }