]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Flock: nicer logging (setting distinct thread ids)
authorMaria Matejka <mq@ucw.cz>
Thu, 19 Sep 2024 07:28:27 +0000 (09:28 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 18:07:35 +0000 (19:07 +0100)
flock/container.c
flock/hypervisor.c

index 25af41ea4d6fb00e04e1a42d4eb24e8e37924aea..9159bac3369b287e72489acc1eb0f8529be96cd4 100644 (file)
@@ -26,6 +26,8 @@ container_mainloop(int fd)
   }
 }
 
+static uint container_counter = 0;
+
 static void
 container_start(void)
 {
@@ -40,15 +42,19 @@ container_start(void)
 
   pid_t pid = fork();
   if (pid < 0)
-    die("Failed to fork exposed: %m");
+    die("Failed to fork container: %m");
 
   if (!pid)
   {
     close(fds[0]);
+    ASSERT_DIE(container_counter < 0x6000);
+    this_thread_id -= (container_counter << 1) + 0x3000 ;
     container_mainloop(fds[1]); /* this never returns */
     bug("container_mainloop has returned");
   }
 
+  container_counter -= 2;
+
   close(fds[1]);
 
   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);
 
-  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);
   skl->type = SK_MAGIC;
   skl->rx_hook = hypervisor_container_rx;
@@ -483,7 +486,7 @@ hypervisor_container_fork(void)
 
   e = fork();
   if (e < 0)
-    die("Failed to fork exposed: %m");
+    die("Failed to fork container forker: %m");
 
   if (e)
   {
@@ -512,6 +515,8 @@ hypervisor_container_fork(void)
   close(fds[0]);
   container_forker_fd = fds[1];
 
+  this_thread_id |= 0xf000;
+
   /* initialize the forker */
   ctx->lp = lp_new(&root_pool);
   ctx->type = 0xff;
@@ -522,6 +527,9 @@ hypervisor_container_fork(void)
     byte buf[4096];
 
     ssize_t rx = read(fds[1], buf, sizeof buf);
+
+    times_update();
+
     if (rx == 0)
     {
       log(L_INFO "Container forker socket closed, exiting");
index 9df38cdc62f0414fedd521c2084b5d1a36994794..561f95446463413d000832e1e91253ac98728d95 100644 (file)
@@ -370,6 +370,8 @@ hypervisor_exposed_fork(void)
   if (e < 0)
     die("Failed to fork exposed: %m");
 
+  if (!e) this_thread_id |= 0xe000;
+
   /* Create the communication channel (this runs twice!) */
   he.loop = birdloop_new(&root_pool, DOMAIN_ORDER(proto), 0, "Exposed interlink");