diff --git a/contrib/debug/flags.c b/contrib/debug/flags.c index 7ff6372cb..f8a4d03ee 100644 --- a/contrib/debug/flags.c +++ b/contrib/debug/flags.c @@ -217,7 +217,6 @@ void show_si_flags(unsigned int f) SHOW_FLAG(f, SI_FL_NOLINGER); SHOW_FLAG(f, SI_FL_NOHALF); SHOW_FLAG(f, SI_FL_SRC_ADDR); - SHOW_FLAG(f, SI_FL_WANT_PUT); SHOW_FLAG(f, SI_FL_WANT_GET); SHOW_FLAG(f, SI_FL_RXBLK_CHAN); diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 6d4638155..910077801 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -262,25 +262,27 @@ static inline int si_rx_endp_ready(const struct stream_interface *si) /* Report that a stream interface wants to put some data into the input buffer */ static inline void si_want_put(struct stream_interface *si) { - si->flags |= SI_FL_WANT_PUT; + si->flags &= ~SI_FL_RX_WAIT_EP; } /* Report that a stream interface failed to put some data into the input buffer */ static inline void si_cant_put(struct stream_interface *si) { - si->flags |= SI_FL_WANT_PUT | SI_FL_RXBLK_ROOM; + si->flags |= SI_FL_RXBLK_ROOM; + si->flags &= ~SI_FL_RX_WAIT_EP; } /* Report that a stream interface doesn't want to put data into the input buffer */ static inline void si_stop_put(struct stream_interface *si) { - si->flags &= ~SI_FL_WANT_PUT; + 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_WANT_PUT | SI_FL_RXBLK_ROOM); + si->flags &= ~SI_FL_RXBLK_ROOM; + si->flags |= SI_FL_RX_WAIT_EP; } /* Returns non-zero if the stream interface's Rx path is blocked */ @@ -387,7 +389,7 @@ static inline void si_shutw(struct stream_interface *si) } /* This is to be used after making some room available in a channel. It will - * return without doing anything if {SI_FL_WANT_PUT,SI_FL_RXBLK_ROOM} != {1,0}. + * return without doing anything if {SI_FL_RX_WAIT_EP,SI_FL_RXBLK_ROOM} != {0,0}. * It will then call ->chk_rcv() to enable receipt of new data. */ static inline void si_chk_rcv(struct stream_interface *si) @@ -395,13 +397,13 @@ static inline void si_chk_rcv(struct stream_interface *si) if (si->flags & SI_FL_RXBLK_ROOM) return; - if (!(si->flags & SI_FL_WANT_PUT)) + if (si->flags & SI_FL_RX_WAIT_EP) return; if (si->state > SI_ST_EST) return; - si->flags &= ~SI_FL_WANT_PUT; + si->flags |= SI_FL_RX_WAIT_EP; si->ops->chk_rcv(si); } diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h index 1f1716fe4..d9eeacbf0 100644 --- a/include/types/stream_interface.h +++ b/include/types/stream_interface.h @@ -72,7 +72,7 @@ enum { SI_FL_NOLINGER = 0x00000080, /* may close without lingering. One-shot. */ SI_FL_NOHALF = 0x00000100, /* no half close, close both sides at once */ SI_FL_SRC_ADDR = 0x00001000, /* get the source ip/port with getsockname */ - SI_FL_WANT_PUT = 0x00002000, /* a stream-int would like to put some data into the buffer */ + /* unused: 0x00002000 */ SI_FL_WANT_GET = 0x00004000, /* a stream-int would like to get some data from the buffer */ SI_FL_CLEAN_ABRT = 0x00008000, /* SI_FL_ERR is used to report aborts, and not SHUTR */ diff --git a/src/stream_interface.c b/src/stream_interface.c index a4bbca51c..bb1dc7aa9 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -225,7 +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_WANT_PUT | SI_FL_NOLINGER); + si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER); + si->flags |= SI_FL_RX_WAIT_EP; ic->flags &= ~CF_SHUTR_NOW; ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY; @@ -726,7 +727,7 @@ struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned short state) 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; + si->flags &= ~SI_FL_RX_WAIT_EP; } if (ret != 0) si_cs_process(cs); @@ -860,12 +861,12 @@ void si_update_both(struct stream_interface *si_f, struct stream_interface *si_b * handled at the latest moment. */ if (obj_type(si_f->end) == OBJ_TYPE_APPCTX && - (((si_f->flags & (SI_FL_WANT_PUT|SI_FL_RXBLK_ROOM)) == SI_FL_WANT_PUT) || + (((si_f->flags & (SI_FL_RX_WAIT_EP|SI_FL_RXBLK_ROOM)) == 0) || ((si_f->flags & (SI_FL_WANT_GET|SI_FL_WAIT_DATA)) == SI_FL_WANT_GET))) appctx_wakeup(si_appctx(si_f)); if (obj_type(si_b->end) == OBJ_TYPE_APPCTX && - (((si_b->flags & (SI_FL_WANT_PUT|SI_FL_RXBLK_ROOM)) == SI_FL_WANT_PUT) || + (((si_b->flags & (SI_FL_RX_WAIT_EP|SI_FL_RXBLK_ROOM)) == 0) || ((si_b->flags & (SI_FL_WANT_GET|SI_FL_WAIT_DATA)) == SI_FL_WANT_GET))) appctx_wakeup(si_appctx(si_b)); } @@ -983,7 +984,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_WANT_PUT | SI_FL_NOLINGER); + si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER); + si->flags |= SI_FL_RX_WAIT_EP; ic->flags &= ~CF_SHUTR_NOW; ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY; @@ -1416,7 +1418,7 @@ void si_applet_wake_cb(struct stream_interface *si) /* If the applet wants to write and the channel is closed, it's a * broken pipe and it must be reported. */ - if ((si->flags & SI_FL_WANT_PUT) && (ic->flags & CF_SHUTR)) + if (!(si->flags & SI_FL_RX_WAIT_EP) && (ic->flags & CF_SHUTR)) si->flags |= SI_FL_ERR; /* update the stream-int, channels, and possibly wake the stream up */ @@ -1428,7 +1430,7 @@ void si_applet_wake_cb(struct stream_interface *si) * we may have to wakeup the appctx immediately. */ if (!task_in_rq(si_task(si)) && - (((si->flags & (SI_FL_WANT_PUT|SI_FL_RXBLK_ROOM)) == SI_FL_WANT_PUT) || + (((si->flags & (SI_FL_RX_WAIT_EP|SI_FL_RXBLK_ROOM)) == 0) || ((si->flags & (SI_FL_WANT_GET|SI_FL_WAIT_DATA)) == SI_FL_WANT_GET))) appctx_wakeup(si_appctx(si)); } @@ -1516,7 +1518,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_WANT_PUT | SI_FL_NOLINGER); + si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER); + si->flags |= SI_FL_RX_WAIT_EP; ic->flags &= ~CF_SHUTR_NOW; ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY;