0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-19 11:55:21 +00:00

Flock: Fixed the exposed process mainloop

This commit is contained in:
Maria Matejka 2024-09-10 11:27:28 +02:00
parent f0c093ecc0
commit d70cbb804f
2 changed files with 13 additions and 33 deletions

View 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();
}

View 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();
}