]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn/channel: Move CF_EOI into the SC and rename it
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 22 Mar 2023 13:53:11 +0000 (14:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:06 +0000 (08:57 +0200)
The channel flag CF_EOI is renamed to SC_FL_EOI and moved into the
stream-connector.

include/haproxy/channel-t.h
include/haproxy/sc_strm.h
include/haproxy/stconn-t.h
src/backend.c
src/flt_bwlim.c
src/hlua.c
src/http_ana.c
src/http_fetch.c
src/stconn.c
src/tcp_rules.c

index a69ce46cd2064f9438aece6be5ed345e9f7daf4d..32f698300c83ea078fcec28ebf6d57c739b6182e 100644 (file)
 
 #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;
index 579409271b783fae47953a646aea92bd11523ce2..199e8d221efc84458413d7b1c2487744c8a5e356 100644 (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)
 {
-       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;
index 285b35c29d81cd1e657cee7548a100788d76f9bb..e97bf83ffc8a299aba3bdc11d07f0d2392b0e4e9 100644 (file)
@@ -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;
index d022627ad45b7f03d4f017210a742448c549a763..af39fefde1651e01a27aff5cfcdbdaed4d846c1a 100644 (file)
@@ -1848,8 +1848,10 @@ skip_reuse:
         *       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)) {
index 20919fcd1ef06c91c10a96aede380ee565b536f0..e14b774912b17865e3690ed20fe97543ec3a54bd 100644 (file)
@@ -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;
 
index 5a0a78c386947ca6452acee1533158d7c4f77825..f2e6f24a23119e31737e745c3d0906fd31300a81 100644 (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
         * (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);
index ae97b33c170614b695f4b738e765e4383f0ef813..6a309c77c83829a0ef23ba257c3f2b8d33795aae 100644 (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 == 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;
index 1775bc68b1ad1df56747643986437669d3c61a72..2485eb3449eabb77092811f61211377699865b1a 100644 (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;
 
        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;
index 1e2ca265eba8026dbcd7f3a146faeb233eb38924..d1aa1b5c62363591fca33613b35a1e8de1942428 100644 (file)
@@ -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)) {
index 1d1ce7d8cafd68d05a77bb47c8093b082d57571d..bb4e51f3da023f4e17ade8e00b65968972b18e2f 100644 (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 ((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;