mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-02-05 07:40:01 +00:00
Flock: nicer logging (setting distinct thread ids)
This commit is contained in:
parent
3406590533
commit
37eda0276c
@ -26,6 +26,8 @@ container_mainloop(int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint container_counter = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
container_start(void)
|
container_start(void)
|
||||||
{
|
{
|
||||||
@ -40,15 +42,19 @@ container_start(void)
|
|||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
die("Failed to fork exposed: %m");
|
die("Failed to fork container: %m");
|
||||||
|
|
||||||
if (!pid)
|
if (!pid)
|
||||||
{
|
{
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
|
ASSERT_DIE(container_counter < 0x6000);
|
||||||
|
this_thread_id -= (container_counter << 1) + 0x3000 ;
|
||||||
container_mainloop(fds[1]); /* this never returns */
|
container_mainloop(fds[1]); /* this never returns */
|
||||||
bug("container_mainloop has returned");
|
bug("container_mainloop has returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container_counter -= 2;
|
||||||
|
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
|
|
||||||
byte outbuf[128];
|
byte outbuf[128];
|
||||||
@ -135,9 +141,6 @@ hypervisor_container_forker_rx(sock *sk, uint _sz UNUSED)
|
|||||||
|
|
||||||
log(L_INFO "Machine started with PID %d", pid);
|
log(L_INFO "Machine started with PID %d", pid);
|
||||||
|
|
||||||
u16 port = ntohs(*((u16 *) &buf[3]));
|
|
||||||
log(L_INFO "RX %d bytes, fd %d, port %u", e, sfd, port);
|
|
||||||
|
|
||||||
sock *skl = sk_new(sk->pool);
|
sock *skl = sk_new(sk->pool);
|
||||||
skl->type = SK_MAGIC;
|
skl->type = SK_MAGIC;
|
||||||
skl->rx_hook = hypervisor_container_rx;
|
skl->rx_hook = hypervisor_container_rx;
|
||||||
@ -483,7 +486,7 @@ hypervisor_container_fork(void)
|
|||||||
|
|
||||||
e = fork();
|
e = fork();
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
die("Failed to fork exposed: %m");
|
die("Failed to fork container forker: %m");
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
@ -512,6 +515,8 @@ hypervisor_container_fork(void)
|
|||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
container_forker_fd = fds[1];
|
container_forker_fd = fds[1];
|
||||||
|
|
||||||
|
this_thread_id |= 0xf000;
|
||||||
|
|
||||||
/* initialize the forker */
|
/* initialize the forker */
|
||||||
ctx->lp = lp_new(&root_pool);
|
ctx->lp = lp_new(&root_pool);
|
||||||
ctx->type = 0xff;
|
ctx->type = 0xff;
|
||||||
@ -522,6 +527,9 @@ hypervisor_container_fork(void)
|
|||||||
byte buf[4096];
|
byte buf[4096];
|
||||||
|
|
||||||
ssize_t rx = read(fds[1], buf, sizeof buf);
|
ssize_t rx = read(fds[1], buf, sizeof buf);
|
||||||
|
|
||||||
|
times_update();
|
||||||
|
|
||||||
if (rx == 0)
|
if (rx == 0)
|
||||||
{
|
{
|
||||||
log(L_INFO "Container forker socket closed, exiting");
|
log(L_INFO "Container forker socket closed, exiting");
|
||||||
|
@ -370,6 +370,8 @@ hypervisor_exposed_fork(void)
|
|||||||
if (e < 0)
|
if (e < 0)
|
||||||
die("Failed to fork exposed: %m");
|
die("Failed to fork exposed: %m");
|
||||||
|
|
||||||
|
if (!e) this_thread_id |= 0xe000;
|
||||||
|
|
||||||
/* Create the communication channel (this runs twice!) */
|
/* 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");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user