CLEANUP: stconn: rename cs_{new,create,free,destroy}_* to sc_*

This renames the following functions:

cs_new_from_endp()  -> sc_new_from_endp()
cs_new_from_strm()  -> sc_new_from_strm()
cs_new_from_check() -> sc_new_from_check()
cs_applet_create()  -> sc_applet_create()
cs_destroy()        -> sc_destroy()
cs_free()           -> sc_free()
This commit is contained in:
Willy Tarreau 2022-05-27 08:33:53 +02:00
parent 90e8b455b7
commit a0b58b537d
12 changed files with 39 additions and 39 deletions

View File

@ -38,18 +38,18 @@ struct check;
struct sedesc *sedesc_new(); struct sedesc *sedesc_new();
void sedesc_free(struct sedesc *sedesc); void sedesc_free(struct sedesc *sedesc);
struct stconn *cs_new_from_endp(struct sedesc *sedesc, struct session *sess, struct buffer *input); struct stconn *sc_new_from_endp(struct sedesc *sedesc, struct session *sess, struct buffer *input);
struct stconn *cs_new_from_strm(struct stream *strm, unsigned int flags); struct stconn *sc_new_from_strm(struct stream *strm, unsigned int flags);
struct stconn *cs_new_from_check(struct check *check, unsigned int flags); struct stconn *sc_new_from_check(struct check *check, unsigned int flags);
void cs_free(struct stconn *cs); void sc_free(struct stconn *cs);
int cs_attach_mux(struct stconn *cs, void *target, void *ctx); int cs_attach_mux(struct stconn *cs, void *target, void *ctx);
int cs_attach_strm(struct stconn *cs, struct stream *strm); int cs_attach_strm(struct stconn *cs, struct stream *strm);
void cs_destroy(struct stconn *cs); void sc_destroy(struct stconn *cs);
int cs_reset_endp(struct stconn *cs); int cs_reset_endp(struct stconn *cs);
struct appctx *cs_applet_create(struct stconn *cs, struct applet *app); struct appctx *sc_applet_create(struct stconn *cs, struct applet *app);
/* The se_fl_*() set of functions manipulate the stream endpoint flags from /* The se_fl_*() set of functions manipulate the stream endpoint flags from
* the stream endpoint itself. The sc_ep_*() set of functions manipulate the * the stream endpoint itself. The sc_ep_*() set of functions manipulate the

View File

@ -107,7 +107,7 @@ static inline struct stconn *qc_attach_cs(struct qcs *qcs, struct buffer *buf)
/* TODO duplicated from mux_h2 */ /* TODO duplicated from mux_h2 */
sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake; sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake;
if (!cs_new_from_endp(qcs->endp, sess, buf)) if (!sc_new_from_endp(qcs->endp, sess, buf))
return NULL; return NULL;
++qcc->nb_cs; ++qcc->nb_cs;

View File

@ -98,7 +98,7 @@ int appctx_finalize_startup(struct appctx *appctx, struct proxy *px, struct buff
sess = session_new(px, NULL, &appctx->obj_type); sess = session_new(px, NULL, &appctx->obj_type);
if (!sess) if (!sess)
return -1; return -1;
if (!cs_new_from_endp(appctx->sedesc, sess, input)) { if (!sc_new_from_endp(appctx->sedesc, sess, input)) {
session_free(sess); session_free(sess);
return -1; return -1;
} }

View File

@ -2175,7 +2175,7 @@ void back_handle_st_req(struct stream *s)
* in SC_ST_RDY state. So, try to create the appctx now. * in SC_ST_RDY state. So, try to create the appctx now.
*/ */
BUG_ON(sc_appctx(cs)); BUG_ON(sc_appctx(cs));
appctx = cs_applet_create(cs, objt_applet(s->target)); appctx = sc_applet_create(cs, objt_applet(s->target));
if (!appctx) { if (!appctx) {
/* No more memory, let's immediately abort. Force the /* No more memory, let's immediately abort. Force the
* error code to ignore the ERR_LOCAL which is not a * error code to ignore the ERR_LOCAL which is not a

View File

@ -1840,7 +1840,7 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
} }
s->target = &http_cache_applet.obj_type; s->target = &http_cache_applet.obj_type;
if ((appctx = cs_applet_create(s->scb, objt_applet(s->target)))) { if ((appctx = sc_applet_create(s->scb, objt_applet(s->target)))) {
struct cache_appctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx)); struct cache_appctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
appctx->st0 = HTX_CACHE_INIT; appctx->st0 = HTX_CACHE_INIT;

View File

@ -1119,7 +1119,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
check->current_step = NULL; check->current_step = NULL;
check->cs = cs_new_from_check(check, SC_FL_NONE); check->cs = sc_new_from_check(check, SC_FL_NONE);
if (!check->cs) { if (!check->cs) {
set_server_check_status(check, HCHK_STATUS_SOCKERR, NULL); set_server_check_status(check, HCHK_STATUS_SOCKERR, NULL);
goto end; goto end;
@ -1180,7 +1180,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
} }
if (cs) { if (cs) {
cs_destroy(cs); sc_destroy(cs);
cs = check->cs = NULL; cs = check->cs = NULL;
conn = NULL; conn = NULL;
} }
@ -1341,7 +1341,7 @@ void free_check(struct check *check)
check_release_buf(check, &check->bi); check_release_buf(check, &check->bi);
check_release_buf(check, &check->bo); check_release_buf(check, &check->bo);
if (check->cs) { if (check->cs) {
cs_destroy(check->cs); sc_destroy(check->cs);
check->cs = NULL; check->cs = NULL;
} }
} }

View File

@ -121,7 +121,7 @@ void sedesc_free(struct sedesc *sedesc)
* function. The caller must, at least, set the SE_FL_ORPHAN or SE_FL_DETACHED * function. The caller must, at least, set the SE_FL_ORPHAN or SE_FL_DETACHED
* flag. * flag.
*/ */
static struct stconn *cs_new(struct sedesc *sedesc) static struct stconn *sc_new(struct sedesc *sedesc)
{ {
struct stconn *cs; struct stconn *cs;
@ -161,11 +161,11 @@ static struct stconn *cs_new(struct sedesc *sedesc)
* defined. It returns NULL on error. On success, the new stream connector is * defined. It returns NULL on error. On success, the new stream connector is
* returned. In this case, SE_FL_ORPHAN flag is removed. * returned. In this case, SE_FL_ORPHAN flag is removed.
*/ */
struct stconn *cs_new_from_endp(struct sedesc *sedesc, struct session *sess, struct buffer *input) struct stconn *sc_new_from_endp(struct sedesc *sedesc, struct session *sess, struct buffer *input)
{ {
struct stconn *cs; struct stconn *cs;
cs = cs_new(sedesc); cs = sc_new(sedesc);
if (unlikely(!cs)) if (unlikely(!cs))
return NULL; return NULL;
if (unlikely(!stream_new(sess, cs, input))) { if (unlikely(!stream_new(sess, cs, input))) {
@ -177,14 +177,14 @@ struct stconn *cs_new_from_endp(struct sedesc *sedesc, struct session *sess, str
} }
/* Creates a new stream connector from an stream. There is no endpoint here, thus it /* Creates a new stream connector from an stream. There is no endpoint here, thus it
* will be created by cs_new(). So the SE_FL_DETACHED flag is set. It returns * will be created by sc_new(). So the SE_FL_DETACHED flag is set. It returns
* NULL on error. On success, the new stream connector is returned. * NULL on error. On success, the new stream connector is returned.
*/ */
struct stconn *cs_new_from_strm(struct stream *strm, unsigned int flags) struct stconn *sc_new_from_strm(struct stream *strm, unsigned int flags)
{ {
struct stconn *cs; struct stconn *cs;
cs = cs_new(NULL); cs = sc_new(NULL);
if (unlikely(!cs)) if (unlikely(!cs))
return NULL; return NULL;
cs->flags |= flags; cs->flags |= flags;
@ -195,14 +195,14 @@ struct stconn *cs_new_from_strm(struct stream *strm, unsigned int flags)
} }
/* Creates a new stream connector from an health-check. There is no endpoint here, /* Creates a new stream connector from an health-check. There is no endpoint here,
* thus it will be created by cs_new(). So the SE_FL_DETACHED flag is set. It * thus it will be created by sc_new(). So the SE_FL_DETACHED flag is set. It
* returns NULL on error. On success, the new stream connector is returned. * returns NULL on error. On success, the new stream connector is returned.
*/ */
struct stconn *cs_new_from_check(struct check *check, unsigned int flags) struct stconn *sc_new_from_check(struct check *check, unsigned int flags)
{ {
struct stconn *cs; struct stconn *cs;
cs = cs_new(NULL); cs = sc_new(NULL);
if (unlikely(!cs)) if (unlikely(!cs))
return NULL; return NULL;
cs->flags |= flags; cs->flags |= flags;
@ -212,10 +212,10 @@ struct stconn *cs_new_from_check(struct check *check, unsigned int flags)
return cs; return cs;
} }
/* Releases a stconn previously allocated by cs_new(), as well as its /* Releases a stconn previously allocated by sc_new(), as well as its
* endpoint, if it exists. This function is called internally or on error path. * endpoint, if it exists. This function is called internally or on error path.
*/ */
void cs_free(struct stconn *cs) void sc_free(struct stconn *cs)
{ {
sockaddr_free(&cs->src); sockaddr_free(&cs->src);
sockaddr_free(&cs->dst); sockaddr_free(&cs->dst);
@ -232,12 +232,12 @@ void cs_free(struct stconn *cs)
* layer defined. Except on error path, this one must be used. if release, the * layer defined. Except on error path, this one must be used. if release, the
* pointer on the CS is set to NULL. * pointer on the CS is set to NULL.
*/ */
static void cs_free_cond(struct stconn **csp) static void sc_free_cond(struct stconn **csp)
{ {
struct stconn *cs = *csp; struct stconn *cs = *csp;
if (!cs->app && (!cs->sedesc || sc_ep_test(cs, SE_FL_DETACHED))) { if (!cs->app && (!cs->sedesc || sc_ep_test(cs, SE_FL_DETACHED))) {
cs_free(cs); sc_free(cs);
*csp = NULL; *csp = NULL;
} }
} }
@ -394,7 +394,7 @@ static void cs_detach_endp(struct stconn **csp)
cs->app_ops = &sc_app_embedded_ops; cs->app_ops = &sc_app_embedded_ops;
else else
cs->app_ops = NULL; cs->app_ops = NULL;
cs_free_cond(csp); sc_free_cond(csp);
} }
/* Detaches the stconn from the app layer. If there is no endpoint attached /* Detaches the stconn from the app layer. If there is no endpoint attached
@ -416,13 +416,13 @@ static void cs_detach_app(struct stconn **csp)
tasklet_free(cs->wait_event.tasklet); tasklet_free(cs->wait_event.tasklet);
cs->wait_event.tasklet = NULL; cs->wait_event.tasklet = NULL;
cs->wait_event.events = 0; cs->wait_event.events = 0;
cs_free_cond(csp); sc_free_cond(csp);
} }
/* Destroy the stconn. It is detached from its endpoint and its /* Destroy the stconn. It is detached from its endpoint and its
* application. After this call, the stconn must be considered as released. * application. After this call, the stconn must be considered as released.
*/ */
void cs_destroy(struct stconn *cs) void sc_destroy(struct stconn *cs)
{ {
cs_detach_endp(&cs); cs_detach_endp(&cs);
cs_detach_app(&cs); cs_detach_app(&cs);
@ -478,7 +478,7 @@ int cs_reset_endp(struct stconn *cs)
* It also pre-initializes the applet's context and returns it (or NULL in case * It also pre-initializes the applet's context and returns it (or NULL in case
* it could not be allocated). * it could not be allocated).
*/ */
struct appctx *cs_applet_create(struct stconn *cs, struct applet *app) struct appctx *sc_applet_create(struct stconn *cs, struct applet *app)
{ {
struct appctx *appctx; struct appctx *appctx;

View File

@ -430,7 +430,7 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
*/ */
if (!s->target && http_stats_check_uri(s, txn, px)) { if (!s->target && http_stats_check_uri(s, txn, px)) {
s->target = &http_stats_applet.obj_type; s->target = &http_stats_applet.obj_type;
if (unlikely(!cs_applet_create(s->scb, objt_applet(s->target)))) { if (unlikely(!sc_applet_create(s->scb, objt_applet(s->target)))) {
s->logs.tv_request = now; s->logs.tv_request = now;
if (!(s->flags & SF_ERR_MASK)) if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_RESOURCE; s->flags |= SF_ERR_RESOURCE;

View File

@ -732,7 +732,7 @@ static struct stconn *h1s_new_cs(struct h1s *h1s, struct buffer *input)
if (h1s->req.flags & H1_MF_UPG_WEBSOCKET) if (h1s->req.flags & H1_MF_UPG_WEBSOCKET)
se_fl_set(h1s->endp, SE_FL_WEBSOCKET); se_fl_set(h1s->endp, SE_FL_WEBSOCKET);
if (!cs_new_from_endp(h1s->endp, h1c->conn->owner, input)) { if (!sc_new_from_endp(h1s->endp, h1c->conn->owner, input)) {
TRACE_ERROR("CS allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s); TRACE_ERROR("CS allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
goto err; goto err;
} }

View File

@ -1635,7 +1635,7 @@ static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *in
*/ */
sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake; sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake;
if (!cs_new_from_endp(h2s->endp, sess, input)) if (!sc_new_from_endp(h2s->endp, sess, input))
goto out_close; goto out_close;
h2c->nb_cs++; h2c->nb_cs++;

View File

@ -308,7 +308,7 @@ static int mux_pt_init(struct connection *conn, struct proxy *prx, struct sessio
ctx->endp->conn = conn; ctx->endp->conn = conn;
se_fl_set(ctx->endp, SE_FL_T_MUX | SE_FL_ORPHAN); se_fl_set(ctx->endp, SE_FL_T_MUX | SE_FL_ORPHAN);
cs = cs_new_from_endp(ctx->endp, sess, input); cs = sc_new_from_endp(ctx->endp, sess, input);
if (!cs) { if (!cs) {
TRACE_ERROR("CS allocation failure", PT_EV_STRM_NEW|PT_EV_STRM_END|PT_EV_STRM_ERR, conn); TRACE_ERROR("CS allocation failure", PT_EV_STRM_NEW|PT_EV_STRM_END|PT_EV_STRM_ERR, conn);
goto fail_free_endp; goto fail_free_endp;

View File

@ -449,7 +449,7 @@ struct stream *stream_new(struct session *sess, struct stconn *cs, struct buffer
if (cs_attach_strm(s->scf, s) < 0) if (cs_attach_strm(s->scf, s) < 0)
goto out_fail_attach_scf; goto out_fail_attach_scf;
s->scb = cs_new_from_strm(s, SC_FL_ISBACK); s->scb = sc_new_from_strm(s, SC_FL_ISBACK);
if (!s->scb) if (!s->scb)
goto out_fail_alloc_scb; goto out_fail_alloc_scb;
@ -568,7 +568,7 @@ struct stream *stream_new(struct session *sess, struct stconn *cs, struct buffer
flt_stream_release(s, 0); flt_stream_release(s, 0);
LIST_DELETE(&s->list); LIST_DELETE(&s->list);
out_fail_attach_scf: out_fail_attach_scf:
cs_free(s->scb); sc_free(s->scb);
out_fail_alloc_scb: out_fail_alloc_scb:
task_destroy(t); task_destroy(t);
out_fail_alloc: out_fail_alloc:
@ -708,8 +708,8 @@ void stream_free(struct stream *s)
} }
LIST_DELETE(&s->list); LIST_DELETE(&s->list);
cs_destroy(s->scb); sc_destroy(s->scb);
cs_destroy(s->scf); sc_destroy(s->scf);
pool_free(pool_head_stream, s); pool_free(pool_head_stream, s);
@ -992,7 +992,7 @@ enum act_return process_use_service(struct act_rule *rule, struct proxy *px,
if (flags & ACT_OPT_FIRST) { if (flags & ACT_OPT_FIRST) {
/* Register applet. this function schedules the applet. */ /* Register applet. this function schedules the applet. */
s->target = &rule->applet.obj_type; s->target = &rule->applet.obj_type;
appctx = cs_applet_create(s->scb, objt_applet(s->target)); appctx = sc_applet_create(s->scb, objt_applet(s->target));
if (unlikely(!appctx)) if (unlikely(!appctx))
return ACT_RET_ERR; return ACT_RET_ERR;