]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: promex: Be sure to never set EOM flag on an empty HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 Apr 2022 08:19:46 +0000 (10:19 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 7 Apr 2022 09:04:07 +0000 (11:04 +0200)
It is the same bug than "BUG/MEDIUM: stats: Be sure to never set EOM flag on
an empty HTX message". We must be sure to set the EOM flag on a non empyt
message to be sure the mux on the client will properly handle
shutdowns. Otherwise, it may miss the end of the message and considers any
shutdown as an abort.

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

addons/promex/service-prometheus.c

index 06eb1eea9b2f7fa76d3d8238f680bc5bc518af41..48bf1602d6a9c2f9e858ae5455f8966e1b9e246d 100644 (file)
@@ -1509,8 +1509,20 @@ static void promex_appctx_handle_io(struct appctx *appctx)
                        /* fall through */
 
                case PROMEX_ST_DONE:
-                       /* no more data are expected. Don't add TLR because mux-h1 will take care of it */
-                       res_htx->flags |= HTX_FL_EOM;
+                       /* no more data are expected. If the response buffer is
+                        * empty, 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)) {
+                               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;
                        appctx->st0 = PROMEX_ST_END;