]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: use si_rx_shut_blk() to indicate the SI is closed
authorWilly Tarreau <w@1wt.eu>
Wed, 14 Nov 2018 15:58:52 +0000 (16:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Nov 2018 20:41:49 +0000 (21:41 +0100)
Till now we were using si_done_put() upon shutr, but these flags could
be reset upon next activity. Now let's switch to SI_FL_RXBLK_SHUT which
doesn't go away. It's also set in stream_int_update() in case a shutr
condition is detected.

The now unused si_done_put() was removed.

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

index c726f87fa81ece6c072ecb5e604e7f45b4f4d7d8..e7293d747b874d234643aa8912dad8b742f05ba6 100644 (file)
@@ -266,13 +266,6 @@ static inline void si_cant_put(struct stream_interface *si)
        si->flags &= ~SI_FL_RX_WAIT_EP;
 }
 
-/* Report that a stream interface won't put any more data into the input buffer */
-static inline void si_done_put(struct stream_interface *si)
-{
-       si->flags &= ~SI_FL_RXBLK_ROOM;
-       si->flags |=  SI_FL_RX_WAIT_EP;
-}
-
 /* The stream interface announces it is ready to try to deliver more data to the input buffer */
 static inline void si_rx_endp_more(struct stream_interface *si)
 {
@@ -301,6 +294,15 @@ static inline void si_rx_buff_blk(struct stream_interface *si)
        si->flags |=  SI_FL_RXBLK_BUFF;
 }
 
+/* The stream interface announces it will never put new data into the input
+ * buffer and that it's not waiting for its endpoint to deliver anything else.
+ * This function obviously doesn't have a _rdy equivalent.
+ */
+static inline void si_rx_shut_blk(struct stream_interface *si)
+{
+       si->flags |=  SI_FL_RXBLK_SHUT;
+}
+
 /* Returns non-zero if the stream interface's Rx path is blocked */
 static inline int si_tx_blocked(const struct stream_interface *si)
 {
index 4e63ed2404b82df115034ebbed17ae372689d38b..df2adb3aa1fb144ca55d517a604ac9ad59dacc8e 100644 (file)
@@ -157,12 +157,12 @@ static void stream_int_shutr(struct stream_interface *si)
 {
        struct channel *ic = si_ic(si);
 
+       si_rx_shut_blk(si);
        ic->flags &= ~CF_SHUTR_NOW;
        if (ic->flags & CF_SHUTR)
                return;
        ic->flags |= CF_SHUTR;
        ic->rex = TICK_ETERNITY;
-       si_done_put(si);
 
        if (si->state != SI_ST_EST && si->state != SI_ST_CON)
                return;
@@ -225,8 +225,8 @@ static void stream_int_shutw(struct stream_interface *si)
                /* Note that none of these states may happen with applets */
                si->state = SI_ST_DIS;
        default:
-               si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
-               si->flags |= SI_FL_RX_WAIT_EP;
+               si->flags &= ~SI_FL_NOLINGER;
+               si_rx_shut_blk(si);
                ic->flags &= ~CF_SHUTR_NOW;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;
@@ -767,6 +767,8 @@ void stream_int_update(struct stream_interface *si)
                                ic->rex = tick_add_ifset(now_ms, ic->rto);
                }
        }
+       else
+               si_rx_shut_blk(si);
 
        if (!(oc->flags & CF_SHUTW)) {
                /* Write not closed, update FD status and timeout for writes */
@@ -886,12 +888,12 @@ static void stream_int_shutr_conn(struct stream_interface *si)
        struct conn_stream *cs = __objt_cs(si->end);
        struct channel *ic = si_ic(si);
 
+       si_rx_shut_blk(si);
        ic->flags &= ~CF_SHUTR_NOW;
        if (ic->flags & CF_SHUTR)
                return;
        ic->flags |= CF_SHUTR;
        ic->rex = TICK_ETERNITY;
-       si_done_put(si);
 
        if (si->state != SI_ST_EST && si->state != SI_ST_CON)
                return;
@@ -984,8 +986,8 @@ static void stream_int_shutw_conn(struct stream_interface *si)
                si->state = SI_ST_DIS;
                /* fall through */
        default:
-               si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
-               si->flags |=  SI_FL_RX_WAIT_EP;
+               si->flags &= ~SI_FL_NOLINGER;
+               si_rx_shut_blk(si);
                ic->flags &= ~CF_SHUTR_NOW;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;
@@ -1369,12 +1371,12 @@ void stream_sock_read0(struct stream_interface *si)
        struct channel *ic = si_ic(si);
        struct channel *oc = si_oc(si);
 
+       si_rx_shut_blk(si);
        ic->flags &= ~CF_SHUTR_NOW;
        if (ic->flags & CF_SHUTR)
                return;
        ic->flags |= CF_SHUTR;
        ic->rex = TICK_ETERNITY;
-       si_done_put(si);
 
        if (si->state != SI_ST_EST && si->state != SI_ST_CON)
                return;
@@ -1454,12 +1456,12 @@ static void stream_int_shutr_applet(struct stream_interface *si)
 {
        struct channel *ic = si_ic(si);
 
+       si_rx_shut_blk(si);
        ic->flags &= ~CF_SHUTR_NOW;
        if (ic->flags & CF_SHUTR)
                return;
        ic->flags |= CF_SHUTR;
        ic->rex = TICK_ETERNITY;
-       si_done_put(si);
 
        /* Note: on shutr, we don't call the applet */
 
@@ -1525,8 +1527,8 @@ static void stream_int_shutw_applet(struct stream_interface *si)
                si_applet_release(si);
                si->state = SI_ST_DIS;
        default:
-               si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
-               si->flags |= SI_FL_RX_WAIT_EP;
+               si->flags &= ~SI_FL_NOLINGER;
+               si_rx_shut_blk(si);
                ic->flags &= ~CF_SHUTR_NOW;
                ic->flags |= CF_SHUTR;
                ic->rex = TICK_ETERNITY;