]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: http-client: Eat output data when waiting for appctx shutdown
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Apr 2023 05:38:34 +0000 (07:38 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Apr 2023 05:43:26 +0000 (07:43 +0200)
When the http-client applet is executed while a shut is pending, the
remaining output data must always be consumed. Otherwise, this can prevent
the stream to exit, leading to a spinning loop on the applet.

It is 2.8-specific. No backport needed.

src/http_client.c

index 29db28f028b77a2382743cfc9f0a23fa6453b3c6..c2dec8bbe8045f32cad010d8cf7a100d57da5ed0 100644 (file)
@@ -700,9 +700,14 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
        uint32_t sz;
        int ret;
 
-       if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW))))
+       if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW)))) {
+               if (co_data(res)) {
+                       htx = htx_from_buf(&res->buf);
+                       co_htx_skip(res, htx, co_data(res));
+                       htx_to_buf(htx, &res->buf);
+               }
                goto out;
-
+       }
        /* The IO handler could be called after the release, so we need to
         * check if hc is still there to run the IO handler */
        if (!hc)