]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: make SI_FL_WANT_PUT reflect CF_DONT_READ
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Nov 2018 14:07:35 +0000 (15:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2018 09:18:37 +0000 (10:18 +0100)
When CF_DONT_READ is set, till now we used to set SI_FL_WAIT_ROOM, which
is not appropriate since it would lose the subscribe status. Instead let's
clear SI_FL_WANT_PUT (just like applets do), and set the flag only when
CF_DONT_READ is cleared.

We have to do this in stream_int_update(), and in si_cs_io_cb() after
returning from si_cs_recv() since it would be a bit invasive to hack
this one for now. It must not be done in stream_int_notify() otherwise
it would re-enable blocked applets.

Last, when si_chk_rcv() is called, it immediately clears the flag before
calling ->chk_rcv() so that we are not tempted to uselessly loop on the
same call until the receive function is called. This is the same principle
as what is done with the applet scheduler.

include/proto/stream_interface.h
src/stream_interface.c

index 1a70536addee970443ffc4da66fcba28a45fffd4..c0f7cdae30ac1d00cb51172606a58c7648636a9c 100644 (file)
@@ -399,6 +399,7 @@ static inline void si_chk_rcv(struct stream_interface *si)
        if (si->state > SI_ST_EST)
                return;
 
+       si->flags &= ~SI_FL_WANT_PUT;
        si->ops->chk_rcv(si);
 }
 
index adbdfa8bfc46feaf91a4d021d4268f59fb151169..3372fc2a61b45f6bf8963fed11d9f9fcf55f2a0f 100644 (file)
@@ -248,9 +248,6 @@ static void stream_int_chk_rcv(struct stream_interface *si)
                __FUNCTION__,
                si, si->state, ic->flags, si_oc(si)->flags);
 
-       if (ic->flags & (CF_SHUTR|CF_DONT_READ))
-               return;
-
        if (!channel_may_recv(ic) || ic->pipe) {
                /* stop reading */
                si->flags |= SI_FL_WAIT_ROOM;
@@ -728,8 +725,11 @@ struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned short state)
 
        if (!(si->wait_event.wait_reason & SUB_CAN_SEND) && co_data(si_oc(si)))
                ret = si_cs_send(cs);
-       if (!(si->wait_event.wait_reason & SUB_CAN_RECV))
+       if (!(si->wait_event.wait_reason & SUB_CAN_RECV)) {
                ret |= si_cs_recv(cs);
+               if (!(si_ic(si)->flags & (CF_SHUTR|CF_DONT_READ)))
+                       si->flags |= SI_FL_WANT_PUT;
+       }
        if (ret != 0)
                si_cs_process(cs);
 
@@ -750,6 +750,9 @@ void stream_int_update(struct stream_interface *si)
        struct channel *oc = si_oc(si);
 
        if (!(ic->flags & CF_SHUTR)) {
+               if (!(ic->flags & CF_DONT_READ))
+                       si_want_put(si);
+
                /* Read not closed, update FD status and timeout for reads */
                if ((ic->flags & CF_DONT_READ) || !channel_may_recv(ic)) {
                        /* stop reading */
@@ -960,10 +963,7 @@ static void stream_int_chk_rcv_conn(struct stream_interface *si)
 {
        struct channel *ic = si_ic(si);
 
-       if (ic->flags & CF_SHUTR)
-               return;
-
-       if ((ic->flags & CF_DONT_READ) || !channel_may_recv(ic)) {
+       if (!channel_may_recv(ic)) {
                /* stop reading */
                si->flags |= SI_FL_WAIT_ROOM;
        }
@@ -1498,9 +1498,6 @@ static void stream_int_chk_rcv_applet(struct stream_interface *si)
                __FUNCTION__,
                si, si->state, ic->flags, si_oc(si)->flags);
 
-       if (ic->flags & (CF_SHUTR|CF_DONT_READ))
-               return;
-
        if (channel_may_recv(ic) && !ic->pipe) {
                /* (re)start reading */
                appctx_wakeup(si_appctx(si));