]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: httpclient: Revisit HC request and response buffers allocation
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Jan 2022 10:14:08 +0000 (11:14 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 2 Feb 2022 15:19:16 +0000 (16:19 +0100)
commit600985df41c9777b6322f00e26dbf539f786d66f
tree32a3cdb8f82dfb6e54697c3c8682ad31ede5f526
parentdae12c7553930c086587f1fa377a3a83f2da72c2
BUG/MINOR: httpclient: Revisit HC request and response buffers allocation

For now, these buffers are allocated when the httpclient is created and
freed when it is released. Usually, we try to avoid to keep buffer allocated
if it is not required. Empty buffers should be released ASAP. Apart for
that, there is no issue with the response side because a copy is always
performed. However, for the request side, a swap with the channel's buffer
is always performed. And there is no guarantee the channel's buffer is
allocated. Thus, after the swap, the httpclient can retrieve a null
buffer. In practice, this never happens. But this may change. And it will be
required for a futur fix.

So, now, we systematically take care to have an allocated buffer when we
want to write in it. And it is released as soon as it becomes empty.

This patch should be backported to 2.5.
src/http_client.c