]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel/applets: Stop to test CF_WRITE_ERROR flag if CF_SHUTW is enough
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Jan 2023 13:11:10 +0000 (14:11 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 9 Jan 2023 17:41:08 +0000 (18:41 +0100)
In applets, we stop processing when a write error (CF_WRITE_ERROR) or a shutdown
for writes (CF_SHUTW) is detected. However, any write error leads to an
immediate shutdown for writes. Thus, it is enough to only test if CF_SHUTW is
set.

15 files changed:
include/haproxy/channel.h
src/activity.c
src/cli.c
src/debug.c
src/dns.c
src/map.c
src/mworker.c
src/proxy.c
src/ring.c
src/sink.c
src/ssl_ckch.c
src/ssl_crtlist.c
src/stconn.c
src/stick_table.c
src/stream.c

index 052ffee15abb02edea59e927cfd04058326fffec..8ef5b863d5c58c137b9b285c99d6664a5fdf50e4 100644 (file)
@@ -534,7 +534,7 @@ static inline void channel_check_timeouts(struct channel *chn)
            unlikely(tick_is_expired(chn->rex, now_ms)))
                chn->flags |= CF_READ_TIMEOUT;
 
-       if (likely(!(chn->flags & (CF_SHUTW|CF_WRITE_TIMEOUT|CF_WRITE_EVENT|CF_WRITE_ERROR))) &&
+       if (likely(!(chn->flags & (CF_SHUTW|CF_WRITE_TIMEOUT|CF_WRITE_EVENT))) &&
            unlikely(tick_is_expired(chn->wex, now_ms)))
                chn->flags |= CF_WRITE_TIMEOUT;
 
index f697358a6cb55c4da4648088a6a31ff91e2c7bce..5ee5fbb10e640041597034d0ee652aa340fdcec5 100644 (file)
@@ -624,7 +624,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
        int max_lines;
        int i, j, max;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        chunk_reset(&trash);
@@ -887,7 +887,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
        int thr, queue;
        int i, max;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        /* It's not possible to scan queues in small chunks and yield in the
@@ -1027,7 +1027,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
        struct timeval up;
        int thr;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        chunk_reset(&trash);
index 23f77e50cb55c2e1bf8cc3ee7f5562f677f54ca2..ced990cceb71d5c147ca0fd6561c397207f8d68d 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1227,7 +1227,7 @@ static int cli_io_handler_show_env(struct appctx *appctx)
        struct stconn *sc = appctx_sc(appctx);
        char **var = ctx->var;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        chunk_reset(&trash);
@@ -1264,7 +1264,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
        int fd = fdctx->fd;
        int ret = 1;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto end;
 
        chunk_reset(&trash);
index c9b912e98ce74872a56a5b93465dc797e56efeb7..05c7a5cf966160a2a7ee9f20c40515dc2024d3e6 100644 (file)
@@ -313,7 +313,7 @@ static int cli_io_handler_show_threads(struct appctx *appctx)
        struct stconn *sc = appctx_sc(appctx);
        int thr;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        if (appctx->st0)
@@ -1096,7 +1096,7 @@ static int debug_iohandler_fd(struct appctx *appctx)
        int ret = 1;
        int i, fd;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto end;
 
        chunk_reset(&trash);
@@ -1303,7 +1303,7 @@ static int debug_iohandler_memstats(struct appctx *appctx)
        const char *pfx = ctx->match;
        int ret = 1;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto end;
 
        if (!ctx->width) {
index a6e6af8bbd71637ef386b13ac4b6211a8dbf87b9..883c293d4a184baf9f9458fed5a92eb6305fb2c5 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -459,8 +459,7 @@ static void dns_session_io_handler(struct appctx *appctx)
        if (ds->shutdown)
                goto close;
 
-       /* an error was detected */
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto close;
 
        /* con closed by server side, we will skip data write and drain data from channel */
index 46125ad9b33cf34cb841a9f2013d781ffb7751eb..971304157292a90f26fdd7cc88ca0cdf44183ba5 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -348,7 +348,7 @@ static int cli_io_handler_pat_list(struct appctx *appctx)
        struct stconn *sc = appctx_sc(appctx);
        struct pat_ref_elt *elt;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW)) {
                /* If we're forced to shut down, we might have to remove our
                 * reference to the last ref_elt being dumped.
                 */
index 82fa2a2a8805bd585b0564b0c877305c5093d20b..8b3be1916d0f6b68e8fe942aaa3c6c48200e6db7 100644 (file)
@@ -534,7 +534,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
        char *uptime = NULL;
        char *reloadtxt = NULL;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        chunk_reset(&trash);
@@ -669,7 +669,7 @@ static int cli_io_handler_show_loadstatus(struct appctx *appctx)
        if (!cli_has_level(appctx, ACCESS_LVL_OPER))
                return 1;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
 
index e53cc4f72d49f08f3fb062f7da43f3f5c249ca48..a0e8c15236cf9002d39c3f663a15c08a5cdfa34f 100644 (file)
@@ -3189,7 +3189,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
        struct stconn *sc = appctx_sc(appctx);
        extern const char *monthname[12];
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        chunk_reset(&trash);
index 91157a90b39108b29be8181242b8caacffe8590d..22ac3047504ea4ecb16e69b88e3c7bed363667ae 100644 (file)
@@ -347,7 +347,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
        size_t len, cnt;
        int ret;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                return 1;
 
        HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
index 3d0fda22347dfc8e65156edc57982320892077b4..862a1ae322837285ff8e028dd16cc7f91c828853 100644 (file)
@@ -330,8 +330,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
        /* rto should not change but it seems the case */
        sc_oc(sc)->rto = TICK_ETERNITY;
 
-       /* an error was detected */
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto close;
 
        /* con closed by server side */
@@ -480,7 +479,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
        sc_oc(sc)->rto = TICK_ETERNITY;
 
        /* an error was detected */
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto close;
 
        /* con closed by server side */
index f8e63edc33d4f9a16572ff4f0b885c88a1025e33..7d07cad71b2577bef2a6a5c9bb69c28e61fc098a 100644 (file)
@@ -2148,7 +2148,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
        struct ckch_store *old_ckchs, *new_ckchs = NULL;
        struct ckch_inst *ckchi;
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto end;
 
        while (1) {
index 9027d0eba1c84cc6b5e8ca6576d17ebe1585d03f..e76fb9a112a18eec1923186696e0d544f6a254d4 100644 (file)
@@ -1098,7 +1098,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx)
        /* for each bind_conf which use the crt-list, a new ckch_inst must be
         * created.
         */
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
                goto end;
 
        switch (ctx->state) {
index 75904238d2c5ff967ae5bdf130a9a99cb429b6bf..ab11ee8a27f0b9a726b9c6fff93dd82b5032e108 100644 (file)
@@ -850,7 +850,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((oc->flags & (CF_WRITE_EVENT|CF_WRITE_ERROR|CF_SHUTW)) ||
+       if (likely((oc->flags & (CF_WRITE_EVENT|CF_SHUTW)) ||
                  ((oc->flags & CF_WAKE_WRITE) &&
                   ((channel_is_empty(oc) && !oc->to_forward) ||
                    !sc_state_in(sc->state, SC_SB_EST))))) {
@@ -1127,7 +1127,7 @@ static void sc_notify(struct stconn *sc)
 
        /* update OC timeouts and wake the other side up if it's waiting for room */
        if (oc->flags & (CF_WRITE_EVENT|CF_WRITE_ERROR)) {
-               if ((oc->flags & (CF_SHUTW|CF_WRITE_EVENT)) == CF_WRITE_EVENT &&
+               if (!(oc->flags & CF_WRITE_ERROR) &&
                    !channel_is_empty(oc))
                        if (tick_isset(oc->wex))
                                oc->wex = tick_add_ifset(now_ms, oc->wto);
index b6f3ef1e5dec326dae505c46af36f293f9894fbb..09c7c74316430cea105cd7202d2be98120d7ed94 100644 (file)
@@ -5022,7 +5022,7 @@ static int cli_io_handler_table(struct appctx *appctx)
         *     data though.
         */
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
+       if (unlikely(sc_ic(sc)->flags & CF_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 8367c891216c07f6e154ac457186e99c94a8ad03..a4b428cd827e0a7c5534ba8e2a13be2fb7fd7c6f 100644 (file)
@@ -1782,7 +1782,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
                 */
                if (!((req->flags | res->flags) &
                      (CF_SHUTR|CF_READ_EVENT|CF_READ_TIMEOUT|CF_SHUTW|
-                      CF_WRITE_EVENT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) &&
+                      CF_WRITE_EVENT|CF_WRITE_TIMEOUT)) &&
                    !(s->flags & SF_CONN_EXP) &&
                    !((sc_ep_get(scf) | scb->flags) & SE_FL_ERROR) &&
                    ((s->pending_events & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER)) {
@@ -3626,7 +3626,7 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
                goto done;
        }
 
-       if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
+       if (unlikely(sc_ic(sc)->flags & CF_SHUTW)) {
                /* If we're forced to shut down, we might have to remove our
                 * reference to the last stream being dumped.
                 */