BUG/MINOR: htx: add two missing HTX_FL_EOI and remove an unexpected one

A workaround for some difficulties encountered to anticipate end of
messages was addressed by commit 810df0614 ("MEDIUM: htx: Add a flag on
a HTX message when no more data are expected"), but there were 3 issues
in it (with minor impact):
  - the flag was mistakenly set before an EOH in Lua, which would only
    cause incomplete packets to be emitted for now but could cause
    truncated responses in the future. It's not needed to add it on
    the next EOM block as http_forward_proxy_resp() already does it.

  - one was still missing in hlua_applet_http_fct(), possibly causing
    delays on Lua services

  - one was missing in the Prometheus exporter.

All this simply shows that this mechanism is still quite fragile and
not trivial to use, especially in order to deal with the impossibility
to append the EOM, so we'll need to improve the solution in the future
and future backports should not be completely ruled out.

This fix must be backported where the patch above is backported,
typically 2.1 and later as it was required for a set of fixes.
This commit is contained in:
Willy Tarreau 2020-07-23 06:53:27 +02:00
parent 963f701f4f
commit f1ea47d896
2 changed files with 2 additions and 1 deletions

View File

@ -2518,6 +2518,7 @@ static void promex_appctx_handle_io(struct appctx *appctx)
case PROMEX_ST_DONE:
/* Don't add TLR because mux-h1 will take care of it */
res_htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(res_htx, HTX_BLK_EOM)) {
si_rx_room_blk(si);
goto out;

View File

@ -4582,7 +4582,6 @@ __LJMP static int hlua_applet_http_send_response(lua_State *L)
}
/* Finalize headers. */
htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(htx, HTX_BLK_EOH)) {
hlua_pusherror(L, "Lua applet http '%s': Failed create the response.\n",
appctx->appctx->rule->arg.hlua_rule->fcn.name);
@ -7122,6 +7121,7 @@ void hlua_applet_http_fct(struct appctx *ctx)
goto error;
/* Don't add TLR because mux-h1 will take care of it */
res_htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(res_htx, HTX_BLK_EOM)) {
si_rx_room_blk(si);
goto out;