]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 4 Apr 2023 08:05:27 +0000 (10:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:06 +0000 (08:57 +0200)
At many places, we simplify the tests on SHUT flags to remove calls to
chn_prod() or chn_cons() function because the corresponding SC is available.

15 files changed:
include/haproxy/sc_strm.h
src/activity.c
src/applet.c
src/cli.c
src/debug.c
src/map.c
src/mworker.c
src/proxy.c
src/quic_conn.c
src/ring.c
src/ssl_ckch.c
src/ssl_crtlist.c
src/stconn.c
src/stick_table.c
src/stream.c

index fbe0968ee48f10a4f0225cdb89270bd6e02149e5..1161f53981490313d1e1ed00909572a16d610d0a 100644 (file)
@@ -286,9 +286,7 @@ static inline void sc_shutw(struct stconn *sc)
 __attribute__((warn_unused_result))
 static inline int sc_is_recv_allowed(const struct stconn *sc)
 {
-       struct channel *ic = sc_ic(sc);
-
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return 0;
 
        if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN))
@@ -365,9 +363,7 @@ static inline const char *sc_state_str(int state)
 __attribute__((warn_unused_result))
 static inline int sc_is_send_allowed(const struct stconn *sc)
 {
-       struct channel *oc = sc_oc(sc);
-
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       if (sc->flags & SC_FL_SHUTW)
                return 0;
 
        return !sc_ep_test(sc, SE_FL_WAIT_DATA | SE_FL_WONT_CONSUME);
@@ -375,8 +371,8 @@ static inline int sc_is_send_allowed(const struct stconn *sc)
 
 static inline int sc_rcv_may_expire(const struct stconn *sc)
 {
-       if ((chn_prod(sc_ic(sc))->flags & SC_FL_SHUTR) ||
-            (sc_ic(sc)->flags & (CF_READ_TIMEOUT|CF_READ_EVENT)))
+       if ((sc->flags & SC_FL_SHUTR) ||
+           (sc_ic(sc)->flags & (CF_READ_TIMEOUT|CF_READ_EVENT)))
                return 0;
        if (sc->flags & (SC_FL_EOI|SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM))
                return 0;
@@ -387,7 +383,7 @@ static inline int sc_rcv_may_expire(const struct stconn *sc)
 
 static inline int sc_snd_may_expire(const struct stconn *sc)
 {
-       if ((chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) ||
+       if ((sc->flags & SC_FL_SHUTW) ||
            (sc_oc(sc)->flags & (CF_WRITE_TIMEOUT|CF_WRITE_EVENT)))
                return 0;
        if (sc_ep_test(sc, SE_FL_WONT_CONSUME))
index bfdd6f3e59f0d39b077adb9a693f9f20c84b6fca..9d396cd9066a0ab7a46d47aa50f2e6d025a7cc6d 100644 (file)
@@ -625,7 +625,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
        int i, j, max;
 
        /* FIXME: Don't watch the other side ! */
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        chunk_reset(&trash);
@@ -889,7 +889,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
        int i, max;
 
        /* FIXME: Don't watch the other side ! */
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        /* It's not possible to scan queues in small chunks and yield in the
@@ -1030,7 +1030,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
        int thr;
 
        /* FIXME: Don't watch the other side ! */
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        chunk_reset(&trash);
index 0c5b40de142e021f1b440978c228eac0809c9939..b9bb9928b29d222e11b679f7fb98786935ef25e0 100644 (file)
@@ -471,7 +471,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
             (b_size(sc_ib(sc)) && !b_data(sc_ib(sc)) && sc->flags & SC_FL_NEED_ROOM) || // asks for room in an empty buffer
             (b_data(sc_ob(sc)) && sc_is_send_allowed(sc)) || // asks for data already present
             (!b_data(sc_ib(sc)) && b_data(sc_ob(sc)) && // didn't return anything ...
-             (!(sc_oc(sc)->flags & CF_WRITE_EVENT) && (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW_NOW))))) { // ... and left data pending after a shut
+             (!(sc_oc(sc)->flags & CF_WRITE_EVENT) && (sc->flags & SC_FL_SHUTW_NOW))))) { // ... and left data pending after a shut
                rate = update_freq_ctr(&app->call_rate, 1);
                if (rate >= 100000 && app->call_rate.prev_ctr) // looped like this more than 100k times over last second
                        stream_dump_and_crash(&app->obj_type, read_freq_ctr(&app->call_rate));
index 21d662055b0adda76958340c1b3ae7af7c4a185c..1b4276ff921ca760ab60f54c62c061a9ccd7be9f 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1214,7 +1214,7 @@ static int cli_io_handler_show_env(struct appctx *appctx)
        char **var = ctx->var;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        chunk_reset(&trash);
@@ -1253,7 +1253,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
        int ret = 1;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        chunk_reset(&trash);
index 5209166ed83ee8fe1bb34b7f352fe0dacb0bc707..ed7f971e741b276fceba52a0aaf6fa3c74aca6ad 100644 (file)
@@ -314,7 +314,7 @@ static int cli_io_handler_show_threads(struct appctx *appctx)
        int thr;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        if (appctx->st0)
@@ -1162,7 +1162,7 @@ static int debug_iohandler_fd(struct appctx *appctx)
        int i, fd;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        chunk_reset(&trash);
@@ -1370,7 +1370,7 @@ static int debug_iohandler_memstats(struct appctx *appctx)
        int ret = 1;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        if (!ctx->width) {
index ff6bbf59ad80f774f0f3c4450e35d02359d9e0cd..b7e087bc2a7972053bf9f9bcb13c52d4f0f9cb4a 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -349,7 +349,7 @@ static int cli_io_handler_pat_list(struct appctx *appctx)
        struct pat_ref_elt *elt;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
                /* If we're forced to shut down, we might have to remove our
                 * reference to the last ref_elt being dumped.
                 */
index 17609f6ce004180c48b1253187e837dd84f3de30..7b4f09c420b14fe16df5114316b7c951e10bf330 100644 (file)
@@ -568,7 +568,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
        char *reloadtxt = NULL;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        if (up < 0) /* must never be negative because of clock drift */
@@ -715,7 +715,7 @@ static int cli_io_handler_show_loadstatus(struct appctx *appctx)
                return 1;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        env = getenv("HAPROXY_LOAD_SUCCESS");
index 276228c345b1a691f50ecfec94f3ebb4bb587af8..89c9cbe8f1cd4665df9d9adf1bbd265d298ec127 100644 (file)
@@ -3209,7 +3209,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
        extern const char *monthname[12];
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        chunk_reset(&trash);
index a09216e4636057e62891662d4913521f528e67df..d858b437f07feaf8e77d4b1a46b1e09af4e23f51 100644 (file)
@@ -8262,7 +8262,7 @@ static int cli_io_handler_dump_quic(struct appctx *appctx)
                goto done;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
                /* If we're forced to shut down, we might have to remove our
                 * reference to the last stream being dumped.
                 */
index 6d75f0510d98271d0af473efb3892a2abf2fb6df..fbd2d0680cb7f26bdef3c6d36a639b7166a6d904 100644 (file)
@@ -350,7 +350,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
        int ret;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                return 1;
 
        HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
@@ -423,7 +423,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
                /* we've drained everything and are configured to wait for more
                 * data or an event (keypress, close)
                 */
-               if (!sc_oc(sc)->output && !(chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW)) {
+               if (!sc_oc(sc)->output && !(sc->flags & SC_FL_SHUTW)) {
                        /* let's be woken up once new data arrive */
                        HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
                        LIST_APPEND(&ring->waiters, &appctx->wait_entry);
index bfb4235e4ed8f02cab18df3cac9209b05a8ebe51..5b3a20d81d9e5d808aa49ec77e3451961d3ac30d 100644 (file)
@@ -2149,7 +2149,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
        struct ckch_inst *ckchi;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        while (1) {
@@ -2826,7 +2826,7 @@ static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx)
        char *path;
 
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        /* The ctx was already validated by the ca-file/crl-file parsing
index 7b410e9ce2b380e327b73dfa53a2d0e937779365..f74f43a038f6d17ebefd3641546828bebd35a0ba 100644 (file)
@@ -1117,7 +1117,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx)
         * created.
         */
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
                goto end;
 
        switch (ctx->state) {
index 5d94646584ed0c8b3a95e7a838d4aec4bf53670f..061a003b818c89f3aa6456c2fb6c7590393dc5bc 100644 (file)
@@ -507,7 +507,7 @@ struct appctx *sc_applet_create(struct stconn *sc, struct applet *app)
 static inline int sc_cond_forward_shutw(struct stconn *sc)
 {
        /* The close must not be forwarded */
-       if (!(chn_prod(sc_ic(sc))->flags & SC_FL_SHUTR) || !(sc->flags & SC_FL_NOHALF))
+       if (!(sc->flags & SC_FL_SHUTR) || !(sc->flags & SC_FL_NOHALF))
                return 0;
 
        if (!channel_is_empty(sc_ic(sc))) {
@@ -534,17 +534,17 @@ static void sc_app_shutr(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
 
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return;
 
-       chn_prod(ic)->flags |= SC_FL_SHUTR;
+       sc->flags |= SC_FL_SHUTR;
        ic->flags |= CF_READ_EVENT;
        sc_ep_report_read_activity(sc);
 
        if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
                return;
 
-       if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+       if (sc->flags & SC_FL_SHUTW) {
                sc->state = SC_ST_DIS;
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
@@ -569,10 +569,10 @@ static void sc_app_shutw(struct stconn *sc)
        struct channel *ic = sc_ic(sc);
        struct channel *oc = sc_oc(sc);
 
-       chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       sc->flags &= ~SC_FL_SHUTW_NOW;
+       if (sc->flags & SC_FL_SHUTW)
                return;
-       chn_cons(oc)->flags |= SC_FL_SHUTW;
+       sc->flags |= SC_FL_SHUTW;
        oc->flags |= CF_WRITE_EVENT;
        sc_set_hcto(sc);
 
@@ -586,7 +586,7 @@ static void sc_app_shutw(struct stconn *sc)
                 * no risk so we close both sides immediately.
                 */
                if (!sc_ep_test(sc, SE_FL_ERROR) && !(sc->flags & SC_FL_NOLINGER) &&
-                   !(chn_prod(ic)->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
+                   !(sc->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
                        return;
 
                __fallthrough;
@@ -599,7 +599,7 @@ static void sc_app_shutw(struct stconn *sc)
                __fallthrough;
        default:
                sc->flags &= ~SC_FL_NOLINGER;
-               chn_prod(ic)->flags |= SC_FL_SHUTR;
+               sc->flags |= SC_FL_SHUTR;
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
@@ -630,7 +630,7 @@ static void sc_app_chk_snd(struct stconn *sc)
 {
        struct channel *oc = sc_oc(sc);
 
-       if (unlikely(sc->state != SC_ST_EST || (chn_cons(oc)->flags & SC_FL_SHUTW)))
+       if (unlikely(sc->state != SC_ST_EST || (sc->flags & SC_FL_SHUTW)))
                return;
 
        if (!sc_ep_test(sc, SE_FL_WAIT_DATA) ||  /* not waiting for data */
@@ -661,15 +661,15 @@ static void sc_app_shutr_conn(struct stconn *sc)
 
        BUG_ON(!sc_conn(sc));
 
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return;
-       chn_prod(ic)->flags |= SC_FL_SHUTR;
+       sc->flags |= SC_FL_SHUTR;
        ic->flags |= CF_READ_EVENT;
 
        if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
                return;
 
-       if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+       if (sc->flags & SC_FL_SHUTW) {
                sc_conn_shut(sc);
                sc->state = SC_ST_DIS;
                if (sc->flags & SC_FL_ISBACK)
@@ -694,10 +694,10 @@ static void sc_app_shutw_conn(struct stconn *sc)
 
        BUG_ON(!sc_conn(sc));
 
-       chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       sc->flags &= ~SC_FL_SHUTW_NOW;
+       if (sc->flags & SC_FL_SHUTW)
                return;
-       chn_cons(oc)->flags |= SC_FL_SHUTW;
+       sc->flags |= SC_FL_SHUTW;
        oc->flags |= CF_WRITE_EVENT;
        sc_set_hcto(sc);
 
@@ -731,7 +731,7 @@ static void sc_app_shutw_conn(struct stconn *sc)
                         */
                        sc_conn_shutw(sc, CO_SHW_NORMAL);
 
-                       if (!(chn_prod(ic)->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
+                       if (!(sc->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
                                return;
                }
 
@@ -749,7 +749,7 @@ static void sc_app_shutw_conn(struct stconn *sc)
                __fallthrough;
        default:
                sc->flags &= ~SC_FL_NOLINGER;
-               chn_prod(ic)->flags |= SC_FL_SHUTR;
+               sc->flags |= SC_FL_SHUTR;
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
@@ -783,7 +783,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
        BUG_ON(!sc_conn(sc));
 
        if (unlikely(!sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST) ||
-                    (chn_cons(oc)->flags & SC_FL_SHUTW)))
+                    (sc->flags & SC_FL_SHUTW)))
                return;
 
        if (unlikely(channel_is_empty(oc)))  /* called with nothing to send ! */
@@ -813,13 +813,13 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
                 * chunk and need to close.
                 */
                if ((oc->flags & CF_AUTO_CLOSE) &&
-                   ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
+                   ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
                    sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST)) {
                        sc_shutw(sc);
                        goto out_wakeup;
                }
 
-               if ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == 0)
+               if ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == 0)
                        sc_ep_set(sc, SE_FL_WAIT_DATA);
        }
        else {
@@ -832,7 +832,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
        /* in case of special condition (error, shutdown, end of write...), we
         * have to notify the task.
         */
-       if (likely((chn_cons(oc)->flags & SC_FL_SHUTW) ||
+       if (likely((sc->flags & SC_FL_SHUTW) ||
                   ((oc->flags & CF_WRITE_EVENT) && sc->state < SC_ST_EST) ||
                   ((oc->flags & CF_WAKE_WRITE) &&
                    ((channel_is_empty(oc) && !oc->to_forward) ||
@@ -857,9 +857,9 @@ static void sc_app_shutr_applet(struct stconn *sc)
 
        BUG_ON(!sc_appctx(sc));
 
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return;
-       chn_prod(ic)->flags |= SC_FL_SHUTR;
+       sc->flags |= SC_FL_SHUTR;
        ic->flags |= CF_READ_EVENT;
 
        /* Note: on shutr, we don't call the applet */
@@ -867,7 +867,7 @@ static void sc_app_shutr_applet(struct stconn *sc)
        if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
                return;
 
-       if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+       if (sc->flags & SC_FL_SHUTW) {
                appctx_shut(__sc_appctx(sc));
                sc->state = SC_ST_DIS;
                if (sc->flags & SC_FL_ISBACK)
@@ -891,10 +891,10 @@ static void sc_app_shutw_applet(struct stconn *sc)
 
        BUG_ON(!sc_appctx(sc));
 
-       chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       sc->flags &= ~SC_FL_SHUTW_NOW;
+       if (sc->flags & SC_FL_SHUTW)
                return;
-       chn_cons(oc)->flags |= SC_FL_SHUTW;
+       sc->flags |= SC_FL_SHUTW;
        oc->flags |= CF_WRITE_EVENT;
        sc_set_hcto(sc);
 
@@ -911,7 +911,7 @@ static void sc_app_shutw_applet(struct stconn *sc)
                 * no risk so we close both sides immediately.
                 */
                if (!sc_ep_test(sc, SE_FL_ERROR) && !(sc->flags & SC_FL_NOLINGER) &&
-                   !(chn_prod(ic)->flags & SC_FL_SHUTR) &&
+                   !(sc->flags & SC_FL_SHUTR) &&
                    !(ic->flags & CF_DONT_READ))
                        return;
 
@@ -926,7 +926,7 @@ static void sc_app_shutw_applet(struct stconn *sc)
                __fallthrough;
        default:
                sc->flags &= ~SC_FL_NOLINGER;
-               chn_prod(ic)->flags |= SC_FL_SHUTR;
+               sc->flags |= SC_FL_SHUTR;
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
@@ -952,7 +952,7 @@ static void sc_app_chk_snd_applet(struct stconn *sc)
 
        BUG_ON(!sc_appctx(sc));
 
-       if (unlikely(sc->state != SC_ST_EST || (chn_cons(oc)->flags & SC_FL_SHUTW)))
+       if (unlikely(sc->state != SC_ST_EST || (sc->flags & SC_FL_SHUTW)))
                return;
 
        /* we only wake the applet up if it was waiting for some data  and is ready to consume it */
@@ -979,7 +979,7 @@ void sc_update_rx(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
 
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return;
 
        /* Read not closed, update FD status and timeout for reads */
@@ -1004,14 +1004,14 @@ void sc_update_tx(struct stconn *sc)
 {
        struct channel *oc = sc_oc(sc);
 
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       if (sc->flags & SC_FL_SHUTW)
                return;
 
        /* Write not closed, update FD status and timeout for writes */
        if (channel_is_empty(oc)) {
                /* stop writing */
                if (!sc_ep_test(sc, SE_FL_WAIT_DATA)) {
-                       if ((chn_cons(oc)->flags & SC_FL_SHUTW_NOW) == 0)
+                       if ((sc->flags & SC_FL_SHUTW_NOW) == 0)
                                sc_ep_set(sc, SE_FL_WAIT_DATA);
                }
                return;
@@ -1042,7 +1042,7 @@ static void sc_notify(struct stconn *sc)
        if (channel_is_empty(oc)) {
                struct connection *conn = sc_conn(sc);
 
-               if (((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
+               if (((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
                    (sc->state == SC_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS))))
                        sc_shutw(sc);
        }
@@ -1050,9 +1050,9 @@ static void sc_notify(struct stconn *sc)
        /* indicate that we may be waiting for data from the output channel or
         * we're about to close and can't expect more data if SC_FL_SHUTW_NOW is there.
         */
-       if (!(chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)))
+       if (!(sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)))
                sc_ep_set(sc, SE_FL_WAIT_DATA);
-       else if ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW)
+       else if ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW)
                sc_ep_clr(sc, SE_FL_WAIT_DATA);
 
        if (oc->flags & CF_DONT_READ)
@@ -1108,17 +1108,17 @@ static void sc_notify(struct stconn *sc)
             *                  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) && ((sc->flags & SC_FL_EOI) || (chn_prod(ic)->flags & SC_FL_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) ||
+               ((ic->flags & CF_READ_EVENT) && ((sc->flags & SC_FL_EOI) || (sc->flags & SC_FL_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) ||
            sc_ep_test(sc, SE_FL_ERROR) ||
 
            /* changes on the consumption side */
            sc_ep_test(sc, SE_FL_ERR_PENDING) ||
            ((oc->flags & CF_WRITE_EVENT) &&
             ((sc->state < SC_ST_EST) ||
-             (chn_cons(oc)->flags & SC_FL_SHUTW) ||
+             (sc->flags & SC_FL_SHUTW) ||
              (((oc->flags & CF_WAKE_WRITE) ||
                (!(oc->flags & CF_AUTO_CLOSE) &&
-                !(chn_cons(oc)->flags & (SC_FL_SHUTW_NOW|SC_FL_SHUTW)))) &&
+                !(sc->flags & (SC_FL_SHUTW_NOW|SC_FL_SHUTW)))) &&
               (sco->state != SC_ST_EST ||
                (channel_is_empty(oc) && !oc->to_forward)))))) {
                task_wakeup(task, TASK_WOKEN_IO);
@@ -1136,20 +1136,19 @@ static void sc_notify(struct stconn *sc)
 static void sc_conn_read0(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
-       struct channel *oc = sc_oc(sc);
 
        BUG_ON(!sc_conn(sc));
 
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return;
-       chn_prod(ic)->flags |= SC_FL_SHUTR;
+       sc->flags |= SC_FL_SHUTR;
        ic->flags |= CF_READ_EVENT;
        sc_ep_report_read_activity(sc);
 
        if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
                return;
 
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       if (sc->flags & SC_FL_SHUTW)
                goto do_close;
 
        if (sc_cond_forward_shutw(sc)) {
@@ -1166,8 +1165,8 @@ static void sc_conn_read0(struct stconn *sc)
        /* OK we completely close the socket here just as if we went through sc_shut[rw]() */
        sc_conn_shut(sc);
 
-       chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-       chn_cons(oc)->flags |= SC_FL_SHUTW;
+       sc->flags &= ~SC_FL_SHUTW_NOW;
+       sc->flags |= SC_FL_SHUTW;
 
        sc->state = SC_ST_DIS;
        if (sc->flags & SC_FL_ISBACK)
@@ -1199,7 +1198,7 @@ static int sc_conn_recv(struct stconn *sc)
                return 0;
 
        /* maybe we were called immediately after an asynchronous shutr */
-       if (chn_prod(ic)->flags & SC_FL_SHUTR)
+       if (sc->flags & SC_FL_SHUTR)
                return 1;
 
        /* we must wait because the mux is not installed yet */
@@ -1330,7 +1329,7 @@ static int sc_conn_recv(struct stconn *sc)
         */
        while (sc_ep_test(sc, SE_FL_RCV_MORE) ||
               (!(conn->flags & CO_FL_HANDSHAKE) &&
-               (!sc_ep_test(sc, SE_FL_ERROR | SE_FL_EOS)) && !(chn_prod(ic)->flags & SC_FL_SHUTR))) {
+               (!sc_ep_test(sc, SE_FL_ERROR | SE_FL_EOS)) && !(sc->flags & SC_FL_SHUTR))) {
                int cur_flags = flags;
 
                /* Compute transient CO_RFL_* flags */
@@ -1494,7 +1493,7 @@ static int sc_conn_recv(struct stconn *sc)
        if (sc_ep_test(sc, SE_FL_ERROR))
                ret = 1;
        else if (!(sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM)) &&
-                !(chn_prod(ic)->flags & SC_FL_SHUTR)) {
+                !(sc->flags & SC_FL_SHUTR)) {
                /* Subscribe to receive events if we're blocking on I/O */
                conn->mux->subscribe(sc, SUB_RETRY_RECV, &sc->wait_event);
                se_have_no_more_data(sc->sedesc);
@@ -1564,7 +1563,7 @@ static int sc_conn_send(struct stconn *sc)
                return 0;
 
        /* we might have been called just after an asynchronous shutw */
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       if (sc->flags & SC_FL_SHUTW)
                return 1;
 
        /* we must wait because the mux is not installed yet */
@@ -1609,10 +1608,10 @@ 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) &&
-                      (!(sco->flags & SC_FL_EOI) && !(chn_prod(oc)->flags & SC_FL_SHUTR) && htx_expect_more(htxbuf(&oc->buf)))))) ||
+                      (!(sco->flags & (SC_FL_EOI|SC_FL_SHUTR)) && htx_expect_more(htxbuf(&oc->buf)))))) ||
                    ((oc->flags & CF_ISRESP) &&
                     (oc->flags & CF_AUTO_CLOSE) &&
-                    (chn_cons(oc)->flags & SC_FL_SHUTW_NOW)))
+                    (sc->flags & SC_FL_SHUTW_NOW)))
                        send_flag |= CO_SFL_MSG_MORE;
 
                if (oc->flags & CF_STREAMER)
@@ -1696,7 +1695,7 @@ void sc_conn_sync_send(struct stconn *sc)
 
        oc->flags &= ~CF_WRITE_EVENT;
 
-       if (chn_cons(oc)->flags & SC_FL_SHUTW)
+       if (sc->flags & SC_FL_SHUTW)
                return;
 
        if (channel_is_empty(oc))
@@ -1774,7 +1773,7 @@ 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_EOS) && !(chn_prod(ic)->flags & SC_FL_SHUTR)) {
+       if (sc_ep_test(sc, SE_FL_EOS) && !(sc->flags & SC_FL_SHUTR)) {
                /* we received a shutdown */
                if (ic->flags & CF_AUTO_CLOSE)
                        channel_shutw_now(ic);
@@ -1853,7 +1852,7 @@ static int sc_applet_process(struct stconn *sc)
        /* If the applet wants to write and the channel is closed, it's a
         * broken pipe and it must be reported.
         */
-       if (!sc_ep_test(sc, SE_FL_HAVE_NO_DATA) && (chn_prod(ic)->flags & SC_FL_SHUTR))
+       if (!sc_ep_test(sc, SE_FL_HAVE_NO_DATA) && (sc->flags & SC_FL_SHUTR))
                sc_ep_set(sc, SE_FL_ERROR);
 
        /* automatically mark the applet having data available if it reported
index bb4dd5abc029d6480743d9e3fbae36e72c0ecfc1..7ff4c472276e89a44150272f508c51a464080439 100644 (file)
@@ -5044,7 +5044,7 @@ static int cli_io_handler_table(struct appctx *appctx)
         *     data though.
         */
        /* FIXME: Don't watch the other side !*/
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
                /* in case of abort, remove any refcount we might have set on an entry */
                if (ctx->state == STATE_DUMP) {
                        stksess_kill_if_expired(ctx->t, ctx->entry, 1);
index b53a6033907c8ae3120da5c6bf92304fdcfe5662..803dbe8309739928c1e63bd27212dd2f9c3bf62a 100644 (file)
@@ -3599,7 +3599,8 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
                goto done;
        }
 
-       if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+       /* FIXME: Don't watch the other side !*/
+       if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
                /* If we're forced to shut down, we might have to remove our
                 * reference to the last stream being dumped.
                 */