BUG/MEDIUM: lua: In some case, the return of sample-fetche is ignored
authorThierry FOURNIER / OZON.IO <thierry.fournier@ozon.io>
Fri, 18 Nov 2016 18:06:21 +0000 (19:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Nov 2016 23:29:19 +0000 (00:29 +0100)
commit8dc7316a6fa8cc6f3a60456376c8a13a6902a5be
tree9553860a32aef77340896cf49985797c257ea526
parent2fe1b921639fd152092cead0fe0398ef0b15c5a3
BUG/MEDIUM: lua: In some case, the return of sample-fetche is ignored

When:

 - A Lua action return data and close the channel. The request status
   is set to HTTP_MSG_CLOSED for the request and HTTP_MSG_DONE for the
   response.

 - HAProxy sets the state HTTP_MSG_ERROR. I don't known why, because
   there are many line which sets this state.

 - A Lua sample-fetch is executed, typically for building the log
   line.

 - When the Lua sample fetch exits, a control of the data is
   executed. If HAProxy is currently parsing the request, the request
   is aborted in order to prevent a segfault or sending corrupted
   data.

This ast control is executed comparing the state HTTP_MSG_BODY. When
this state is reached, the request is parsed and no error are
possible. When the state is < than HTTP_MSG_BODY, the parser is
running.

Unfortunately, the code HTTP_MSG_ERROR is just < HTTP_MSG_BODY. When
we are in error, we want to terminate the execution of Lua without
error.

This patch changes the comparaison level.

This patch must be backported in 1.6
src/hlua.c