mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-27 14:41:28 +01:00
BUG/MEDIUM: pools: fix crash on filtered "show pools" output
The truncation of pools output that was adressed in commit 982805e6a3
("BUG/MINOR: pools: Fix the dump of pools info to deal with buffers
limitations") required to split the pools filling from dumping. However
there is a problem when a limit is passed that is lower than the number
of pools or if a pool name is specified or if pool caches are disabled,
because in this case the number of filled slots will be lower than the
initially allocated one, and empty entries will be visited either by the
sort functions when filling the entries if "byxxx" is specified, or by
the dump function after the last entry, but none of these functions was
expecting to be passed a NULL entry.
Let's just re-adjust nbpools to match the number of filled entries at
the end. Anyway the totals are calculated on the number of dumped
entries.
This must be backported to 3.2 since the fix above was backported there
as well.
This commit is contained in:
parent
d5f4872ba6
commit
ab0c97139f
@ -1374,6 +1374,9 @@ static int get_show_pools_info(struct show_pools_ctx *ctx)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* adjust the number of entries to be dumped */
|
||||||
|
ctx->nbpools = n;
|
||||||
|
|
||||||
if (by_what == 1) /* sort by name */
|
if (by_what == 1) /* sort by name */
|
||||||
qsort(ctx->pool_info, ctx->nbpools, sizeof(*ctx->pool_info), cmp_dump_pools_name);
|
qsort(ctx->pool_info, ctx->nbpools, sizeof(*ctx->pool_info), cmp_dump_pools_name);
|
||||||
else if (by_what == 2) /* sort by item size */
|
else if (by_what == 2) /* sort by item size */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user