MINOR: channel/stconn: Replace sc_shutw() by sc_shutdown()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Apr 2023 14:23:48 +0000 (16:23 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 13:02:57 +0000 (15:02 +0200)
All reference to a shutw is replaced by an abort. So sc_shutw() is renamed
sc_shutdown(). 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 43cfcef..26b1444 100644 (file)
@@ -255,20 +255,13 @@ static inline int sc_get_dst(struct stconn *sc)
 }
 
 
-/* Marks on the stream connector that next shutw must kill the whole connection */
+/* Marks on the stream connector that next shutdown must kill the whole connection */
 static inline void sc_must_kill_conn(struct stconn *sc)
 {
        sc_ep_set(sc, SE_FL_KILL_CONN);
 }
 
 
-/* Sends a shutw to the endpoint using the data layer */
-static inline void sc_shutw(struct stconn *sc)
-{
-       if (likely(sc->app_ops->shutw))
-               sc->app_ops->shutw(sc);
-}
-
 /* Returns non-zero if the stream connector is allowed to receive from the
  * endpoint, which means that no flag indicating a blocked channel, lack of
  * buffer or room is set, and that the endpoint is not waiting for the
@@ -426,4 +419,11 @@ static inline void sc_schedule_shutdown(struct stconn *sc)
        sc->flags |= SC_FL_SHUT_WANTED;
 }
 
+/* Shutdown the SC and notify the endpoint using the data layer */
+static inline void sc_shutdown(struct stconn *sc)
+{
+       if (likely(sc->app_ops->shutdown))
+               sc->app_ops->shutdown(sc);
+}
+
 #endif /* _HAPROXY_SC_STRM_H */
index c42b81a..ce0876b 100644 (file)
@@ -266,7 +266,7 @@ 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 (*abort)(struct stconn *);      /* abort function, may not be null */
-       void (*shutw)(struct stconn *);      /* shut write function, may not be null */
+       void (*shutdown)(struct stconn *);   /* shutdown function, may not be null */
        int  (*wake)(struct stconn *);       /* data-layer callback to report activity */
        char name[8];                        /* data layer name, zero-terminated */
 };
index a221b1c..7044ae1 100644 (file)
@@ -2023,7 +2023,7 @@ void back_try_conn_req(struct stream *s)
 
                        /* Failed and not retryable. */
                        sc_abort(sc);
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
                        sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
 
                        s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@@ -2083,7 +2083,7 @@ void back_try_conn_req(struct stream *s)
                                _HA_ATOMIC_INC(&srv->counters.failed_conns);
                        _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
                        sc_abort(sc);
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
                        req->flags |= CF_WRITE_TIMEOUT;
                        if (!s->conn_err_type)
                                s->conn_err_type = STRM_ET_QUEUE_TO;
@@ -2143,7 +2143,7 @@ abort_connection:
        s->conn_exp = TICK_ETERNITY;
        s->flags &= ~SF_CONN_EXP;
        sc_abort(sc);
-       sc_shutw(sc);
+       sc_shutdown(sc);
        sc->state = SC_ST_CLO;
        if (s->srv_error)
                s->srv_error(s, sc);
@@ -2183,7 +2183,7 @@ void back_handle_st_req(struct stream *s)
                        s->flags &= ~(SF_ERR_MASK | SF_FINST_MASK);
 
                        sc_abort(sc);
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
                        sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                        s->conn_err_type = STRM_ET_CONN_RES;
                        sc->state = SC_ST_CLO;
@@ -2209,7 +2209,7 @@ void back_handle_st_req(struct stream *s)
 
                /* we did not get any server, let's check the cause */
                sc_abort(sc);
-               sc_shutw(sc);
+               sc_shutdown(sc);
                sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
                if (!s->conn_err_type)
                        s->conn_err_type = STRM_ET_CONN_OTHER;
@@ -2250,7 +2250,7 @@ void back_handle_st_con(struct stream *s)
            ((chn_cons(req)->flags & SC_FL_SHUT_WANTED) &&
             (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
                sc->flags |= SC_FL_NOLINGER;
-               sc_shutw(sc);
+               sc_shutdown(sc);
                s->conn_err_type |= STRM_ET_CONN_ABRT;
                if (s->srv_error)
                        s->srv_error(s, sc);
@@ -2344,7 +2344,7 @@ void back_handle_st_cer(struct stream *s)
                        process_srv_queue(objt_server(s->target));
 
                /* shutw is enough to stop a connecting socket */
-               sc_shutw(sc);
+               sc_shutdown(sc);
                sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
 
                sc->state = SC_ST_CLO;
@@ -2377,7 +2377,7 @@ void back_handle_st_cer(struct stream *s)
                        process_srv_queue(objt_server(s->target));
 
                /* shutw is enough to stop a connecting socket */
-               sc_shutw(sc);
+               sc_shutdown(sc);
                sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
 
                sc->state = SC_ST_CLO;
@@ -2475,7 +2475,7 @@ void back_handle_st_rdy(struct stream *s)
                     (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
                        /* give up */
                        sc->flags |= SC_FL_NOLINGER;
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
                        s->conn_err_type |= STRM_ET_CONN_ABRT;
                        if (s->srv_error)
                                s->srv_error(s, sc);
index 55a825a..bcb4ce7 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2748,7 +2748,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 
                s->scb->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
                sc_abort(s->scb);
-               sc_shutw(s->scb);
+               sc_shutdown(s->scb);
 
                /*
                 * starting from there this the same code as
index f9d71dd..61b5443 100644 (file)
@@ -4178,7 +4178,7 @@ void http_perform_server_redirect(struct stream *s, struct stconn *sc)
 
        /* return without error. */
        sc_abort(sc);
-       sc_shutw(sc);
+       sc_shutdown(sc);
        s->conn_err_type = STRM_ET_NONE;
        sc->state = SC_ST_CLO;
 
index afe5d7b..d320173 100644 (file)
@@ -25,19 +25,19 @@ DECLARE_POOL(pool_head_sedesc, "sedesc", sizeof(struct sedesc));
 
 /* functions used by default on a detached stream connector */
 static void sc_app_abort(struct stconn *sc);
-static void sc_app_shutw(struct stconn *sc);
+static void sc_app_shut(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_abort_conn(struct stconn *sc);
-static void sc_app_shutw_conn(struct stconn *sc);
+static void sc_app_shut_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_abort_applet(struct stconn *sc);
-static void sc_app_shutw_applet(struct stconn *sc);
+static void sc_app_shut_applet(struct stconn *sc);
 static void sc_app_chk_rcv_applet(struct stconn *sc);
 static void sc_app_chk_snd_applet(struct stconn *sc);
 
@@ -51,7 +51,7 @@ struct sc_app_ops sc_app_conn_ops = {
        .chk_rcv = sc_app_chk_rcv_conn,
        .chk_snd = sc_app_chk_snd_conn,
        .abort   = sc_app_abort_conn,
-       .shutw   = sc_app_shutw_conn,
+       .shutdown= sc_app_shut_conn,
        .wake    = sc_conn_process,
        .name    = "STRM",
 };
@@ -61,7 +61,7 @@ struct sc_app_ops sc_app_embedded_ops = {
        .chk_rcv = sc_app_chk_rcv,
        .chk_snd = sc_app_chk_snd,
        .abort   = sc_app_abort,
-       .shutw   = sc_app_shutw,
+       .shutdown= sc_app_shut,
        .wake    = NULL,   /* may never be used */
        .name    = "NONE", /* may never be used */
 };
@@ -71,7 +71,7 @@ struct sc_app_ops sc_app_applet_ops = {
        .chk_rcv = sc_app_chk_rcv_applet,
        .chk_snd = sc_app_chk_snd_applet,
        .abort   = sc_app_abort_applet,
-       .shutw   = sc_app_shutw_applet,
+       .shutdown= sc_app_shut_applet,
        .wake    = sc_applet_process,
        .name    = "STRM",
 };
@@ -81,7 +81,7 @@ struct sc_app_ops sc_app_check_ops = {
        .chk_rcv = NULL,
        .chk_snd = NULL,
        .abort   = NULL,
-       .shutw   = NULL,
+       .shutdown= NULL,
        .wake    = wake_srv_chk,
        .name    = "CHCK",
 };
@@ -504,7 +504,7 @@ struct appctx *sc_applet_create(struct stconn *sc, struct applet *app)
  * side. Otherwise, 0 is returned. In this case, SC_FL_SHUT_WANTED flag may be set on
  * the consumer SC if we are only waiting for the outgoing data to be flushed.
  */
-static inline int sc_cond_forward_shutw(struct stconn *sc)
+static inline int sc_cond_forward_shut(struct stconn *sc)
 {
        /* The close must not be forwarded */
        if (!(sc->flags & SC_FL_ABRT_DONE) || !(sc->flags & SC_FL_NOHALF))
@@ -549,8 +549,8 @@ static void sc_app_abort(struct stconn *sc)
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
-       else if (sc_cond_forward_shutw(sc))
-               return sc_app_shutw(sc);
+       else if (sc_cond_forward_shut(sc))
+               return sc_app_shut(sc);
 
        /* note that if the task exists, it must unregister itself once it runs */
        if (!(sc->flags & SC_FL_DONT_WAKE))
@@ -564,7 +564,7 @@ static void sc_app_abort(struct stconn *sc)
  * reflect the new state. It does also close everything if the SC was marked as
  * being in error state. The owner task is woken up if it exists.
  */
-static void sc_app_shutw(struct stconn *sc)
+static void sc_app_shut(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
        struct channel *oc = sc_oc(sc);
@@ -675,8 +675,8 @@ static void sc_app_abort_conn(struct stconn *sc)
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
-       else if (sc_cond_forward_shutw(sc))
-               return sc_app_shutw_conn(sc);
+       else if (sc_cond_forward_shut(sc))
+               return sc_app_shut_conn(sc);
 }
 
 /*
@@ -687,7 +687,7 @@ static void sc_app_abort_conn(struct stconn *sc)
  * everything if the SC was marked as being in error state. If there is a
  * data-layer shutdown, it is called.
  */
-static void sc_app_shutw_conn(struct stconn *sc)
+static void sc_app_shut_conn(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
        struct channel *oc = sc_oc(sc);
@@ -815,7 +815,7 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
                if ((oc->flags & CF_AUTO_CLOSE) &&
                    ((sc->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) == SC_FL_SHUT_WANTED) &&
                    sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST)) {
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
                        goto out_wakeup;
                }
 
@@ -873,8 +873,8 @@ static void sc_app_abort_applet(struct stconn *sc)
                if (sc->flags & SC_FL_ISBACK)
                        __sc_strm(sc)->conn_exp = TICK_ETERNITY;
        }
-       else if (sc_cond_forward_shutw(sc))
-               return sc_app_shutw_applet(sc);
+       else if (sc_cond_forward_shut(sc))
+               return sc_app_shut_applet(sc);
 }
 
 /*
@@ -884,7 +884,7 @@ static void sc_app_abort_applet(struct stconn *sc)
  * updated to reflect the new state. It does also close everything if the SI
  * was marked as being in error state. The owner task is woken up if it exists.
  */
-static void sc_app_shutw_applet(struct stconn *sc)
+static void sc_app_shut_applet(struct stconn *sc)
 {
        struct channel *ic = sc_ic(sc);
        struct channel *oc = sc_oc(sc);
@@ -1044,7 +1044,7 @@ static void sc_notify(struct stconn *sc)
 
                if (((sc->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) == SC_FL_SHUT_WANTED) &&
                    (sc->state == SC_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS))))
-                       sc_shutw(sc);
+                       sc_shutdown(sc);
        }
 
        /* indicate that we may be waiting for data from the output channel or
@@ -1151,7 +1151,7 @@ static void sc_conn_read0(struct stconn *sc)
        if (sc->flags & SC_FL_SHUT_DONE)
                goto do_close;
 
-       if (sc_cond_forward_shutw(sc)) {
+       if (sc_cond_forward_shut(sc)) {
                /* we want to immediately forward this close to the write side */
                /* force flag on ssl to keep stream in cache */
                sc_conn_shutw(sc, CO_SHW_SILENT);
index 59049b8..83e3b72 100644 (file)
@@ -1587,7 +1587,7 @@ static void stream_handle_timeouts(struct stream *s)
 
        if (unlikely(!(s->scb->flags & SC_FL_SHUT_DONE) && (s->req.flags & CF_WRITE_TIMEOUT))) {
                s->scb->flags |= SC_FL_NOLINGER;
-               sc_shutw(s->scb);
+               sc_shutdown(s->scb);
        }
 
        if (unlikely(!(s->scf->flags & SC_FL_ABRT_DONE) && (s->req.flags & CF_READ_TIMEOUT))) {
@@ -1597,7 +1597,7 @@ static void stream_handle_timeouts(struct stream *s)
        }
        if (unlikely(!(s->scf->flags & SC_FL_SHUT_DONE) && (s->res.flags & CF_WRITE_TIMEOUT))) {
                s->scf->flags |= SC_FL_NOLINGER;
-               sc_shutw(s->scf);
+               sc_shutdown(s->scf);
        }
 
        if (unlikely(!(s->scb->flags & SC_FL_ABRT_DONE) && (s->res.flags & CF_READ_TIMEOUT))) {
@@ -1827,7 +1827,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
        if (unlikely(sc_ep_test(scf, SE_FL_ERROR))) {
                if (sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS)) {
                        sc_abort(scf);
-                       sc_shutw(scf);
+                       sc_shutdown(scf);
                        //sc_report_error(scf); TODO: Be sure it is useless
                        if (!(req->analysers) && !(res->analysers)) {
                                _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
@@ -1847,7 +1847,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_abort(scb);
-                       sc_shutw(scb);
+                       sc_shutdown(scb);
                        //sc_report_error(scb); TODO: Be sure it is useless
                        _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
                        if (srv)
@@ -2375,7 +2375,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
                     channel_is_empty(req))) {
                if (sc_ep_test(s->scf, SE_FL_ERROR))
                        scb->flags |= SC_FL_NOLINGER;
-               sc_shutw(scb);
+               sc_shutdown(scb);
        }
 
        /* shutdown(write) done on server side, we must stop the client too */
@@ -2495,7 +2495,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
        /* shutdown(write) pending */
        if (unlikely((scf->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) == SC_FL_SHUT_WANTED &&
                     channel_is_empty(res))) {
-               sc_shutw(scf);
+               sc_shutdown(scf);
        }
 
        /* shutdown(write) done on the client side, we must stop the server too */
index 01c0a2e..ad86ac8 100644 (file)
@@ -394,7 +394,7 @@ resume_execution:
                                chn_prod(rep)->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
                                sc_must_kill_conn(chn_prod(rep));
                                sc_abort(chn_prod(rep));
-                               sc_shutw(chn_prod(rep));
+                               sc_shutdown(chn_prod(rep));
                                s->last_rule_file = rule->conf.file;
                                s->last_rule_line = rule->conf.line;
                                goto end;