CLEANUP: stconn: rename cs_{shut,chk}* to sc_*

This applies the following renaming:

cs_shutr() -> sc_shutr()
cs_shutw() -> sc_shutw()
cs_chk_rcv() -> sc_chk_rcv()
cs_chk_snd() -> sc_chk_snd()
cs_must_kill_conn() -> sc_must_kill_conn()
This commit is contained in:
Willy Tarreau 2022-05-27 09:00:19 +02:00
parent d68ff018c5
commit f61dd19284
18 changed files with 82 additions and 82 deletions

View File

@ -1571,7 +1571,7 @@ static void promex_appctx_handle_io(struct appctx *appctx)
case PROMEX_ST_END:
if (!(res->flags & CF_SHUTR)) {
res->flags |= CF_READ_NULL;
cs_shutr(cs);
sc_shutr(cs);
}
}
@ -1587,8 +1587,8 @@ static void promex_appctx_handle_io(struct appctx *appctx)
error:
res->flags |= CF_READ_NULL;
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
}
struct applet promex_applet = {

View File

@ -266,21 +266,21 @@ static inline int sc_get_dst(struct stconn *cs)
/* Marks on the stream connector that next shutw must kill the whole connection */
static inline void cs_must_kill_conn(struct stconn *cs)
static inline void sc_must_kill_conn(struct stconn *cs)
{
sc_ep_set(cs, SE_FL_KILL_CONN);
}
/* Sends a shutr to the endpoint using the data layer */
static inline void cs_shutr(struct stconn *cs)
static inline void sc_shutr(struct stconn *cs)
{
if (likely(cs->app_ops->shutr))
cs->app_ops->shutr(cs);
}
/* Sends a shutw to the endpoint using the data layer */
static inline void cs_shutw(struct stconn *cs)
static inline void sc_shutw(struct stconn *cs)
{
if (likely(cs->app_ops->shutw))
cs->app_ops->shutw(cs);
@ -316,7 +316,7 @@ static inline int sc_is_recv_allowed(const struct stconn *sc)
* point in order to avoid useless repeated wakeups.
* It will then call ->chk_rcv() to enable receipt of new data.
*/
static inline void cs_chk_rcv(struct stconn *cs)
static inline void sc_chk_rcv(struct stconn *cs)
{
if (sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) &&
cs_state_in(cs_opposite(cs)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO))
@ -334,7 +334,7 @@ static inline void cs_chk_rcv(struct stconn *cs)
}
/* Calls chk_snd on the endpoint using the data layer */
static inline void cs_chk_snd(struct stconn *cs)
static inline void sc_chk_snd(struct stconn *cs)
{
if (likely(cs->app_ops->chk_snd))
cs->app_ops->chk_snd(cs);

View File

@ -2023,8 +2023,8 @@ void back_try_conn_req(struct stream *s)
process_srv_queue(srv);
/* Failed and not retryable. */
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
req->flags |= CF_WRITE_ERROR;
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@ -2083,8 +2083,8 @@ 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);
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
req->flags |= CF_WRITE_TIMEOUT;
if (!s->conn_err_type)
s->conn_err_type = STRM_ET_QUEUE_TO;
@ -2143,8 +2143,8 @@ abort_connection:
/* give up */
s->conn_exp = TICK_ETERNITY;
s->flags &= ~SF_CONN_EXP;
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
cs->state = SC_ST_CLO;
if (s->srv_error)
s->srv_error(s, cs);
@ -2183,8 +2183,8 @@ void back_handle_st_req(struct stream *s)
*/
s->flags &= ~(SF_ERR_MASK | SF_FINST_MASK);
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
s->req.flags |= CF_WRITE_ERROR;
s->conn_err_type = STRM_ET_CONN_RES;
cs->state = SC_ST_CLO;
@ -2209,8 +2209,8 @@ void back_handle_st_req(struct stream *s)
}
/* we did not get any server, let's check the cause */
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
s->req.flags |= CF_WRITE_ERROR;
if (!s->conn_err_type)
s->conn_err_type = STRM_ET_CONN_OTHER;
@ -2251,7 +2251,7 @@ void back_handle_st_con(struct stream *s)
((req->flags & CF_SHUTW_NOW) &&
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
cs->flags |= SC_FL_NOLINGER;
cs_shutw(cs);
sc_shutw(cs);
s->conn_err_type |= STRM_ET_CONN_ABRT;
if (s->srv_error)
s->srv_error(s, cs);
@ -2347,7 +2347,7 @@ void back_handle_st_cer(struct stream *s)
process_srv_queue(objt_server(s->target));
/* shutw is enough to stop a connecting socket */
cs_shutw(cs);
sc_shutw(cs);
s->req.flags |= CF_WRITE_ERROR;
s->res.flags |= CF_READ_ERROR;
@ -2381,7 +2381,7 @@ void back_handle_st_cer(struct stream *s)
process_srv_queue(objt_server(s->target));
/* shutw is enough to stop a connecting socket */
cs_shutw(cs);
sc_shutw(cs);
s->req.flags |= CF_WRITE_ERROR;
s->res.flags |= CF_READ_ERROR;
@ -2480,7 +2480,7 @@ void back_handle_st_rdy(struct stream *s)
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
/* give up */
cs->flags |= SC_FL_NOLINGER;
cs_shutw(cs);
sc_shutw(cs);
s->conn_err_type |= STRM_ET_CONN_ABRT;
if (s->srv_error)
s->srv_error(s, cs);

View File

@ -1534,7 +1534,7 @@ static void http_cache_io_handler(struct appctx *appctx)
end:
if (!(res->flags & CF_SHUTR) && appctx->st0 == HTX_CACHE_END) {
res->flags |= CF_READ_NULL;
cs_shutr(cs);
sc_shutr(cs);
}
out:

View File

@ -928,7 +928,7 @@ static void cli_io_handler(struct appctx *appctx)
/* Let's close for real now. We just close the request
* side, the conditions below will complete if needed.
*/
cs_shutw(cs);
sc_shutw(cs);
free_trash_chunk(appctx->chunk);
appctx->chunk = NULL;
break;
@ -1176,7 +1176,7 @@ static void cli_io_handler(struct appctx *appctx)
* we forward the close to the request side so that it flows upstream to
* the client.
*/
cs_shutw(cs);
sc_shutw(cs);
}
if ((req->flags & CF_SHUTW) && (cs->state == SC_ST_EST) && (appctx->st0 < CLI_ST_OUTPUT)) {
@ -1186,7 +1186,7 @@ static void cli_io_handler(struct appctx *appctx)
* the client side has closed. So we'll forward this state downstream
* on the response buffer.
*/
cs_shutr(cs);
sc_shutr(cs);
res->flags |= CF_READ_NULL;
}
@ -2698,8 +2698,8 @@ 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;
cs_shutr(s->scb);
cs_shutw(s->scb);
sc_shutr(s->scb);
sc_shutw(s->scb);
/*
* starting from there this the same code as

View File

@ -807,7 +807,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs)
if (((oc->flags & (CF_SHUTW|CF_AUTO_CLOSE|CF_SHUTW_NOW)) ==
(CF_AUTO_CLOSE|CF_SHUTW_NOW)) &&
cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) {
cs_shutw(cs);
sc_shutw(cs);
goto out_wakeup;
}
@ -1036,7 +1036,7 @@ void sc_update_rx(struct stconn *cs)
else if (!(ic->flags & CF_READ_NOEXP) && !tick_isset(ic->rex))
ic->rex = tick_add_ifset(now_ms, ic->rto);
cs_chk_rcv(cs);
sc_chk_rcv(cs);
}
/* This function is designed to be called from within the stream handler to
@ -1110,7 +1110,7 @@ static void sc_notify(struct stconn *cs)
if (((oc->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW) &&
(cs->state == SC_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS))))
cs_shutw(cs);
sc_shutw(cs);
oc->wex = TICK_ETERNITY;
}
@ -1160,7 +1160,7 @@ static void sc_notify(struct stconn *cs)
if (ic->pipe)
last_len += ic->pipe->data;
cs_chk_snd(cso);
sc_chk_snd(cso);
new_len = co_data(ic);
if (ic->pipe)
@ -1176,15 +1176,15 @@ static void sc_notify(struct stconn *cs)
if (!(ic->flags & CF_DONT_READ))
sc_will_read(cs);
cs_chk_rcv(cs);
cs_chk_rcv(cso);
sc_chk_rcv(cs);
sc_chk_rcv(cso);
if (ic->flags & CF_SHUTR || sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) ||
(cs->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM))) {
ic->rex = TICK_ETERNITY;
}
else if ((ic->flags & (CF_SHUTR|CF_READ_PARTIAL)) == CF_READ_PARTIAL) {
/* we must re-enable reading if cs_chk_snd() has freed some space */
/* we must re-enable reading if sc_chk_snd() has freed some space */
if (!(ic->flags & CF_READ_NOEXP) && tick_isset(ic->rex))
ic->rex = tick_add_ifset(now_ms, ic->rto);
}
@ -1257,7 +1257,7 @@ static void sc_conn_read0(struct stconn *cs)
return;
do_close:
/* OK we completely close the socket here just as if we went through cs_shut[rw]() */
/* OK we completely close the socket here just as if we went through sc_shut[rw]() */
sc_conn_shut(cs);
oc->flags &= ~CF_SHUTW_NOW;

View File

@ -764,8 +764,8 @@ read:
return;
close:
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
}

View File

@ -1301,8 +1301,8 @@ spoe_release_appctx(struct appctx *appctx)
if (spoe_appctx->status_code == SPOE_FRM_ERR_NONE)
spoe_appctx->status_code = SPOE_FRM_ERR_IO;
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
}
@ -2007,8 +2007,8 @@ spoe_handle_appctx(struct appctx *appctx)
appctx->st0 = SPOE_APPCTX_ST_END;
SPOE_APPCTX(appctx)->task->expire = TICK_ETERNITY;
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
/* fall through */

View File

@ -1936,8 +1936,8 @@ static void hlua_socket_handler(struct appctx *appctx)
struct stconn *cs = appctx_cs(appctx);
if (ctx->die) {
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
notification_wake(&ctx->wake_on_read);
notification_wake(&ctx->wake_on_write);
@ -9341,7 +9341,7 @@ void hlua_applet_tcp_fct(struct appctx *ctx)
/* eat the whole request */
co_skip(sc_oc(cs), co_data(sc_oc(cs)));
res->flags |= CF_READ_NULL;
cs_shutr(cs);
sc_shutr(cs);
return;
/* yield. */
@ -9386,8 +9386,8 @@ void hlua_applet_tcp_fct(struct appctx *ctx)
error:
/* For all other cases, just close the stream. */
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
tcp_ctx->flags |= APPLET_DONE;
}
@ -9624,7 +9624,7 @@ void hlua_applet_http_fct(struct appctx *ctx)
if (http_ctx->flags & APPLET_DONE) {
if (!(res->flags & CF_SHUTR)) {
res->flags |= CF_READ_NULL;
cs_shutr(cs);
sc_shutr(cs);
}
/* eat the whole request */

View File

@ -719,7 +719,7 @@ static enum act_parse_ret parse_http_set_status(const char **args, int *orig_arg
static enum act_return http_action_reject(struct act_rule *rule, struct proxy *px,
struct session *sess, struct stream *s, int flags)
{
cs_must_kill_conn(chn_prod(&s->req));
sc_must_kill_conn(chn_prod(&s->req));
channel_abort(&s->req);
channel_abort(&s->res);
s->req.analysers &= AN_REQ_FLT_END;

View File

@ -4313,8 +4313,8 @@ void http_perform_server_redirect(struct stream *s, struct stconn *cs)
goto fail;
/* return without error. */
cs_shutr(cs);
cs_shutw(cs);
sc_shutr(cs);
sc_shutw(cs);
s->conn_err_type = STRM_ET_NONE;
cs->state = SC_ST_CLO;

View File

@ -238,8 +238,8 @@ static int hc_cli_io_handler(struct appctx *appctx)
/* we must close only if F_END is the last flag */
if (ctx->flags == HC_CLI_F_RES_END) {
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
ctx->flags &= ~HC_CLI_F_RES_END;
goto out;
}
@ -933,8 +933,8 @@ more:
return;
end:
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
return;
}

View File

@ -3680,8 +3680,8 @@ cli_abort:
_HA_ATOMIC_INC(&frontend->fe_counters.cli_aborts);
close:
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;

View File

@ -3127,8 +3127,8 @@ send_msgs:
HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock);
curpeer = NULL;
}
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
goto out;
}

View File

@ -426,8 +426,8 @@ static void sink_forward_io_handler(struct appctx *appctx)
return;
close:
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
}
@ -570,8 +570,8 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
return;
close:
cs_shutw(cs);
cs_shutr(cs);
sc_shutw(cs);
sc_shutr(cs);
sc_ic(cs)->flags |= CF_READ_NULL;
}

View File

@ -4356,7 +4356,7 @@ static void http_stats_io_handler(struct appctx *appctx)
if (appctx->st0 == STAT_HTTP_END) {
if (!(res->flags & CF_SHUTR)) {
res->flags |= CF_READ_NULL;
cs_shutr(cs);
sc_shutr(cs);
}
/* eat the whole request */

View File

@ -936,7 +936,7 @@ static void back_establish(struct stream *s)
* delayed recv here to give a chance to the data to flow back
* by the time we process other tasks.
*/
cs_chk_rcv(s->scb);
sc_chk_rcv(s->scb);
}
req->wex = TICK_ETERNITY;
/* If we managed to get the whole response, and we don't have anything
@ -1680,26 +1680,26 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (unlikely((req->flags & (CF_SHUTW|CF_WRITE_TIMEOUT)) == CF_WRITE_TIMEOUT)) {
scb->flags |= SC_FL_NOLINGER;
cs_shutw(scb);
sc_shutw(scb);
}
if (unlikely((req->flags & (CF_SHUTR|CF_READ_TIMEOUT)) == CF_READ_TIMEOUT)) {
if (scf->flags & SC_FL_NOHALF)
scf->flags |= SC_FL_NOLINGER;
cs_shutr(scf);
sc_shutr(scf);
}
channel_check_timeouts(res);
if (unlikely((res->flags & (CF_SHUTW|CF_WRITE_TIMEOUT)) == CF_WRITE_TIMEOUT)) {
scf->flags |= SC_FL_NOLINGER;
cs_shutw(scf);
sc_shutw(scf);
}
if (unlikely((res->flags & (CF_SHUTR|CF_READ_TIMEOUT)) == CF_READ_TIMEOUT)) {
if (scb->flags & SC_FL_NOHALF)
scb->flags |= SC_FL_NOLINGER;
cs_shutr(scb);
sc_shutr(scb);
}
if (HAS_FILTERS(s))
@ -1754,8 +1754,8 @@ 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 (cs_state_in(scf->state, SC_SB_EST|SC_SB_DIS)) {
cs_shutr(scf);
cs_shutw(scf);
sc_shutr(scf);
sc_shutw(scf);
cs_report_error(scf);
if (!(req->analysers) && !(res->analysers)) {
_HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
@ -1774,8 +1774,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (unlikely(sc_ep_test(scb, SE_FL_ERROR))) {
if (cs_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) {
cs_shutr(scb);
cs_shutw(scb);
sc_shutr(scb);
sc_shutw(scb);
cs_report_error(scb);
_HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
if (srv)
@ -2308,7 +2308,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
channel_is_empty(req))) {
if (req->flags & CF_READ_ERROR)
scb->flags |= SC_FL_NOLINGER;
cs_shutw(scb);
sc_shutw(scb);
}
/* shutdown(write) done on server side, we must stop the client too */
@ -2320,7 +2320,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (unlikely((req->flags & (CF_SHUTR|CF_SHUTR_NOW)) == CF_SHUTR_NOW)) {
if (scf->flags & SC_FL_NOHALF)
scf->flags |= SC_FL_NOLINGER;
cs_shutr(scf);
sc_shutr(scf);
}
/* Benchmarks have shown that it's optimal to do a full resync now */
@ -2433,7 +2433,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
/* shutdown(write) pending */
if (unlikely((res->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW &&
channel_is_empty(res))) {
cs_shutw(scf);
sc_shutw(scf);
}
/* shutdown(write) done on the client side, we must stop the server too */
@ -2445,7 +2445,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (unlikely((res->flags & (CF_SHUTR|CF_SHUTR_NOW)) == CF_SHUTR_NOW)) {
if (scb->flags & SC_FL_NOHALF)
scb->flags |= SC_FL_NOLINGER;
cs_shutr(scb);
sc_shutr(scb);
}
if (scf->state == SC_ST_DIS ||

View File

@ -254,7 +254,7 @@ resume_execution:
_HA_ATOMIC_INC(&sess->listener->counters->failed_req);
reject:
cs_must_kill_conn(chn_prod(req));
sc_must_kill_conn(chn_prod(req));
channel_abort(req);
channel_abort(&s->res);
@ -392,9 +392,9 @@ resume_execution:
}
else if (rule->action == ACT_TCP_CLOSE) {
chn_prod(rep)->flags |= SC_FL_NOLINGER | SC_FL_NOHALF;
cs_must_kill_conn(chn_prod(rep));
cs_shutr(chn_prod(rep));
cs_shutw(chn_prod(rep));
sc_must_kill_conn(chn_prod(rep));
sc_shutr(chn_prod(rep));
sc_shutw(chn_prod(rep));
s->last_rule_file = rule->conf.file;
s->last_rule_line = rule->conf.line;
goto end;
@ -451,7 +451,7 @@ resume_execution:
_HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
reject:
cs_must_kill_conn(chn_prod(rep));
sc_must_kill_conn(chn_prod(rep));
channel_abort(rep);
channel_abort(&s->req);