]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: hlua: Don't set EOM flag on an empty HTX message in HTTP applet
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 Apr 2022 08:07:18 +0000 (10:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 Apr 2022 09:04:07 +0000 (11:04 +0200)
In a lua HTTP applet, when the script is finished, we must be sure to not
set the EOM on an empty message. Otherwise, because there is no data to
send, the mux on the client side may miss the end of the message and
consider any shutdown as an abort.

See "UG/MEDIUM: stats: Be sure to never set EOM flag on an empty HTX
message" for details.

This patch must be backported as far as 2.4. On previous version there is
still the EOM HTX block.

src/hlua.c

index ea75b16eb5c24fa00aa55232a2f322a2902eab0f..ee48323d55551eab4b8215f7086206b92deffd23 100644 (file)
@@ -9567,7 +9567,19 @@ void hlua_applet_http_fct(struct appctx *ctx)
                if (!(ctx->ctx.hlua_apphttp.flags & APPLET_HDR_SENT))
                        goto error;
 
-               /* no more data are expected. Don't add TLR because mux-h1 will take care of it */
+               /* no more data are expected. If the response buffer is empty
+                * for a chunked message, be sure to add something (EOT block in
+                * this case) to have something to send. It is important to be
+                * sure the EOM flags will be handled by the endpoint.
+                */
+               if (htx_is_empty(res_htx) && (strm->txn->rsp.flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN)) == HTTP_MSGF_XFER_LEN) {
+                       if (!htx_add_endof(res_htx, HTX_BLK_EOT)) {
+                               si_rx_room_blk(si);
+                               goto out;
+                       }
+                       channel_add_input(res, 1);
+               }
+
                res_htx->flags |= HTX_FL_EOM;
                si->cs->flags |= CS_FL_EOI;
                res->flags |= CF_EOI;