BUG/MINOR: stats: use proper buffer size for http dump
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 2 Feb 2023 14:03:12 +0000 (15:03 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 2 Feb 2023 16:10:11 +0000 (17:10 +0100)
commit5e7ecbec997e3112c8f1e30f9f2f2a719f6cc98e
treee598dd44a069b408c5c890e33fbcf8fab3a10aae
parent739281b3d6e24eebaf71237842e6cce0a0c9770e
BUG/MINOR: stats: use proper buffer size for http dump

In an attempt to fix GH #1873, ("BUG/MEDIUM: stats: Rely on a local trash
buffer to dump the stats") explicitly reduced output buffer size to leave
enough space for htx overhead under http context.

Github user debtsandbooze, who first reported the issue, came back to us
and said he was still able to make the http dump "hang" with the new fix.

After some tests, it became clear that htx_add_data_atonce() could fail from
time to time in stats_putchk(), even if htx was completely empty:

In http context, buffer size is maxed out at channel_htx_recv_limit().
Unfortunately, channel_htx_recv_limit() is not what we're looking for here
because limit() doesn't compute the proper htx overhead.

Using buf_room_for_htx_data() instead of channel_htx_recv_limit() to compute
max "usable" data space seems to be the last piece of work required for
the previous fix to work properly.

This should be backported everywhere the aforementioned commit is.
src/stats.c