From cfc11c0eae611a865ba822c14105ad374a34efa4 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 13 Apr 2023 16:10:23 +0200 Subject: [PATCH] MINOR: channel/stconn: Replace sc_shutr() by sc_abort() 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 | 14 +++++++------- include/haproxy/stconn-t.h | 2 +- src/backend.c | 10 +++++----- src/cli.c | 2 +- src/http_ana.c | 2 +- src/stconn.c | 28 ++++++++++++++-------------- src/stream.c | 12 ++++++------ src/tcp_rules.c | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h index 357092b3c..a53b3d765 100644 --- a/include/haproxy/sc_strm.h +++ b/include/haproxy/sc_strm.h @@ -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) { diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 5901ba222..1beac1572 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -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 */ diff --git a/src/backend.c b/src/backend.c index 8b4e4fbcb..885cec4da 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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) diff --git a/src/cli.c b/src/cli.c index cd1e9a82f..840f775dd 100644 --- 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); /* diff --git a/src/http_ana.c b/src/http_ana.c index 7825e658c..e17075cf8 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -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; diff --git a/src/stconn.c b/src/stconn.c index aa9b2d575..64163d5a3 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -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 diff --git a/src/stream.c b/src/stream.c index 8684000ed..f455b32ee 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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 || diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 13dc5627e..01c0a2efd 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -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;