From: Willy Tarreau Date: Wed, 14 Nov 2018 15:58:52 +0000 (+0100) Subject: MEDIUM: stream-int: use si_rx_shut_blk() to indicate the SI is closed X-Git-Tag: v1.9-dev7~91 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=abb5d4202ffa4bc272bc761cf5d3919a45194155;p=thirdparty%2Fhaproxy.git MEDIUM: stream-int: use si_rx_shut_blk() to indicate the SI is closed 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. --- diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index c726f87fa8..e7293d747b 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -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) { diff --git a/src/stream_interface.c b/src/stream_interface.c index 4e63ed2404..df2adb3aa1 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -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;