diff --git a/flock/flock.c b/flock/flock.c index daf8dc8c..24837720 100644 --- a/flock/flock.c +++ b/flock/flock.c @@ -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(); } diff --git a/flock/hypervisor.c b/flock/hypervisor.c index a6e87b7d..26d5e455 100644 --- a/flock/hypervisor.c +++ b/flock/hypervisor.c @@ -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(); }