]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: Report the current tgid in "debug dev fd"
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 29 Jul 2026 21:28:48 +0000 (23:28 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 30 Jul 2026 11:35:22 +0000 (13:35 +0200)
"debug dev fd" scans the FDs of the process as the calling thread sees
them, and reports the ones unknown to fdtab. With per-thread-group FD
tables, both that scan and the fdtab lookups only reflect the view of
the calling thread's group: the same command may report different FDs
depending on the thread that serves it. Let's print the current tgid in
a header line so the output states which view it shows.

src/debug.c

index 47c70437a428a50ffbd88a1db93b516854b59240..6e85ab3d5e3c0fa0eff3e068913928f8979a4a74 100644 (file)
@@ -1970,6 +1970,7 @@ static int debug_parse_cli_trace(char **args, char *payload, struct appctx *appc
 /* CLI state for "debug dev fd" */
 struct dev_fd_ctx {
        int start_fd;
+       int hdr_done;
 };
 
 /* CLI parser for the "debug dev fd" command. The current FD to restart from is
@@ -2006,6 +2007,19 @@ static int debug_iohandler_fd(struct appctx *appctx)
 
        thread_isolate();
 
+       /* thread groups may have their own FD tables, and even their own view
+        * of the process's FDs, so let's always indicate which group the dump
+        * is seen from.
+        */
+       if (!ctx->hdr_done) {
+               chunk_printf(&trash, "# current tgid: %u\n", tgid);
+               if (applet_putchk(appctx, &trash) == -1) {
+                       ret = 0;
+                       goto leave;
+               }
+               ctx->hdr_done = 1;
+       }
+
        /* we have two inner loops here, one for the proxy, the other one for
         * the buffer.
         */
@@ -2163,6 +2177,7 @@ static int debug_iohandler_fd(struct appctx *appctx)
                }
        }
 
+ leave:
        thread_release();
        return ret;
 }