CLEANUP: stconn: rename cs_conn_*() to sc_conn_*()

The following functions which act on a connection-based stream connector
were renamed to sc_conn_* (~60 places):

  cs_conn_drain_and_shut
  cs_conn_process
  cs_conn_read0
  cs_conn_ready
  cs_conn_recv
  cs_conn_send
  cs_conn_shut
  cs_conn_shutr
  cs_conn_shutw
This commit is contained in:
Willy Tarreau 2022-05-18 18:06:53 +02:00
parent f8d0ab54ec
commit 462b989d4c
8 changed files with 55 additions and 55 deletions

View File

@ -227,7 +227,7 @@ static inline const char *sc_get_data_name(const struct stconn *cs)
} }
/* shut read */ /* shut read */
static inline void cs_conn_shutr(struct stconn *cs, enum co_shr_mode mode) static inline void sc_conn_shutr(struct stconn *cs, enum co_shr_mode mode)
{ {
const struct mux_ops *mux; const struct mux_ops *mux;
@ -244,7 +244,7 @@ static inline void cs_conn_shutr(struct stconn *cs, enum co_shr_mode mode)
} }
/* shut write */ /* shut write */
static inline void cs_conn_shutw(struct stconn *cs, enum co_shw_mode mode) static inline void sc_conn_shutw(struct stconn *cs, enum co_shw_mode mode)
{ {
const struct mux_ops *mux; const struct mux_ops *mux;
@ -261,17 +261,17 @@ static inline void cs_conn_shutw(struct stconn *cs, enum co_shw_mode mode)
} }
/* completely close a stream connector (but do not detach it) */ /* completely close a stream connector (but do not detach it) */
static inline void cs_conn_shut(struct stconn *cs) static inline void sc_conn_shut(struct stconn *cs)
{ {
cs_conn_shutw(cs, CO_SHW_SILENT); sc_conn_shutw(cs, CO_SHW_SILENT);
cs_conn_shutr(cs, CO_SHR_RESET); sc_conn_shutr(cs, CO_SHR_RESET);
} }
/* completely close a stream connector after draining possibly pending data (but do not detach it) */ /* completely close a stream connector after draining possibly pending data (but do not detach it) */
static inline void cs_conn_drain_and_shut(struct stconn *cs) static inline void sc_conn_drain_and_shut(struct stconn *cs)
{ {
cs_conn_shutw(cs, CO_SHW_SILENT); sc_conn_shutw(cs, CO_SHW_SILENT);
cs_conn_shutr(cs, CO_SHR_DRAIN); sc_conn_shutr(cs, CO_SHR_DRAIN);
} }
/* sets SE_FL_ERROR or SE_FL_ERR_PENDING on the endpoint */ /* sets SE_FL_ERROR or SE_FL_ERR_PENDING on the endpoint */

View File

@ -36,9 +36,9 @@
void cs_update_rx(struct stconn *cs); void cs_update_rx(struct stconn *cs);
void cs_update_tx(struct stconn *cs); void cs_update_tx(struct stconn *cs);
struct task *cs_conn_io_cb(struct task *t, void *ctx, unsigned int state); struct task *sc_conn_io_cb(struct task *t, void *ctx, unsigned int state);
int cs_conn_sync_recv(struct stconn *cs); int sc_conn_sync_recv(struct stconn *cs);
void cs_conn_sync_send(struct stconn *cs); void sc_conn_sync_send(struct stconn *cs);
/* returns the channel which receives data from this stream connector (input channel) */ /* returns the channel which receives data from this stream connector (input channel) */
@ -120,7 +120,7 @@ static inline int cs_state_in(enum cs_state state, enum cs_state_bit mask)
/* Returns true if a connection is attached to the stream connector <cs> and if this /* Returns true if a connection is attached to the stream connector <cs> and if this
* connection is ready. * connection is ready.
*/ */
static inline int cs_conn_ready(struct stconn *cs) static inline int sc_conn_ready(struct stconn *cs)
{ {
struct connection *conn = sc_conn(cs); struct connection *conn = sc_conn(cs);

View File

@ -1176,7 +1176,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
* as a failed response coupled with "observe layer7" caused the * as a failed response coupled with "observe layer7" caused the
* server state to be suddenly changed. * server state to be suddenly changed.
*/ */
cs_conn_drain_and_shut(cs); sc_conn_drain_and_shut(cs);
} }
if (cs) { if (cs) {

View File

@ -2766,7 +2766,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
/* only release our endpoint if we don't intend to reuse the /* only release our endpoint if we don't intend to reuse the
* connection. * connection.
*/ */
if (!cs_conn_ready(s->scb)) { if (!sc_conn_ready(s->scb)) {
s->srv_conn = NULL; s->srv_conn = NULL;
if (cs_reset_endp(s->scb) < 0) { if (cs_reset_endp(s->scb) < 0) {
if (!s->conn_err_type) if (!s->conn_err_type)

View File

@ -41,9 +41,9 @@ static void sc_app_shutw_applet(struct stconn *cs);
static void sc_app_chk_rcv_applet(struct stconn *cs); static void sc_app_chk_rcv_applet(struct stconn *cs);
static void sc_app_chk_snd_applet(struct stconn *cs); static void sc_app_chk_snd_applet(struct stconn *cs);
static int cs_conn_process(struct stconn *cs); static int sc_conn_process(struct stconn *cs);
static int cs_conn_recv(struct stconn *cs); static int sc_conn_recv(struct stconn *cs);
static int cs_conn_send(struct stconn *cs); static int sc_conn_send(struct stconn *cs);
static int cs_applet_process(struct stconn *cs); static int cs_applet_process(struct stconn *cs);
/* stream connector operations for connections */ /* stream connector operations for connections */
@ -52,7 +52,7 @@ struct sc_app_ops sc_app_conn_ops = {
.chk_snd = sc_app_chk_snd_conn, .chk_snd = sc_app_chk_snd_conn,
.shutr = sc_app_shutr_conn, .shutr = sc_app_shutr_conn,
.shutw = sc_app_shutw_conn, .shutw = sc_app_shutw_conn,
.wake = cs_conn_process, .wake = sc_conn_process,
.name = "STRM", .name = "STRM",
}; };
@ -263,7 +263,7 @@ int cs_attach_mux(struct stconn *cs, void *endp, void *ctx)
cs->wait_event.tasklet = tasklet_new(); cs->wait_event.tasklet = tasklet_new();
if (!cs->wait_event.tasklet) if (!cs->wait_event.tasklet)
return -1; return -1;
cs->wait_event.tasklet->process = cs_conn_io_cb; cs->wait_event.tasklet->process = sc_conn_io_cb;
cs->wait_event.tasklet->context = cs; cs->wait_event.tasklet->context = cs;
cs->wait_event.events = 0; cs->wait_event.events = 0;
} }
@ -312,7 +312,7 @@ int cs_attach_strm(struct stconn *cs, struct stream *strm)
cs->wait_event.tasklet = tasklet_new(); cs->wait_event.tasklet = tasklet_new();
if (!cs->wait_event.tasklet) if (!cs->wait_event.tasklet)
return -1; return -1;
cs->wait_event.tasklet->process = cs_conn_io_cb; cs->wait_event.tasklet->process = sc_conn_io_cb;
cs->wait_event.tasklet->context = cs; cs->wait_event.tasklet->context = cs;
cs->wait_event.events = 0; cs->wait_event.events = 0;
@ -661,7 +661,7 @@ static void sc_app_shutr_conn(struct stconn *cs)
return; return;
if (sc_oc(cs)->flags & CF_SHUTW) { if (sc_oc(cs)->flags & CF_SHUTW) {
cs_conn_shut(cs); sc_conn_shut(cs);
cs->state = SC_ST_DIS; cs->state = SC_ST_DIS;
__sc_strm(cs)->conn_exp = TICK_ETERNITY; __sc_strm(cs)->conn_exp = TICK_ETERNITY;
} }
@ -717,7 +717,7 @@ static void sc_app_shutw_conn(struct stconn *cs)
* option abortonclose. No need for the TLS layer to try to * option abortonclose. No need for the TLS layer to try to
* emit a shutdown message. * emit a shutdown message.
*/ */
cs_conn_shutw(cs, CO_SHW_SILENT); sc_conn_shutw(cs, CO_SHW_SILENT);
} }
else { else {
/* clean data-layer shutdown. This only happens on the /* clean data-layer shutdown. This only happens on the
@ -726,7 +726,7 @@ static void sc_app_shutw_conn(struct stconn *cs)
* while option abortonclose is set. We want the TLS * while option abortonclose is set. We want the TLS
* layer to try to signal it to the peer before we close. * layer to try to signal it to the peer before we close.
*/ */
cs_conn_shutw(cs, CO_SHW_NORMAL); sc_conn_shutw(cs, CO_SHW_NORMAL);
if (!(ic->flags & (CF_SHUTR|CF_DONT_READ))) if (!(ic->flags & (CF_SHUTR|CF_DONT_READ)))
return; return;
@ -737,7 +737,7 @@ static void sc_app_shutw_conn(struct stconn *cs)
/* we may have to close a pending connection, and mark the /* we may have to close a pending connection, and mark the
* response buffer as shutr * response buffer as shutr
*/ */
cs_conn_shut(cs); sc_conn_shut(cs);
/* fall through */ /* fall through */
case SC_ST_CER: case SC_ST_CER:
case SC_ST_QUE: case SC_ST_QUE:
@ -792,7 +792,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs)
return; return;
if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(sc_oc(cs))) if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(sc_oc(cs)))
cs_conn_send(cs); sc_conn_send(cs);
if (sc_ep_test(cs, SE_FL_ERROR | SE_FL_ERR_PENDING) || cs_is_conn_error(cs)) { if (sc_ep_test(cs, SE_FL_ERROR | SE_FL_ERR_PENDING) || cs_is_conn_error(cs)) {
/* Write error on the file descriptor */ /* Write error on the file descriptor */
@ -1237,7 +1237,7 @@ static void cs_notify(struct stconn *cs)
* It updates the stream connector. If the stream connector has SC_FL_NOHALF, * It updates the stream connector. If the stream connector has SC_FL_NOHALF,
* the close is also forwarded to the write side as an abort. * the close is also forwarded to the write side as an abort.
*/ */
static void cs_conn_read0(struct stconn *cs) static void sc_conn_read0(struct stconn *cs)
{ {
struct channel *ic = sc_ic(cs); struct channel *ic = sc_ic(cs);
struct channel *oc = sc_oc(cs); struct channel *oc = sc_oc(cs);
@ -1259,7 +1259,7 @@ static void cs_conn_read0(struct stconn *cs)
if (cs->flags & SC_FL_NOHALF) { if (cs->flags & SC_FL_NOHALF) {
/* we want to immediately forward this close to the write side */ /* we want to immediately forward this close to the write side */
/* force flag on ssl to keep stream in cache */ /* force flag on ssl to keep stream in cache */
cs_conn_shutw(cs, CO_SHW_SILENT); sc_conn_shutw(cs, CO_SHW_SILENT);
goto do_close; goto do_close;
} }
@ -1268,7 +1268,7 @@ static void cs_conn_read0(struct stconn *cs)
do_close: 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 cs_shut[rw]() */
cs_conn_shut(cs); sc_conn_shut(cs);
oc->flags &= ~CF_SHUTW_NOW; oc->flags &= ~CF_SHUTW_NOW;
oc->flags |= CF_SHUTW; oc->flags |= CF_SHUTW;
@ -1286,7 +1286,7 @@ static void cs_conn_read0(struct stconn *cs)
* into the buffer from the connection. It iterates over the mux layer's * into the buffer from the connection. It iterates over the mux layer's
* rcv_buf function. * rcv_buf function.
*/ */
static int cs_conn_recv(struct stconn *cs) static int sc_conn_recv(struct stconn *cs)
{ {
struct connection *conn = __sc_conn(cs); struct connection *conn = __sc_conn(cs);
struct channel *ic = sc_ic(cs); struct channel *ic = sc_ic(cs);
@ -1298,7 +1298,7 @@ static int cs_conn_recv(struct stconn *cs)
if (cs->state != SC_ST_EST) if (cs->state != SC_ST_EST)
return 0; return 0;
/* If another call to cs_conn_recv() failed, and we subscribed to /* If another call to sc_conn_recv() failed, and we subscribed to
* recv events already, give up now. * recv events already, give up now.
*/ */
if (cs->wait_event.events & SUB_RETRY_RECV) if (cs->wait_event.events & SUB_RETRY_RECV)
@ -1596,7 +1596,7 @@ static int cs_conn_recv(struct stconn *cs)
ic->flags |= CF_READ_NULL; ic->flags |= CF_READ_NULL;
if (ic->flags & CF_AUTO_CLOSE) if (ic->flags & CF_AUTO_CLOSE)
channel_shutw_now(ic); channel_shutw_now(ic);
cs_conn_read0(cs); sc_conn_read0(cs);
ret = 1; ret = 1;
} }
else if (!cs_rx_blocked(cs)) { else if (!cs_rx_blocked(cs)) {
@ -1617,7 +1617,7 @@ static int cs_conn_recv(struct stconn *cs)
* to be programmed and performed later, though it doesn't provide any * to be programmed and performed later, though it doesn't provide any
* such guarantee. * such guarantee.
*/ */
int cs_conn_sync_recv(struct stconn *cs) int sc_conn_sync_recv(struct stconn *cs)
{ {
if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST))
return 0; return 0;
@ -1631,7 +1631,7 @@ int cs_conn_sync_recv(struct stconn *cs)
if (!cs_rx_endp_ready(cs) || cs_rx_blocked(cs)) if (!cs_rx_endp_ready(cs) || cs_rx_blocked(cs))
return 0; // already failed return 0; // already failed
return cs_conn_recv(cs); return sc_conn_recv(cs);
} }
/* /*
@ -1640,7 +1640,7 @@ int cs_conn_sync_recv(struct stconn *cs)
* caller to commit polling changes. The caller should check conn->flags * caller to commit polling changes. The caller should check conn->flags
* for errors. * for errors.
*/ */
static int cs_conn_send(struct stconn *cs) static int sc_conn_send(struct stconn *cs)
{ {
struct connection *conn = __sc_conn(cs); struct connection *conn = __sc_conn(cs);
struct stream *s = __sc_strm(cs); struct stream *s = __sc_strm(cs);
@ -1785,7 +1785,7 @@ static int cs_conn_send(struct stconn *cs)
* CF_WRITE_PARTIAL flags are cleared prior to the attempt, and will possibly * CF_WRITE_PARTIAL flags are cleared prior to the attempt, and will possibly
* be updated in case of success. * be updated in case of success.
*/ */
void cs_conn_sync_send(struct stconn *cs) void sc_conn_sync_send(struct stconn *cs)
{ {
struct channel *oc = sc_oc(cs); struct channel *oc = sc_oc(cs);
@ -1803,7 +1803,7 @@ void cs_conn_sync_send(struct stconn *cs)
if (!sc_mux_ops(cs)) if (!sc_mux_ops(cs))
return; return;
cs_conn_send(cs); sc_conn_send(cs);
} }
/* Called by I/O handlers after completion.. It propagates /* Called by I/O handlers after completion.. It propagates
@ -1812,7 +1812,7 @@ void cs_conn_sync_send(struct stconn *cs)
* connection's polling based on the channels and stream connector's final * connection's polling based on the channels and stream connector's final
* states. The function always returns 0. * states. The function always returns 0.
*/ */
static int cs_conn_process(struct stconn *cs) static int sc_conn_process(struct stconn *cs)
{ {
struct connection *conn = __sc_conn(cs); struct connection *conn = __sc_conn(cs);
struct channel *ic = sc_ic(cs); struct channel *ic = sc_ic(cs);
@ -1822,7 +1822,7 @@ static int cs_conn_process(struct stconn *cs)
/* If we have data to send, try it now */ /* If we have data to send, try it now */
if (!channel_is_empty(oc) && !(cs->wait_event.events & SUB_RETRY_SEND)) if (!channel_is_empty(oc) && !(cs->wait_event.events & SUB_RETRY_SEND))
cs_conn_send(cs); sc_conn_send(cs);
/* First step, report to the stream connector what was detected at the /* First step, report to the stream connector what was detected at the
* connection layer : errors and connection establishment. * connection layer : errors and connection establishment.
@ -1832,8 +1832,8 @@ static int cs_conn_process(struct stconn *cs)
* to retry to connect, the connection may still have CO_FL_ERROR, * to retry to connect, the connection may still have CO_FL_ERROR,
* and we don't want to add SE_FL_ERROR back * and we don't want to add SE_FL_ERROR back
* *
* Note: This test is only required because cs_conn_process is also the SI * Note: This test is only required because sc_conn_process is also the SI
* wake callback. Otherwise cs_conn_recv()/cs_conn_send() already take * wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
* care of it. * care of it.
*/ */
@ -1864,8 +1864,8 @@ static int cs_conn_process(struct stconn *cs)
/* Report EOS on the channel if it was reached from the mux point of /* Report EOS on the channel if it was reached from the mux point of
* view. * view.
* *
* Note: This test is only required because cs_conn_process is also the SI * Note: This test is only required because sc_conn_process is also the SI
* wake callback. Otherwise cs_conn_recv()/cs_conn_send() already take * wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
* care of it. * care of it.
*/ */
if (sc_ep_test(cs, SE_FL_EOS) && !(ic->flags & CF_SHUTR)) { if (sc_ep_test(cs, SE_FL_EOS) && !(ic->flags & CF_SHUTR)) {
@ -1873,14 +1873,14 @@ static int cs_conn_process(struct stconn *cs)
ic->flags |= CF_READ_NULL; ic->flags |= CF_READ_NULL;
if (ic->flags & CF_AUTO_CLOSE) if (ic->flags & CF_AUTO_CLOSE)
channel_shutw_now(ic); channel_shutw_now(ic);
cs_conn_read0(cs); sc_conn_read0(cs);
} }
/* Report EOI on the channel if it was reached from the mux point of /* Report EOI on the channel if it was reached from the mux point of
* view. * view.
* *
* Note: This test is only required because cs_conn_process is also the SI * Note: This test is only required because sc_conn_process is also the SI
* wake callback. Otherwise cs_conn_recv()/cs_conn_send() already take * wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
* care of it. * care of it.
*/ */
if (sc_ep_test(cs, SE_FL_EOI) && !(ic->flags & CF_EOI)) if (sc_ep_test(cs, SE_FL_EOI) && !(ic->flags & CF_EOI))
@ -1900,7 +1900,7 @@ static int cs_conn_process(struct stconn *cs)
* stream connector. Thus it is always safe to perform a tasklet_wakeup() on a * stream connector. Thus it is always safe to perform a tasklet_wakeup() on a
* stream connector, as the presence of the CS is checked there. * stream connector, as the presence of the CS is checked there.
*/ */
struct task *cs_conn_io_cb(struct task *t, void *ctx, unsigned int state) struct task *sc_conn_io_cb(struct task *t, void *ctx, unsigned int state)
{ {
struct stconn *cs = ctx; struct stconn *cs = ctx;
int ret = 0; int ret = 0;
@ -1909,11 +1909,11 @@ struct task *cs_conn_io_cb(struct task *t, void *ctx, unsigned int state)
return t; return t;
if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(sc_oc(cs))) if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(sc_oc(cs)))
ret = cs_conn_send(cs); ret = sc_conn_send(cs);
if (!(cs->wait_event.events & SUB_RETRY_RECV)) if (!(cs->wait_event.events & SUB_RETRY_RECV))
ret |= cs_conn_recv(cs); ret |= sc_conn_recv(cs);
if (ret != 0) if (ret != 0)
cs_conn_process(cs); sc_conn_process(cs);
stream_release_buffers(__sc_strm(cs)); stream_release_buffers(__sc_strm(cs));
return t; return t;

View File

@ -252,7 +252,7 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
s = (struct stream *)task->context; s = (struct stream *)task->context;
else if (task->process == task_run_applet && task->context) else if (task->process == task_run_applet && task->context)
s = sc_strm(appctx_cs((struct appctx *)task->context)); s = sc_strm(appctx_cs((struct appctx *)task->context));
else if (task->process == cs_conn_io_cb && task->context) else if (task->process == sc_conn_io_cb && task->context)
s = sc_strm(((struct stconn *)task->context)); s = sc_strm(((struct stconn *)task->context));
if (s) if (s)

View File

@ -1634,8 +1634,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
scb = s->scb; scb = s->scb;
/* First, attempt to receive pending data from I/O layers */ /* First, attempt to receive pending data from I/O layers */
cs_conn_sync_recv(scf); sc_conn_sync_recv(scf);
cs_conn_sync_recv(scb); sc_conn_sync_recv(scb);
/* Let's check if we're looping without making any progress, e.g. due /* Let's check if we're looping without making any progress, e.g. due
* to a bogus analyser or the fact that we're ignoring a read0. The * to a bogus analyser or the fact that we're ignoring a read0. The
@ -2287,7 +2287,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
} }
/* Let's see if we can send the pending request now */ /* Let's see if we can send the pending request now */
cs_conn_sync_send(scb); sc_conn_sync_send(scb);
/* /*
* Now forward all shutdown requests between both sides of the request buffer * Now forward all shutdown requests between both sides of the request buffer
@ -2416,7 +2416,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
rpf_last = res->flags; rpf_last = res->flags;
/* Let's see if we can send the pending response now */ /* Let's see if we can send the pending response now */
cs_conn_sync_send(scf); sc_conn_sync_send(scf);
/* /*
* Now forward all shutdown requests between both sides of the buffer * Now forward all shutdown requests between both sides of the buffer

View File

@ -4936,7 +4936,7 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *ad
} fcts[] = { } fcts[] = {
{ .func = process_stream, .name = "process_stream" }, { .func = process_stream, .name = "process_stream" },
{ .func = task_run_applet, .name = "task_run_applet" }, { .func = task_run_applet, .name = "task_run_applet" },
{ .func = cs_conn_io_cb, .name = "cs_conn_io_cb" }, { .func = sc_conn_io_cb, .name = "sc_conn_io_cb" },
{ .func = sock_conn_iocb, .name = "sock_conn_iocb" }, { .func = sock_conn_iocb, .name = "sock_conn_iocb" },
{ .func = dgram_fd_handler, .name = "dgram_fd_handler" }, { .func = dgram_fd_handler, .name = "dgram_fd_handler" },
{ .func = listener_accept, .name = "listener_accept" }, { .func = listener_accept, .name = "listener_accept" },