BUG/MEDIUM: httpclient: Throw an error if an lua httpclient instance is reused
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 May 2025 16:35:30 +0000 (18:35 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Jun 2025 14:22:13 +0000 (16:22 +0200)
commit39c8ba33f9a452ffa35f151efe2c7abbfdc16419
treed35bd2c34da27fa63a92e9599d1510d82837b7d3
parentc57aab7218dbb0c5e20733562ed921d6eeaf66cd
BUG/MEDIUM: httpclient: Throw an error if an lua httpclient instance is reused

It is not expected/supported to reuse an httpclient instance to process
several requests. A new instance must be created for each request. However,
in lua, there is nothing to prevent a user to create an httpclient object
and use it in a loop to process requests.

That's unfortunate because this will apparently work, the requests will be
sent and a response will be received and processed. However internally some
ressources will be allocated and never released. When the next response is
processed, the ressources allocated for the previous one are definitively
lost.

In this patch we take care to check that the httpclient object was never
used when a request is sent from a lua script by checking
HTTPCLIENT_FS_STARTED flags. This flag is set when a httpclient applet is
spawned to process a request and never removed after that. In lua, the
httpclient applet is created when the request is sent. So, it is the right
place to do this test.

This patch should fix the issue #2986. It should be backported as far as
2.6.

(cherry picked from commit 50fca6f0b7ebee94b5ebe402e37af9d7d945fe64)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit c0d42ff115438f7a2ee83388be87b439d034e79e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/hlua.c