CLEANUP: cli: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
in the various keyword handlers.
This commit is contained in:
Willy Tarreau 2022-05-27 10:26:46 +02:00
parent caff631bc0
commit 475e4636bc
13 changed files with 76 additions and 76 deletions

View File

@ -621,13 +621,13 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
unsigned long long tot_alloc_calls, tot_free_calls;
unsigned long long tot_alloc_bytes, tot_free_bytes;
#endif
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct buffer *name_buffer = get_trash_chunk();
const char *str;
int max_lines;
int i, max;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);
@ -840,7 +840,7 @@ static int cli_parse_show_profiling(char **args, char *payload, struct appctx *a
static int cli_io_handler_show_tasks(struct appctx *appctx)
{
struct sched_activity tmp_activity[256] __attribute__((aligned(64)));
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct buffer *name_buffer = get_trash_chunk();
struct sched_activity *entry;
const struct tasklet *tl;
@ -851,7 +851,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
int thr, queue;
int i, max;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
/* It's not possible to scan queues in small chunks and yield in the

View File

@ -897,14 +897,14 @@ static int cli_output_msg(struct channel *chn, const char *msg, int severity, in
*/
static void cli_io_handler(struct appctx *appctx)
{
struct stconn *cs = appctx_cs(appctx);
struct channel *req = sc_oc(cs);
struct channel *res = sc_ic(cs);
struct bind_conf *bind_conf = strm_li(__sc_strm(cs))->bind_conf;
struct stconn *sc = appctx_cs(appctx);
struct channel *req = sc_oc(sc);
struct channel *res = sc_ic(sc);
struct bind_conf *bind_conf = strm_li(__sc_strm(sc))->bind_conf;
int reql;
int len;
if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO))
if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
goto out;
/* Check if the input buffer is available. */
@ -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.
*/
sc_shutw(cs);
sc_shutw(sc);
free_trash_chunk(appctx->chunk);
appctx->chunk = NULL;
break;
@ -950,8 +950,8 @@ static void cli_io_handler(struct appctx *appctx)
/* ensure we have some output room left in the event we
* would want to return some info right after parsing.
*/
if (buffer_almost_full(sc_ib(cs))) {
sc_need_room(cs);
if (buffer_almost_full(sc_ib(sc))) {
sc_need_room(sc);
break;
}
@ -962,10 +962,10 @@ static void cli_io_handler(struct appctx *appctx)
*/
if (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD)
reql = co_getline(sc_oc(cs), str,
reql = co_getline(sc_oc(sc), str,
appctx->chunk->size - appctx->chunk->data - 1);
else
reql = co_getdelim(sc_oc(cs), str,
reql = co_getdelim(sc_oc(sc), str,
appctx->chunk->size - appctx->chunk->data - 1,
"\n;", '\\');
@ -1050,7 +1050,7 @@ static void cli_io_handler(struct appctx *appctx)
}
/* re-adjust req buffer */
co_skip(sc_oc(cs), reql);
co_skip(sc_oc(sc), reql);
req->flags |= CF_READ_DONTWAIT; /* we plan to read small requests */
}
else { /* output functions */
@ -1094,7 +1094,7 @@ static void cli_io_handler(struct appctx *appctx)
appctx->st0 = CLI_ST_PROMPT;
}
else
sc_need_room(cs);
sc_need_room(sc);
break;
case CLI_ST_CALLBACK: /* use custom pointer */
@ -1161,39 +1161,39 @@ static void cli_io_handler(struct appctx *appctx)
* refills the buffer with new bytes in non-interactive
* mode, avoiding to close on apparently empty commands.
*/
if (co_data(sc_oc(cs))) {
if (co_data(sc_oc(sc))) {
appctx_wakeup(appctx);
goto out;
}
}
}
if ((res->flags & CF_SHUTR) && (cs->state == SC_ST_EST)) {
DPRINTF(stderr, "%s@%d: cs to buf closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, cs->state);
if ((res->flags & CF_SHUTR) && (sc->state == SC_ST_EST)) {
DPRINTF(stderr, "%s@%d: sc to buf closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, sc->state);
/* Other side has closed, let's abort if we have no more processing to do
* and nothing more to consume. This is comparable to a broken pipe, so
* we forward the close to the request side so that it flows upstream to
* the client.
*/
sc_shutw(cs);
sc_shutw(sc);
}
if ((req->flags & CF_SHUTW) && (cs->state == SC_ST_EST) && (appctx->st0 < CLI_ST_OUTPUT)) {
DPRINTF(stderr, "%s@%d: buf to cs closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, cs->state);
if ((req->flags & CF_SHUTW) && (sc->state == SC_ST_EST) && (appctx->st0 < CLI_ST_OUTPUT)) {
DPRINTF(stderr, "%s@%d: buf to sc closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, sc->state);
/* We have no more processing to do, and nothing more to send, and
* the client side has closed. So we'll forward this state downstream
* on the response buffer.
*/
sc_shutr(cs);
sc_shutr(sc);
res->flags |= CF_READ_NULL;
}
out:
DPRINTF(stderr, "%s@%d: st=%d, rqf=%x, rpf=%x, rqh=%lu, rqs=%lu, rh=%lu, rs=%lu\n",
__FUNCTION__, __LINE__,
cs->state, req->flags, res->flags, ci_data(req), co_data(req), ci_data(res), co_data(res));
sc->state, req->flags, res->flags, ci_data(req), co_data(req), ci_data(res), co_data(res));
}
/* This is called when the stream connector is closed. For instance, upon an
@ -1224,10 +1224,10 @@ static void cli_release_handler(struct appctx *appctx)
static int cli_io_handler_show_env(struct appctx *appctx)
{
struct show_env_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
char **var = ctx->var;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);
@ -1259,12 +1259,12 @@ static int cli_io_handler_show_env(struct appctx *appctx)
*/
static int cli_io_handler_show_fd(struct appctx *appctx)
{
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct show_fd_ctx *fdctx = appctx->svcctx;
int fd = fdctx->fd;
int ret = 1;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto end;
chunk_reset(&trash);
@ -1458,10 +1458,10 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
*/
static int cli_io_handler_show_activity(struct appctx *appctx)
{
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
int thr;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);
@ -1969,9 +1969,9 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr
char *cmsgbuf = NULL;
unsigned char *tmpbuf = NULL;
struct cmsghdr *cmsg;
struct stconn *cs = appctx_cs(appctx);
struct stream *s = __sc_strm(cs);
struct connection *remote = sc_conn(sc_opposite(cs));
struct stconn *sc = appctx_cs(appctx);
struct stream *s = __sc_strm(sc);
struct connection *remote = sc_conn(sc_opposite(sc));
struct msghdr msghdr;
struct iovec iov;
struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };

View File

@ -290,10 +290,10 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
*/
static int cli_io_handler_show_threads(struct appctx *appctx)
{
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
int thr;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
if (appctx->st0)
@ -1043,7 +1043,7 @@ static int debug_parse_cli_fd(char **args, char *payload, struct appctx *appctx,
static int debug_iohandler_fd(struct appctx *appctx)
{
struct dev_fd_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct sockaddr_storage sa;
struct stat statbuf;
socklen_t salen, vlen;
@ -1052,7 +1052,7 @@ static int debug_iohandler_fd(struct appctx *appctx)
int ret = 1;
int i, fd;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto end;
chunk_reset(&trash);
@ -1237,11 +1237,11 @@ static int debug_parse_cli_memstats(char **args, char *payload, struct appctx *a
static int debug_iohandler_memstats(struct appctx *appctx)
{
struct dev_mem_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct mem_stats *ptr = ctx->start;
int ret = 1;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto end;
chunk_reset(&trash);

View File

@ -10143,15 +10143,15 @@ static int hlua_cli_io_handler_fct(struct appctx *appctx)
{
struct hlua_cli_ctx *ctx = appctx->svcctx;
struct hlua *hlua;
struct stconn *cs;
struct stconn *sc;
struct hlua_function *fcn;
hlua = ctx->hlua;
cs = appctx_cs(appctx);
sc = appctx_cs(appctx);
fcn = ctx->fcn;
/* If the stream is disconnect or closed, ldo nothing. */
if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO))
if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
return 1;
/* Execute the function. */
@ -10165,7 +10165,7 @@ static int hlua_cli_io_handler_fct(struct appctx *appctx)
case HLUA_E_AGAIN:
/* We want write. */
if (HLUA_IS_WAKERESWR(hlua))
sc_need_room(cs);
sc_need_room(sc);
/* Set the timeout. */
if (hlua->wake_time != TICK_ETERNITY)
task_schedule(hlua->task, hlua->wake_time);

View File

@ -195,7 +195,7 @@ err:
static int hc_cli_io_handler(struct appctx *appctx)
{
struct hcli_svc_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct buffer *trash = alloc_trash_chunk();
struct httpclient *hc = ctx->hc;
struct http_hdr *hdrs, *hdr;
@ -227,8 +227,8 @@ static int hc_cli_io_handler(struct appctx *appctx)
if (ctx->flags & HC_CLI_F_RES_BODY) {
int ret;
ret = httpclient_res_xfer(hc, sc_ib(cs));
channel_add_input(sc_ic(cs), ret); /* forward what we put in the buffer channel */
ret = httpclient_res_xfer(hc, sc_ib(sc));
channel_add_input(sc_ic(sc), ret); /* forward what we put in the buffer channel */
if (!httpclient_data(hc)) {/* remove the flag if the buffer was emptied */
ctx->flags &= ~HC_CLI_F_RES_BODY;
@ -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) {
sc_shutw(cs);
sc_shutr(cs);
sc_shutw(sc);
sc_shutr(sc);
ctx->flags &= ~HC_CLI_F_RES_END;
goto out;
}
@ -247,7 +247,7 @@ static int hc_cli_io_handler(struct appctx *appctx)
out:
/* we didn't clear every flags, we should come back to finish things */
if (ctx->flags)
sc_need_room(cs);
sc_need_room(sc);
free_trash_chunk(trash);
return 0;

View File

@ -345,10 +345,10 @@ struct show_map_ctx {
static int cli_io_handler_pat_list(struct appctx *appctx)
{
struct show_map_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct pat_ref_elt *elt;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
/* If we're forced to shut down, we might have to remove our
* reference to the last ref_elt being dumped.
*/

View File

@ -509,14 +509,14 @@ void mworker_cleanup_proc()
/* Displays workers and processes */
static int cli_io_handler_show_proc(struct appctx *appctx)
{
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct mworker_proc *child;
int old = 0;
int up = now.tv_sec - proc_self->timestamp;
char *uptime = NULL;
char *reloadtxt = NULL;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);

View File

@ -3771,7 +3771,7 @@ static int peers_dump_head(struct buffer *msg, struct appctx *appctx, struct pee
* Returns 0 if the output buffer is full and needs to be called again, non-zero
* if not. Dedicated to be called by cli_io_handler_show_peers() cli I/O handler.
*/
static int peers_dump_peer(struct buffer *msg, struct stconn *cs, struct peer *peer, int flags)
static int peers_dump_peer(struct buffer *msg, struct stconn *sc, struct peer *peer, int flags)
{
struct connection *conn;
char pn[INET6_ADDRSTRLEN];

View File

@ -2706,9 +2706,9 @@ static void dump_server_addr(const struct sockaddr_storage *addr, char *addr_str
* ->px, the proxy's id ->only_pxid, the server's pointer from ->sv, and the
* choice of what to dump from ->show_conn.
*/
static int dump_servers_state(struct stconn *cs)
static int dump_servers_state(struct stconn *sc)
{
struct appctx *appctx = __sc_appctx(cs);
struct appctx *appctx = __sc_appctx(sc);
struct show_srv_ctx *ctx = appctx->svcctx;
struct proxy *px = ctx->px;
struct server *srv;
@ -2786,7 +2786,7 @@ static int dump_servers_state(struct stconn *cs)
static int cli_io_handler_servers_state(struct appctx *appctx)
{
struct show_srv_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct proxy *curproxy;
if (ctx->state == SHOW_SRV_HEAD) {
@ -2810,7 +2810,7 @@ static int cli_io_handler_servers_state(struct appctx *appctx)
curproxy = ctx->px;
/* servers are only in backends */
if ((curproxy->cap & PR_CAP_BE) && !(curproxy->cap & PR_CAP_INT)) {
if (!dump_servers_state(cs))
if (!dump_servers_state(sc))
return 0;
}
/* only the selected proxy is dumped */
@ -3138,10 +3138,10 @@ static int cli_parse_show_errors(char **args, char *payload, struct appctx *appc
static int cli_io_handler_show_errors(struct appctx *appctx)
{
struct show_errors_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
extern const char *monthname[12];
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
chunk_reset(&trash);
@ -3296,7 +3296,7 @@ static int cli_io_handler_show_errors(struct appctx *appctx)
cant_send_unlock:
HA_RWLOCK_RDUNLOCK(PROXY_LOCK, &ctx->px->lock);
cant_send:
sc_need_room(cs);
sc_need_room(sc);
return 0;
}

View File

@ -290,7 +290,7 @@ int ring_attach_cli(struct ring *ring, struct appctx *appctx, uint flags)
int cli_io_handler_show_ring(struct appctx *appctx)
{
struct show_ring_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct ring *ring = ctx->ring;
struct buffer *buf = &ring->buf;
size_t ofs = ctx->ofs;
@ -298,7 +298,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
size_t len, cnt;
int ret;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
return 1;
HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
@ -373,7 +373,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
/* we've drained everything and are configured to wait for more
* data or an event (keypress, close)
*/
if (!sc_oc(cs)->output && !(sc_oc(cs)->flags & CF_SHUTW)) {
if (!sc_oc(sc)->output && !(sc_oc(sc)->flags & CF_SHUTW)) {
/* let's be woken up once new data arrive */
HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
LIST_APPEND(&ring->waiters, &appctx->wait_entry);
@ -382,7 +382,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
ret = 0;
}
/* always drain all the request */
co_skip(sc_oc(cs), sc_oc(cs)->output);
co_skip(sc_oc(sc), sc_oc(sc)->output);
}
return ret;
}

View File

@ -2044,7 +2044,7 @@ void ckch_store_replace(struct ckch_store *old_ckchs, struct ckch_store *new_ckc
static int cli_io_handler_commit_cert(struct appctx *appctx)
{
struct commit_cert_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
int y = 0;
char *err = NULL;
struct ckch_store *old_ckchs, *new_ckchs = NULL;
@ -2054,7 +2054,7 @@ static int cli_io_handler_commit_cert(struct appctx *appctx)
if (trash == NULL)
goto error;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto error;
while (1) {
@ -2785,7 +2785,7 @@ static inline int __create_new_instance(struct appctx *appctx, struct ckch_inst
static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx)
{
struct commit_cacrlfile_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
int y = 0;
char *err = NULL;
struct cafile_entry *old_cafile_entry = NULL, *new_cafile_entry = NULL;
@ -2795,7 +2795,7 @@ static int cli_io_handler_commit_cafile_crlfile(struct appctx *appctx)
if (trash == NULL)
goto error;
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto error;
while (1) {

View File

@ -1063,7 +1063,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx)
{
struct add_crtlist_ctx *ctx = appctx->svcctx;
struct bind_conf_list *bind_conf_node;
struct stconn *cs = appctx_cs(appctx);
struct stconn *sc = appctx_cs(appctx);
struct crtlist *crtlist = ctx->crtlist;
struct crtlist_entry *entry = ctx->entry;
struct ckch_store *store = entry->node.key;
@ -1079,7 +1079,7 @@ static int cli_io_handler_add_crtlist(struct appctx *appctx)
/* for each bind_conf which use the crt-list, a new ckch_inst must be
* created.
*/
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
goto error;
switch (ctx->state) {

View File

@ -4663,8 +4663,8 @@ err_args:
static int cli_io_handler_table(struct appctx *appctx)
{
struct show_table_ctx *ctx = appctx->svcctx;
struct stconn *cs = appctx_cs(appctx);
struct stream *s = __sc_strm(cs);
struct stconn *sc = appctx_cs(appctx);
struct stream *s = __sc_strm(sc);
struct ebmb_node *eb;
int skip_entry;
int show = ctx->action == STK_CLI_ACT_SHOW;
@ -4680,7 +4680,7 @@ static int cli_io_handler_table(struct appctx *appctx)
* data though.
*/
if (unlikely(sc_ic(cs)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
if (unlikely(sc_ic(sc)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
/* in case of abort, remove any refcount we might have set on an entry */
if (ctx->state == STATE_DUMP) {
stksess_kill_if_expired(ctx->t, ctx->entry, 1);