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

In the applet, function arguments and local variables called "cs"
were renamed to "sc" to avoid future confusion.
This commit is contained in:
Willy Tarreau 2022-05-27 10:44:04 +02:00
parent 7577d9d99c
commit da30490b9c

View File

@ -1167,10 +1167,10 @@ static int peer_get_version(const char *str,
*/ */
static inline int peer_getline(struct appctx *appctx) static inline int peer_getline(struct appctx *appctx)
{ {
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
int n; int n;
n = co_getline(sc_oc(cs), trash.area, trash.size); n = co_getline(sc_oc(sc), trash.area, trash.size);
if (!n) if (!n)
return 0; return 0;
@ -1184,7 +1184,7 @@ static inline int peer_getline(struct appctx *appctx)
else else
trash.area[n - 1] = 0; trash.area[n - 1] = 0;
co_skip(sc_oc(cs), n); co_skip(sc_oc(sc), n);
return n; return n;
} }
@ -1201,7 +1201,7 @@ static inline int peer_send_msg(struct appctx *appctx,
struct peer_prep_params *params) struct peer_prep_params *params)
{ {
int ret, msglen; int ret, msglen;
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
msglen = peer_prepare_msg(trash.area, trash.size, params); msglen = peer_prepare_msg(trash.area, trash.size, params);
if (!msglen) { if (!msglen) {
@ -1211,11 +1211,11 @@ static inline int peer_send_msg(struct appctx *appctx,
} }
/* message to buffer */ /* message to buffer */
ret = ci_putblk(sc_ic(cs), trash.area, msglen); ret = ci_putblk(sc_ic(sc), trash.area, msglen);
if (ret <= 0) { if (ret <= 0) {
if (ret == -1) { if (ret == -1) {
/* No more write possible */ /* No more write possible */
sc_need_room(cs); sc_need_room(sc);
return -1; return -1;
} }
appctx->st0 = PEER_SESS_ST_END; appctx->st0 = PEER_SESS_ST_END;
@ -1681,7 +1681,7 @@ static inline int peer_send_teach_stage2_msgs(struct appctx *appctx, struct peer
static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt, int exp, static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt, int exp,
char **msg_cur, char *msg_end, int msg_len, int totl) char **msg_cur, char *msg_end, int msg_len, int totl)
{ {
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
struct shared_table *st = p->remote_table; struct shared_table *st = p->remote_table;
struct stksess *ts, *newts; struct stksess *ts, *newts;
uint32_t update; uint32_t update;
@ -2024,7 +2024,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
ignore_msg: ignore_msg:
/* skip consumed message */ /* skip consumed message */
co_skip(sc_oc(cs), totl); co_skip(sc_oc(sc), totl);
TRACE_DEVEL("leaving in error", PEERS_EV_UPDTMSG); TRACE_DEVEL("leaving in error", PEERS_EV_UPDTMSG);
return 0; return 0;
@ -2133,7 +2133,7 @@ static inline int peer_treat_switchmsg(struct appctx *appctx, struct peer *p,
static inline int peer_treat_definemsg(struct appctx *appctx, struct peer *p, static inline int peer_treat_definemsg(struct appctx *appctx, struct peer *p,
char **msg_cur, char *msg_end, int totl) char **msg_cur, char *msg_end, int totl)
{ {
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
int table_id_len; int table_id_len;
struct shared_table *st; struct shared_table *st;
int table_type; int table_type;
@ -2307,7 +2307,7 @@ static inline int peer_treat_definemsg(struct appctx *appctx, struct peer *p,
return 1; return 1;
ignore_msg: ignore_msg:
co_skip(sc_oc(cs), totl); co_skip(sc_oc(sc), totl);
return 0; return 0;
malformed_exit: malformed_exit:
@ -2332,10 +2332,10 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
uint32_t *msg_len, int *totl) uint32_t *msg_len, int *totl)
{ {
int reql; int reql;
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
char *cur; char *cur;
reql = co_getblk(sc_oc(cs), msg_head, 2 * sizeof(char), *totl); reql = co_getblk(sc_oc(sc), msg_head, 2 * sizeof(char), *totl);
if (reql <= 0) /* closed or EOL not found */ if (reql <= 0) /* closed or EOL not found */
goto incomplete; goto incomplete;
@ -2349,11 +2349,11 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
/* Read and Decode message length */ /* Read and Decode message length */
msg_head += *totl; msg_head += *totl;
msg_head_sz -= *totl; msg_head_sz -= *totl;
reql = co_data(sc_oc(cs)) - *totl; reql = co_data(sc_oc(sc)) - *totl;
if (reql > msg_head_sz) if (reql > msg_head_sz)
reql = msg_head_sz; reql = msg_head_sz;
reql = co_getblk(sc_oc(cs), msg_head, reql, *totl); reql = co_getblk(sc_oc(sc), msg_head, reql, *totl);
if (reql <= 0) /* closed */ if (reql <= 0) /* closed */
goto incomplete; goto incomplete;
@ -2379,7 +2379,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
return -1; return -1;
} }
reql = co_getblk(sc_oc(cs), trash.area, *msg_len, *totl); reql = co_getblk(sc_oc(sc), trash.area, *msg_len, *totl);
if (reql <= 0) /* closed */ if (reql <= 0) /* closed */
goto incomplete; goto incomplete;
*totl += reql; *totl += reql;
@ -2388,7 +2388,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
return 1; return 1;
incomplete: incomplete:
if (reql < 0 || (sc_oc(cs)->flags & (CF_SHUTW|CF_SHUTW_NOW))) { if (reql < 0 || (sc_oc(sc)->flags & (CF_SHUTW|CF_SHUTW_NOW))) {
/* there was an error or the message was truncated */ /* there was an error or the message was truncated */
appctx->st0 = PEER_SESS_ST_END; appctx->st0 = PEER_SESS_ST_END;
return -1; return -1;
@ -2850,8 +2850,8 @@ static inline void init_connected_peer(struct peer *peer, struct peers *peers)
*/ */
static void peer_io_handler(struct appctx *appctx) static void peer_io_handler(struct appctx *appctx)
{ {
struct stconn *cs = appctx_cs(appctx); struct stconn *sc = appctx_cs(appctx);
struct stream *s = __sc_strm(cs); struct stream *s = __sc_strm(sc);
struct peers *curpeers = strm_fe(s)->parent; struct peers *curpeers = strm_fe(s)->parent;
struct peer *curpeer = NULL; struct peer *curpeer = NULL;
int reql = 0; int reql = 0;
@ -2860,8 +2860,8 @@ static void peer_io_handler(struct appctx *appctx)
int prev_state; int prev_state;
/* Check if the input buffer is available. */ /* Check if the input buffer is available. */
if (sc_ib(cs)->size == 0) { if (sc_ib(sc)->size == 0) {
sc_need_room(cs); sc_need_room(sc);
goto out; goto out;
} }
@ -2997,7 +2997,7 @@ switchstate:
} }
} }
if (sc_ic(cs)->flags & CF_WRITE_PARTIAL) if (sc_ic(sc)->flags & CF_WRITE_PARTIAL)
curpeer->statuscode = PEER_SESS_SC_CONNECTEDCODE; curpeer->statuscode = PEER_SESS_SC_CONNECTEDCODE;
reql = peer_getline(appctx); reql = peer_getline(appctx);
@ -3060,7 +3060,7 @@ switchstate:
curpeer->flags |= PEER_F_ALIVE; curpeer->flags |= PEER_F_ALIVE;
/* skip consumed message */ /* skip consumed message */
co_skip(sc_oc(cs), totl); co_skip(sc_oc(sc), totl);
/* loop on that state to peek next message */ /* loop on that state to peek next message */
goto switchstate; goto switchstate;
@ -3127,15 +3127,15 @@ send_msgs:
HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock); HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock);
curpeer = NULL; curpeer = NULL;
} }
sc_shutw(cs); sc_shutw(sc);
sc_shutr(cs); sc_shutr(sc);
sc_ic(cs)->flags |= CF_READ_NULL; sc_ic(sc)->flags |= CF_READ_NULL;
goto out; goto out;
} }
} }
} }
out: out:
sc_oc(cs)->flags |= CF_READ_DONTWAIT; sc_oc(sc)->flags |= CF_READ_DONTWAIT;
if (curpeer) if (curpeer)
HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock); HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock);