]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel/stconn: Replace sc_shutr() by sc_abort()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Apr 2023 14:10:23 +0000 (16:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 12:54:35 +0000 (14:54 +0200)
All reference to a shutr is replaced by an abort. So sc_shutr() is renamed
sc_abort(). SC app ops functions are renamed accordingly.

include/haproxy/sc_strm.h
include/haproxy/stconn-t.h
src/backend.c
src/cli.c
src/http_ana.c
src/stconn.c
src/stream.c
src/tcp_rules.c

index 357092b3ca8401fb6daa2d39d0c4e192eee54040..a53b3d7656d5fa84b359effadd0d272c66782eb0 100644 (file)
@@ -262,13 +262,6 @@ static inline void sc_must_kill_conn(struct stconn *sc)
 }
 
 
-/* Sends a shutr to the endpoint using the data layer */
-static inline void sc_shutr(struct stconn *sc)
-{
-       if (likely(sc->app_ops->shutr))
-               sc->app_ops->shutr(sc);
-}
-
 /* Sends a shutw to the endpoint using the data layer */
 static inline void sc_shutw(struct stconn *sc)
 {
@@ -420,6 +413,13 @@ static inline void sc_schedule_abort(struct stconn *sc)
        sc->flags |= SC_FL_ABRT_WANTED;
 }
 
+/* Abort the SC and notify the endpoint using the data layer */
+static inline void sc_abort(struct stconn *sc)
+{
+       if (likely(sc->app_ops->abort))
+               sc->app_ops->abort(sc);
+}
+
 /* Schedule a shutdown for the SC */
 static inline void sc_schedule_shutdown(struct stconn *sc)
 {
index 5901ba222e448278e014ecb2d6c0ab1fa5aaefdb..1beac1572834863850f1a20c71ff584368ed46ad 100644 (file)
@@ -265,7 +265,7 @@ struct sedesc {
 struct sc_app_ops {
        void (*chk_rcv)(struct stconn *);    /* chk_rcv function, may not be null */
        void (*chk_snd)(struct stconn *);    /* chk_snd function, may not be null */
-       void (*shutr)(struct stconn *);      /* shut read function, may not be null */
+       void (*abort)(struct stconn *);      /* abort function, may not be null */
        void (*shutw)(struct stconn *);      /* shut write function, may not be null */
        int  (*wake)(struct stconn *);       /* data-layer callback to report activity */
        char name[8];                        /* data layer name, zero-terminated */
index 8b4e4fbcbc19945c424e9932d8fae93a41a563e0..885cec4dab21368ba624df4130f101ae18615fe8 100644 (file)
@@ -2022,7 +2022,7 @@ void back_try_conn_req(struct stream *s)
                                process_srv_queue(srv);
 
                        /* Failed and not retryable. */
-                       sc_shutr(sc);
+                       sc_abort(sc);
                        sc_shutw(sc);
                        sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
 
@@ -2082,7 +2082,7 @@ void back_try_conn_req(struct stream *s)
                        if (srv)
                                _HA_ATOMIC_INC(&srv->counters.failed_conns);
                        _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
-                       sc_shutr(sc);
+                       sc_abort(sc);
                        sc_shutw(sc);
                        req->flags |= CF_WRITE_TIMEOUT;
                        if (!s->conn_err_type)
@@ -2142,7 +2142,7 @@ abort_connection:
        /* give up */
        s->conn_exp = TICK_ETERNITY;
        s->flags &= ~SF_CONN_EXP;
-       sc_shutr(sc);
+       sc_abort(sc);
        sc_shutw(sc);
        sc->state = SC_ST_CLO;
        if (s->srv_error)
@@ -2182,7 +2182,7 @@ void back_handle_st_req(struct stream *s)
                         */
                        s->flags &= ~(SF_ERR_MASK | SF_FINST_MASK);
 
-                       sc_shutr(sc);
+                       sc_abort(sc);
                        sc_shutw(sc);
                        sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                        s->conn_err_type = STRM_ET_CONN_RES;
@@ -2208,7 +2208,7 @@ void back_handle_st_req(struct stream *s)
                }
 
                /* we did not get any server, let's check the cause */
-               sc_shutr(sc);
+               sc_abort(sc);
                sc_shutw(sc);
                sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                if (!s->conn_err_type)
index cd1e9a82fd079adce5e101fe5024812d6fde9438..840f775dde68d2da6769e3808b60d524274f749f 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2747,7 +2747,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                pcli_write_prompt(s);
 
                s->scb->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
-               sc_shutr(s->scb);
+               sc_abort(s->scb);
                sc_shutw(s->scb);
 
                /*
index 7825e658c115a996382e42e8611d474dfa8ef7b4..e17075cf812b4fcb0d9791d548806c1000d98fe6 100644 (file)
@@ -4177,7 +4177,7 @@ void http_perform_server_redirect(struct stream *s, struct stconn *sc)
                goto fail;
 
        /* return without error. */
-       sc_shutr(sc);
+       sc_abort(sc);
        sc_shutw(sc);
        s->conn_err_type = STRM_ET_NONE;
        sc->state = SC_ST_CLO;
index aa9b2d575fb982865e2a65c41612ccc00b6215c3..64163d5a356f99a01bdeff1973ddd70693615e14 100644 (file)
@@ -24,19 +24,19 @@ DECLARE_POOL(pool_head_connstream, "stconn", sizeof(struct stconn));
 DECLARE_POOL(pool_head_sedesc, "sedesc", sizeof(struct sedesc));
 
 /* functions used by default on a detached stream connector */
-static void sc_app_shutr(struct stconn *sc);
+static void sc_app_abort(struct stconn *sc);
 static void sc_app_shutw(struct stconn *sc);
 static void sc_app_chk_rcv(struct stconn *sc);
 static void sc_app_chk_snd(struct stconn *sc);
 
 /* functions used on a mux-based stream connector */
-static void sc_app_shutr_conn(struct stconn *sc);
+static void sc_app_abort_conn(struct stconn *sc);
 static void sc_app_shutw_conn(struct stconn *sc);
 static void sc_app_chk_rcv_conn(struct stconn *sc);
 static void sc_app_chk_snd_conn(struct stconn *sc);
 
 /* functions used on an applet-based stream connector */
-static void sc_app_shutr_applet(struct stconn *sc);
+static void sc_app_abort_applet(struct stconn *sc);
 static void sc_app_shutw_applet(struct stconn *sc);
 static void sc_app_chk_rcv_applet(struct stconn *sc);
 static void sc_app_chk_snd_applet(struct stconn *sc);
@@ -50,7 +50,7 @@ static int sc_applet_process(struct stconn *sc);
 struct sc_app_ops sc_app_conn_ops = {
        .chk_rcv = sc_app_chk_rcv_conn,
        .chk_snd = sc_app_chk_snd_conn,
-       .shutr   = sc_app_shutr_conn,
+       .abort   = sc_app_abort_conn,
        .shutw   = sc_app_shutw_conn,
        .wake    = sc_conn_process,
        .name    = "STRM",
@@ -60,7 +60,7 @@ struct sc_app_ops sc_app_conn_ops = {
 struct sc_app_ops sc_app_embedded_ops = {
        .chk_rcv = sc_app_chk_rcv,
        .chk_snd = sc_app_chk_snd,
-       .shutr   = sc_app_shutr,
+       .abort   = sc_app_abort,
        .shutw   = sc_app_shutw,
        .wake    = NULL,   /* may never be used */
        .name    = "NONE", /* may never be used */
@@ -70,7 +70,7 @@ struct sc_app_ops sc_app_embedded_ops = {
 struct sc_app_ops sc_app_applet_ops = {
        .chk_rcv = sc_app_chk_rcv_applet,
        .chk_snd = sc_app_chk_snd_applet,
-       .shutr   = sc_app_shutr_applet,
+       .abort   = sc_app_abort_applet,
        .shutw   = sc_app_shutw_applet,
        .wake    = sc_applet_process,
        .name    = "STRM",
@@ -80,7 +80,7 @@ struct sc_app_ops sc_app_applet_ops = {
 struct sc_app_ops sc_app_check_ops = {
        .chk_rcv = NULL,
        .chk_snd = NULL,
-       .shutr   = NULL,
+       .abort   = NULL,
        .shutw   = NULL,
        .wake    = wake_srv_chk,
        .name    = "CHCK",
@@ -530,7 +530,7 @@ static inline int sc_cond_forward_shutw(struct stconn *sc)
  * reflect the new state. If the stream connector has SC_FL_NOHALF, we also
  * forward the close to the write side. The owner task is woken up if it exists.
  */
-static void sc_app_shutr(struct stconn *sc)
+static void sc_app_abort(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
 
@@ -655,7 +655,7 @@ static void sc_app_chk_snd(struct stconn *sc)
  * descriptors are then shutdown or closed accordingly. The function
  * automatically disables polling if needed.
  */
-static void sc_app_shutr_conn(struct stconn *sc)
+static void sc_app_abort_conn(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
 
@@ -738,7 +738,7 @@ static void sc_app_shutw_conn(struct stconn *sc)
                __fallthrough;
        case SC_ST_CON:
                /* we may have to close a pending connection, and mark the
-                * response buffer as shutr
+                * response buffer as abort
                 */
                sc_conn_shut(sc);
                __fallthrough;
@@ -851,7 +851,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
  * we also forward the close to the write side. The owner task is woken up if
  * it exists.
  */
-static void sc_app_shutr_applet(struct stconn *sc)
+static void sc_app_abort_applet(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
 
@@ -862,7 +862,7 @@ static void sc_app_shutr_applet(struct stconn *sc)
        sc->flags |= SC_FL_ABRT_DONE;
        ic->flags |= CF_READ_EVENT;
 
-       /* Note: on shutr, we don't call the applet */
+       /* Note: on abort, we don't call the applet */
 
        if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
                return;
@@ -1197,7 +1197,7 @@ static int sc_conn_recv(struct stconn *sc)
        if ((sc->wait_event.events & SUB_RETRY_RECV) || sc_waiting_room(sc))
                return 0;
 
-       /* maybe we were called immediately after an asynchronous shutr */
+       /* maybe we were called immediately after an asynchronous abort */
        if (sc->flags & SC_FL_ABRT_DONE)
                return 1;
 
@@ -1847,7 +1847,7 @@ static int sc_applet_process(struct stconn *sc)
 
        if (sc_ep_test(sc, SE_FL_EOS)) {
                /* we received a shutdown */
-               sc_shutr(sc);
+               sc_abort(sc);
        }
 
        /* If the applet wants to write and the channel is closed, it's a
index 8684000ed2f1c5fb2711cc4aef402c7055c1d795..f455b32ee1eac24b8ee284aa3ad05dc9a0bd9833 100644 (file)
@@ -1593,7 +1593,7 @@ static void stream_handle_timeouts(struct stream *s)
        if (unlikely(!(s->scf->flags & SC_FL_ABRT_DONE) && (s->req.flags & CF_READ_TIMEOUT))) {
                if (s->scf->flags & SC_FL_NOHALF)
                        s->scf->flags |= SC_FL_NOLINGER;
-               sc_shutr(s->scf);
+               sc_abort(s->scf);
        }
        if (unlikely(!(s->scf->flags & SC_FL_SHUTW) && (s->res.flags & CF_WRITE_TIMEOUT))) {
                s->scf->flags |= SC_FL_NOLINGER;
@@ -1603,7 +1603,7 @@ static void stream_handle_timeouts(struct stream *s)
        if (unlikely(!(s->scb->flags & SC_FL_ABRT_DONE) && (s->res.flags & CF_READ_TIMEOUT))) {
                if (s->scb->flags & SC_FL_NOHALF)
                        s->scb->flags |= SC_FL_NOLINGER;
-               sc_shutr(s->scb);
+               sc_abort(s->scb);
        }
 
        if (HAS_FILTERS(s))
@@ -1826,7 +1826,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
        srv = objt_server(s->target);
        if (unlikely(sc_ep_test(scf, SE_FL_ERROR))) {
                if (sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS)) {
-                       sc_shutr(scf);
+                       sc_abort(scf);
                        sc_shutw(scf);
                        //sc_report_error(scf); TODO: Be sure it is useless
                        if (!(req->analysers) && !(res->analysers)) {
@@ -1846,7 +1846,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
 
        if (unlikely(sc_ep_test(scb, SE_FL_ERROR))) {
                if (sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) {
-                       sc_shutr(scb);
+                       sc_abort(scb);
                        sc_shutw(scb);
                        //sc_report_error(scb); TODO: Be sure it is useless
                        _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
@@ -2387,7 +2387,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
        if (unlikely((scf->flags & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) == SC_FL_ABRT_WANTED)) {
                if (scf->flags & SC_FL_NOHALF)
                        scf->flags |= SC_FL_NOLINGER;
-               sc_shutr(scf);
+               sc_abort(scf);
        }
 
        /* Benchmarks have shown that it's optimal to do a full resync now */
@@ -2507,7 +2507,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
        if (unlikely((scb->flags & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) == SC_FL_ABRT_WANTED)) {
                if (scb->flags & SC_FL_NOHALF)
                        scb->flags |= SC_FL_NOLINGER;
-               sc_shutr(scb);
+               sc_abort(scb);
        }
 
        if (scf->state == SC_ST_DIS ||
index 13dc5627e6638d7ba618bdfe5c339b9aa5823466..01c0a2efdb719b1798fbe017e3863effb2bb49e6 100644 (file)
@@ -393,7 +393,7 @@ resume_execution:
                        else if (rule->action == ACT_TCP_CLOSE) {
                                chn_prod(rep)->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
                                sc_must_kill_conn(chn_prod(rep));
-                               sc_shutr(chn_prod(rep));
+                               sc_abort(chn_prod(rep));
                                sc_shutw(chn_prod(rep));
                                s->last_rule_file = rule->conf.file;
                                s->last_rule_line = rule->conf.line;