From: Olivier Houchard Date: Wed, 29 Jul 2026 21:28:48 +0000 (+0200) Subject: MINOR: debug: Report the current tgid in "debug dev fd" X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=1b801ca6f7dfc977096dbc5833d166842aaf3d27;p=thirdparty%2Fhaproxy.git MINOR: debug: Report the current tgid in "debug dev fd" "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. --- diff --git a/src/debug.c b/src/debug.c index 47c70437a..6e85ab3d5 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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; }