MINOR: cli: improve forward compatibility for show fd

The "<tgid>/" and "/" wildcard forms previously produced no output.
This isn't a bug since they are new, but a script written for future
versions (where the slash form will gain per-thread-group semantics)
would not work the same on 3.4. Make them produce output by dropping
the redundant ctx->fd = -1 wildcard sentinel; also tighten tgid
validation to reject values <= 0.
This commit is contained in:
Maxime Henrion 2026-05-08 10:30:30 -04:00 committed by Olivier Houchard
parent f9e9ab8c90
commit 4f9b8574d2

View File

@ -1879,28 +1879,26 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx,
/* We allow the forms "<tgid>/" and "/<fd>" where the missing
* value is considered a wildcard. So the first form means
* "show me all the fds belonging to <tgid>", while the second
* one means "show the fd <fd> for each thread group".
* one means "show the fd <fd> for each thread group". Note
* that the tgid is parsed but ignored for now - this code
* will require changes once we split fd tables.
*/
if (c == args[2])
if (c == args[2]) {
ctx->tgid = -1;
else
} else {
ctx->tgid = atoi(args[2]);
if (ctx->tgid > MAX_TGROUPS)
return cli_err(appctx, "Invalid TGID.\n");
if (ctx->tgid <= 0 || ctx->tgid > MAX_TGROUPS)
return cli_err(appctx, "Invalid TGID.\n");
}
c++;
if (!*c)
ctx->fd = -1;
else
if (*c) {
ctx->fd = atoi(c);
ctx->show_one = 1;
}
} 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;