]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: applet: Check room needed to unblock opposite SC when data was consumed
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 09:39:03 +0000 (11:39 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 13:44:23 +0000 (15:44 +0200)
If the opposite SC is waiting for a minimum free space to receive more data,
it is only unblock is the condition is respected. 0 is a special cases where
the opposite SC is always unblocked.

src/applet.c

index 8e9e515ff0f891bb8486f7f8389ec052e3454c31..91f9cca5f49cc26be5cdcdbb03de709e6072c07a 100644 (file)
@@ -400,7 +400,7 @@ int appctx_buf_available(void *arg)
 struct task *task_run_applet(struct task *t, void *context, unsigned int state)
 {
        struct appctx *app = context;
-       struct stconn *sc;
+       struct stconn *sc, *sco;
        unsigned int rate;
        size_t count;
 
@@ -428,6 +428,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
        }
 
        sc = appctx_sc(app);
+       sco = sc_opposite(sc);
 
        /* We always pretend the applet can't get and doesn't want to
         * put, it's up to it to change this if needed. This ensures
@@ -455,8 +456,11 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
         */
        if (count != co_data(sc_oc(sc))) {
                sc_oc(sc)->flags |= CF_WRITE_EVENT | CF_WROTE_DATA;
-               sc_have_room(sc_opposite(sc));
+               if (sco->room_needed < 0 || channel_recv_max(sc_oc(sc)) >= sco->room_needed)
+                       sc_have_room(sco);
        }
+       else if (!sco->room_needed)
+               sc_have_room(sco);
 
        if (sc_ic(sc)->flags & CF_READ_EVENT)
                sc_ep_report_read_activity(sc);