From da554b7ef7dbdcce1056feb6aeb51cf17d185191 Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Mon, 27 Apr 2026 09:26:55 -0400 Subject: [PATCH] MINOR: cli: allow specifying a tgid with show fd This will become useful when we implement using unshare() to split fd tables per thread group. For now, the tgid is parsed but completely ignored. --- src/cli.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/cli.c b/src/cli.c index cab99aa33..55cd8dab8 100644 --- a/src/cli.c +++ b/src/cli.c @@ -106,7 +106,8 @@ struct show_env_ctx { #define CLI_SHOWFD_F_ANY 0x0000003f /* any type */ struct show_fd_ctx { - int fd; /* first FD to show */ + int fd; /* first FD to show, -1=wildcard */ + int tgid; /* 0=unspecified, -1=wildcard, >0=specific tgid */ int show_one; /* stop after showing one FD */ uint show_mask; /* CLI_SHOWFD_F_xxx */ }; @@ -1873,8 +1874,33 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx, ctx->show_mask = CLI_SHOWFD_F_ANY; if (*args[arg]) { - ctx->fd = atoi(args[2]); - ctx->show_one = 1; + c = strchr(args[2], '/'); + if (c) { + /* We allow the forms "/" and "/" where the missing + * value is considered a wildcard. So the first form means + * "show me all the fds belonging to ", while the second + * one means "show the fd for each thread group". + */ + if (c == args[2]) + ctx->tgid = -1; + else + ctx->tgid = atoi(args[2]); + if (ctx->tgid > MAX_TGROUPS) + return cli_err(appctx, "Invalid TGID.\n"); + c++; + if (!*c) + ctx->fd = -1; + else + ctx->fd = atoi(c); + } else { + ctx->fd = atoi(args[2]); + } + + /* This will need to change when we implement split fd tables. We + * completely ignore the tgid for now. + */ + if (ctx->fd != -1) + ctx->show_one = 1; } return 0;