/* 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();
}
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];
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();
}