mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-05 08:31:53 +00:00
Flock: Fixed the exposed process mainloop
This commit is contained in:
parent
7affe9296e
commit
cafd775a41
@ -251,33 +251,5 @@ main(int argc, char **argv, char **argh UNUSED)
|
|||||||
|
|
||||||
/* Wait for Godot */
|
/* Wait for Godot */
|
||||||
log(L_INFO "Hypervisor running");
|
log(L_INFO "Hypervisor running");
|
||||||
while (1)
|
birdloop_minimalist_main();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -175,13 +175,14 @@ hypervisor_exposed_fork(void)
|
|||||||
if (e < 0)
|
if (e < 0)
|
||||||
die("Failed to fork exposed: %m");
|
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");
|
he.loop = birdloop_new(&root_pool, DOMAIN_ORDER(proto), 0, "Exposed interlink");
|
||||||
|
|
||||||
birdloop_enter(he.loop);
|
birdloop_enter(he.loop);
|
||||||
he.p = rp_new(birdloop_pool(he.loop), birdloop_domain(he.loop), "Exposed interlink pool");
|
he.p = rp_new(birdloop_pool(he.loop), birdloop_domain(he.loop), "Exposed interlink pool");
|
||||||
he.s = sk_new(he.p);
|
he.s = sk_new(he.p);
|
||||||
he.s->type = SK_MAGIC;
|
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->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->err_hook = e ? hypervisor_exposed_parent_err : hypervisor_exposed_child_err;
|
||||||
he.s->fd = fds[!!e];
|
he.s->fd = fds[!!e];
|
||||||
@ -198,7 +199,14 @@ hypervisor_exposed_fork(void)
|
|||||||
if (e)
|
if (e)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Child-only */
|
/**
|
||||||
while (1)
|
* Child only
|
||||||
pause();
|
**/
|
||||||
|
|
||||||
|
/* Run worker threads */
|
||||||
|
struct thread_config tc = {};
|
||||||
|
bird_thread_commit(&tc);
|
||||||
|
|
||||||
|
/* Wait for Godot */
|
||||||
|
birdloop_minimalist_main();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user