diff --git a/include/haproxy/channel-t.h b/include/haproxy/channel-t.h index a69ce46cd..32f698300 100644 --- a/include/haproxy/channel-t.h +++ b/include/haproxy/channel-t.h @@ -114,7 +114,7 @@ #define CF_WAKE_ONCE 0x10000000 /* pretend there is activity on this channel (one-shoot) */ #define CF_FLT_ANALYZE 0x20000000 /* at least one filter is still analyzing this channel */ -#define CF_EOI 0x40000000 /* end-of-input has been reached */ +/* unuse 0x40000000 */ #define CF_ISRESP 0x80000000 /* 0 = request channel, 1 = response channel */ /* Masks which define input events for stream analysers */ @@ -141,7 +141,7 @@ static forceinline char *chn_show_flags(char *buf, size_t len, const char *delim _(CF_KERN_SPLICING, _(CF_AUTO_CONNECT, _(CF_DONT_READ, _(CF_WAKE_ONCE, _(CF_FLT_ANALYZE, - _(CF_EOI, _(CF_ISRESP)))))))))))))))))))); + _(CF_ISRESP))))))))))))))))))); /* epilogue */ _(~0U); return buf; diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h index 579409271..199e8d221 100644 --- a/include/haproxy/sc_strm.h +++ b/include/haproxy/sc_strm.h @@ -375,9 +375,9 @@ static inline int sc_is_send_allowed(const struct stconn *sc) static inline int sc_rcv_may_expire(const struct stconn *sc) { - if (sc_ic(sc)->flags & (CF_EOI|CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT)) + if (sc_ic(sc)->flags & (CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT)) return 0; - if (sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM)) + if (sc->flags & (SC_FL_EOI|SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM)) return 0; if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) || sc_ep_test(sc_opposite(sc), SE_FL_EXP_NO_DATA)) return 0; diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 285b35c29..e97bf83ff 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -114,7 +114,7 @@ enum sc_flags { SC_FL_NONE = 0x00000000, /* Just for initialization purposes */ SC_FL_ISBACK = 0x00000001, /* Set for SC on back-side */ - /* not used: 0x00000002 */ + SC_FL_EOI = 0x00000002, /* End of input was reached. no more data will be received from the endpoint */ /* not used: 0x00000004 */ SC_FL_NOLINGER = 0x00000008, /* may close without lingering. One-shot. */ @@ -142,10 +142,10 @@ static forceinline char *sc_show_flags(char *buf, size_t len, const char *delim, /* prologue */ _(0); /* flags */ - _(SC_FL_ISBACK, _(SC_FL_NOLINGER, _(SC_FL_NOHALF, + _(SC_FL_ISBACK, _(SC_FL_EOI, _(SC_FL_NOLINGER, _(SC_FL_NOHALF, _(SC_FL_DONT_WAKE, _(SC_FL_INDEP_STR, _(SC_FL_WONT_READ, _(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM, - _(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE)))))))))))); + _(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE))))))))))))); /* epilogue */ _(~0U); return buf; diff --git a/src/backend.c b/src/backend.c index d022627ad..af39fefde 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1848,8 +1848,10 @@ static int connect_server(struct stream *s) * wake callback. Otherwise si_cs_recv()/si_cs_send() already take * care of it. */ - if (sc_ep_test(s->scb, SE_FL_EOI) && !(sc_ic(s->scb)->flags & CF_EOI)) - sc_ic(s->scb)->flags |= (CF_EOI|CF_READ_EVENT); + if (sc_ep_test(s->scb, SE_FL_EOI) && !(s->scb->flags & SC_FL_EOI)) { + s->scb->flags |= SC_FL_EOI; + sc_ic(s->scb)->flags |= CF_READ_EVENT; + } /* catch all sync connect while the mux is not already installed */ if (!srv_conn->mux && !(srv_conn->flags & CO_FL_WAIT_XPRT)) { diff --git a/src/flt_bwlim.c b/src/flt_bwlim.c index 20919fcd1..e14b77491 100644 --- a/src/flt_bwlim.c +++ b/src/flt_bwlim.c @@ -151,7 +151,7 @@ static int bwlim_apply_limit(struct filter *filter, struct channel *chn, unsigne */ ret = tokens; if (tokens < conf->min_size) { - ret = (chn->flags & (CF_EOI|CF_SHUTR)) + ret = ((chn_prod(chn)->flags & SC_FL_EOI) || (chn->flags & CF_SHUTR)) ? MIN(len, conf->min_size) : conf->min_size; diff --git a/src/hlua.c b/src/hlua.c index 5a0a78c38..f2e6f24a2 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5106,7 +5106,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K /* The message was fully consumed and no more data are expected * (EOM flag set). */ - if (htx_is_empty(htx) && (req->flags & CF_EOI)) + if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI)) stop = 1; htx_to_buf(htx, &req->buf); @@ -5198,7 +5198,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon /* The message was fully consumed and no more data are expected * (EOM flag set). */ - if (htx_is_empty(htx) && (req->flags & CF_EOI)) + if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI)) len = 0; htx_to_buf(htx, &req->buf); diff --git a/src/http_ana.c b/src/http_ana.c index ae97b33c1..6a309c77c 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -911,7 +911,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) if (req->to_forward) { if (req->to_forward == CHN_INFINITE_FORWARD) { - if (req->flags & CF_EOI) + if (s->scf->flags & SC_FL_EOI) msg->msg_state = HTTP_MSG_ENDING; } else { @@ -1134,7 +1134,7 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc) res = &s->res; /* Remove any write error from the request, and read error from the response */ req->flags &= ~(CF_WRITE_TIMEOUT | CF_SHUTW | CF_SHUTW_NOW); - res->flags &= ~(CF_READ_TIMEOUT | CF_SHUTR | CF_EOI | CF_READ_EVENT | CF_SHUTR_NOW); + res->flags &= ~(CF_READ_TIMEOUT | CF_SHUTR | CF_READ_EVENT | CF_SHUTR_NOW); res->analysers &= AN_RES_FLT_END; s->conn_err_type = STRM_ET_NONE; s->flags &= ~(SF_CONN_EXP | SF_ERR_MASK | SF_FINST_MASK); @@ -2019,7 +2019,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit if (res->to_forward) { if (res->to_forward == CHN_INFINITE_FORWARD) { - if (res->flags & CF_EOI) + if (s->scb->flags & SC_FL_EOI) msg->msg_state = HTTP_MSG_ENDING; } else { @@ -4449,11 +4449,11 @@ int http_forward_proxy_resp(struct stream *s, int final) channel_auto_read(res); channel_auto_close(res); channel_shutr_now(res); - res->flags |= CF_EOI; /* The response is terminated, add EOI */ + s->scb->flags |= SC_FL_EOI; /* The response is terminated, add EOI */ htxbuf(&res->buf)->flags |= HTX_FL_EOM; /* no more data are expected */ } else { - /* Send ASAP informational messages. Rely on CF_EOI for final + /* Send ASAP informational messages. Rely on SC_FL_EOI for final * response. */ s->scf->flags |= SC_FL_SND_ASAP; diff --git a/src/http_fetch.c b/src/http_fetch.c index 1775bc68b..2485eb344 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -615,7 +615,7 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char smp->flags = SMP_F_VOL_TEST; if (!finished && (check || (chn && !channel_full(chn, global.tune.maxrewrite) && - !(chn->flags & (CF_EOI|CF_SHUTR))))) + !(chn_prod(chn)->flags & SC_FL_EOI) && !(chn->flags & CF_SHUTR)))) smp->flags |= SMP_F_MAY_CHANGE; return 1; diff --git a/src/stconn.c b/src/stconn.c index 1e2ca265e..d1aa1b5c6 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -1096,11 +1096,11 @@ static void sc_notify(struct stconn *sc) if (/* changes on the production side that must be handled: * - An error on receipt: SE_FL_ERROR * - A read event: shutdown for reads (CF_READ_EVENT + SHUTR) - * end of input (CF_READ_EVENT + CF_EOI) + * end of input (CF_READ_EVENT + SC_FL_EOI) * data received and no fast-forwarding (CF_READ_EVENT + !to_forward) * read event while consumer side is not established (CF_READ_EVENT + sco->state != SC_ST_EST) */ - ((ic->flags & CF_READ_EVENT) && ((ic->flags & (CF_SHUTR|CF_EOI)) || !ic->to_forward || sco->state != SC_ST_EST)) || + ((ic->flags & CF_READ_EVENT) && ((sc->flags & SC_FL_EOI) || (ic->flags & CF_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) || sc_ep_test(sc, SE_FL_ERROR) || /* changes on the consumption side */ @@ -1466,9 +1466,10 @@ static int sc_conn_recv(struct stconn *sc) /* Report EOI on the channel if it was reached from the mux point of * view. */ - if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI)) { + if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) { sc_ep_report_read_activity(sc); - ic->flags |= (CF_EOI|CF_READ_EVENT); + sc->flags |= SC_FL_EOI; + ic->flags |= CF_READ_EVENT; ret = 1; } @@ -1528,6 +1529,7 @@ int sc_conn_sync_recv(struct stconn *sc) static int sc_conn_send(struct stconn *sc) { struct connection *conn = __sc_conn(sc); + struct stconn *sco = sc_opposite(sc); struct stream *s = __sc_strm(sc); struct channel *oc = sc_oc(sc); int ret; @@ -1597,7 +1599,7 @@ static int sc_conn_send(struct stconn *sc) ((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) || (sc->flags & SC_FL_SND_EXP_MORE) || (IS_HTX_STRM(s) && - (!(oc->flags & (CF_EOI|CF_SHUTR)) && htx_expect_more(htxbuf(&oc->buf)))))) || + (!(sco->flags & SC_FL_EOI) && !(oc->flags & CF_SHUTR) && htx_expect_more(htxbuf(&oc->buf)))))) || ((oc->flags & CF_ISRESP) && ((oc->flags & (CF_AUTO_CLOSE|CF_SHUTW_NOW)) == (CF_AUTO_CLOSE|CF_SHUTW_NOW)))) send_flag |= CO_SFL_MSG_MORE; @@ -1775,8 +1777,10 @@ static int sc_conn_process(struct stconn *sc) * wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take * care of it. */ - if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI)) - ic->flags |= (CF_EOI|CF_READ_EVENT); + if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) { + sc->flags |= SC_FL_EOI; + ic->flags |= CF_READ_EVENT; + } /* Second step : update the stream connector and channels, try to forward any * pending data, then possibly wake the stream up based on the new @@ -1824,9 +1828,10 @@ static int sc_applet_process(struct stconn *sc) /* Report EOI on the channel if it was reached from the applet point of * view. */ - if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI)) { + if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) { sc_ep_report_read_activity(sc); - ic->flags |= (CF_EOI|CF_READ_EVENT); + sc->flags |= SC_FL_EOI; + ic->flags |= CF_READ_EVENT; } if (sc_ep_test(sc, SE_FL_EOS)) { diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 1d1ce7d8c..bb4e51f3d 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -116,7 +116,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit) * - if one rule returns KO, then return KO */ - if ((req->flags & (CF_EOI|CF_SHUTR)) || channel_full(req, global.tune.maxrewrite) || + if ((s->scf->flags & SC_FL_EOI) || (req->flags & CF_SHUTR) || channel_full(req, global.tune.maxrewrite) || sc_waiting_room(chn_prod(req)) || !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { partial = SMP_OPT_FINAL; @@ -299,7 +299,7 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit) * - if one rule returns OK, then return OK * - if one rule returns KO, then return KO */ - if ((rep->flags & (CF_EOI|CF_SHUTR)) || channel_full(rep, global.tune.maxrewrite) || + if ((s->scb->flags & SC_FL_EOI) || (rep->flags & CF_SHUTR) || channel_full(rep, global.tune.maxrewrite) || sc_waiting_room(chn_prod(rep)) || !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { partial = SMP_OPT_FINAL;