MINOR: stconn/channel: Move CF_EOI into the SC and rename it

The channel flag CF_EOI is renamed to SC_FL_EOI and moved into the
stream-connector.
This commit is contained in:
Christopher Faulet 2023-03-22 14:53:11 +01:00
parent be08df8fb3
commit 904763f562
10 changed files with 36 additions and 29 deletions

View File

@ -114,7 +114,7 @@
#define CF_WAKE_ONCE 0x10000000 /* pretend there is activity on this channel (one-shoot) */ #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_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 */ #define CF_ISRESP 0x80000000 /* 0 = request channel, 1 = response channel */
/* Masks which define input events for stream analysers */ /* 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_KERN_SPLICING,
_(CF_AUTO_CONNECT, _(CF_DONT_READ, _(CF_AUTO_CONNECT, _(CF_DONT_READ,
_(CF_WAKE_ONCE, _(CF_FLT_ANALYZE, _(CF_WAKE_ONCE, _(CF_FLT_ANALYZE,
_(CF_EOI, _(CF_ISRESP)))))))))))))))))))); _(CF_ISRESP)))))))))))))))))));
/* epilogue */ /* epilogue */
_(~0U); _(~0U);
return buf; return buf;

View File

@ -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) 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; 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; return 0;
if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) || sc_ep_test(sc_opposite(sc), SE_FL_EXP_NO_DATA)) if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) || sc_ep_test(sc_opposite(sc), SE_FL_EXP_NO_DATA))
return 0; return 0;

View File

@ -114,7 +114,7 @@ enum sc_flags {
SC_FL_NONE = 0x00000000, /* Just for initialization purposes */ SC_FL_NONE = 0x00000000, /* Just for initialization purposes */
SC_FL_ISBACK = 0x00000001, /* Set for SC on back-side */ 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 */ /* not used: 0x00000004 */
SC_FL_NOLINGER = 0x00000008, /* may close without lingering. One-shot. */ 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 */ /* prologue */
_(0); _(0);
/* flags */ /* 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_DONT_WAKE, _(SC_FL_INDEP_STR, _(SC_FL_WONT_READ,
_(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM, _(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 */ /* epilogue */
_(~0U); _(~0U);
return buf; return buf;

View File

@ -1848,8 +1848,10 @@ static int connect_server(struct stream *s)
* wake callback. Otherwise si_cs_recv()/si_cs_send() already take * wake callback. Otherwise si_cs_recv()/si_cs_send() already take
* care of it. * care of it.
*/ */
if (sc_ep_test(s->scb, SE_FL_EOI) && !(sc_ic(s->scb)->flags & CF_EOI)) if (sc_ep_test(s->scb, SE_FL_EOI) && !(s->scb->flags & SC_FL_EOI)) {
sc_ic(s->scb)->flags |= (CF_EOI|CF_READ_EVENT); 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 */ /* catch all sync connect while the mux is not already installed */
if (!srv_conn->mux && !(srv_conn->flags & CO_FL_WAIT_XPRT)) { if (!srv_conn->mux && !(srv_conn->flags & CO_FL_WAIT_XPRT)) {

View File

@ -151,7 +151,7 @@ static int bwlim_apply_limit(struct filter *filter, struct channel *chn, unsigne
*/ */
ret = tokens; ret = tokens;
if (tokens < conf->min_size) { 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) ? MIN(len, conf->min_size)
: conf->min_size; : conf->min_size;

View File

@ -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 /* The message was fully consumed and no more data are expected
* (EOM flag set). * (EOM flag set).
*/ */
if (htx_is_empty(htx) && (req->flags & CF_EOI)) if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
stop = 1; stop = 1;
htx_to_buf(htx, &req->buf); 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 /* The message was fully consumed and no more data are expected
* (EOM flag set). * (EOM flag set).
*/ */
if (htx_is_empty(htx) && (req->flags & CF_EOI)) if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
len = 0; len = 0;
htx_to_buf(htx, &req->buf); htx_to_buf(htx, &req->buf);

View File

@ -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) {
if (req->to_forward == CHN_INFINITE_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; msg->msg_state = HTTP_MSG_ENDING;
} }
else { else {
@ -1134,7 +1134,7 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc)
res = &s->res; res = &s->res;
/* Remove any write error from the request, and read error from the response */ /* Remove any write error from the request, and read error from the response */
req->flags &= ~(CF_WRITE_TIMEOUT | CF_SHUTW | CF_SHUTW_NOW); 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; res->analysers &= AN_RES_FLT_END;
s->conn_err_type = STRM_ET_NONE; s->conn_err_type = STRM_ET_NONE;
s->flags &= ~(SF_CONN_EXP | SF_ERR_MASK | SF_FINST_MASK); 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) {
if (res->to_forward == CHN_INFINITE_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; msg->msg_state = HTTP_MSG_ENDING;
} }
else { else {
@ -4449,11 +4449,11 @@ int http_forward_proxy_resp(struct stream *s, int final)
channel_auto_read(res); channel_auto_read(res);
channel_auto_close(res); channel_auto_close(res);
channel_shutr_now(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 */ htxbuf(&res->buf)->flags |= HTX_FL_EOM; /* no more data are expected */
} }
else { else {
/* Send ASAP informational messages. Rely on CF_EOI for final /* Send ASAP informational messages. Rely on SC_FL_EOI for final
* response. * response.
*/ */
s->scf->flags |= SC_FL_SND_ASAP; s->scf->flags |= SC_FL_SND_ASAP;

View File

@ -615,7 +615,7 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char
smp->flags = SMP_F_VOL_TEST; smp->flags = SMP_F_VOL_TEST;
if (!finished && (check || (chn && !channel_full(chn, global.tune.maxrewrite) && 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; smp->flags |= SMP_F_MAY_CHANGE;
return 1; return 1;

View File

@ -1096,11 +1096,11 @@ static void sc_notify(struct stconn *sc)
if (/* changes on the production side that must be handled: if (/* changes on the production side that must be handled:
* - An error on receipt: SE_FL_ERROR * - An error on receipt: SE_FL_ERROR
* - A read event: shutdown for reads (CF_READ_EVENT + SHUTR) * - 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) * 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) * 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) || sc_ep_test(sc, SE_FL_ERROR) ||
/* changes on the consumption side */ /* 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 /* Report EOI on the channel if it was reached from the mux point of
* view. */ * 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); 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; ret = 1;
} }
@ -1528,6 +1529,7 @@ int sc_conn_sync_recv(struct stconn *sc)
static int sc_conn_send(struct stconn *sc) static int sc_conn_send(struct stconn *sc)
{ {
struct connection *conn = __sc_conn(sc); struct connection *conn = __sc_conn(sc);
struct stconn *sco = sc_opposite(sc);
struct stream *s = __sc_strm(sc); struct stream *s = __sc_strm(sc);
struct channel *oc = sc_oc(sc); struct channel *oc = sc_oc(sc);
int ret; int ret;
@ -1597,7 +1599,7 @@ static int sc_conn_send(struct stconn *sc)
((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) || ((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) ||
(sc->flags & SC_FL_SND_EXP_MORE) || (sc->flags & SC_FL_SND_EXP_MORE) ||
(IS_HTX_STRM(s) && (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_ISRESP) &&
((oc->flags & (CF_AUTO_CLOSE|CF_SHUTW_NOW)) == (CF_AUTO_CLOSE|CF_SHUTW_NOW)))) ((oc->flags & (CF_AUTO_CLOSE|CF_SHUTW_NOW)) == (CF_AUTO_CLOSE|CF_SHUTW_NOW))))
send_flag |= CO_SFL_MSG_MORE; 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 * wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
* care of it. * care of it.
*/ */
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)) {
ic->flags |= (CF_EOI|CF_READ_EVENT); sc->flags |= SC_FL_EOI;
ic->flags |= CF_READ_EVENT;
}
/* Second step : update the stream connector and channels, try to forward any /* Second step : update the stream connector and channels, try to forward any
* pending data, then possibly wake the stream up based on the new * 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 /* Report EOI on the channel if it was reached from the applet point of
* view. */ * 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); 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)) { if (sc_ep_test(sc, SE_FL_EOS)) {

View File

@ -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 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)) || sc_waiting_room(chn_prod(req)) ||
!s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
partial = SMP_OPT_FINAL; 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 OK, then return OK
* - if one rule returns KO, then return KO * - 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)) || sc_waiting_room(chn_prod(rep)) ||
!s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
partial = SMP_OPT_FINAL; partial = SMP_OPT_FINAL;