CLEANUP: stconn: rename final state manipulation functions from cs_* to sc_*
This applies the following renaming. It's a bit large but pretty mechanical: cs_state -> sc_state (enum) cs_alloc_ibuf() -> sc_alloc_ibuf() cs_is_conn_error() -> sc_is_conn_error() cs_opposite() -> sc_opposite() cs_report_error() -> sc_report_error() cs_set_state() -> sc_set_state() cs_state_bit() -> sc_state_bit() cs_state_in() -> sc_state_in() cs_state_str() -> sc_state_str()
This commit is contained in:
parent
f61dd19284
commit
74568cf023
@ -106,7 +106,7 @@ enum sc_flags {
|
||||
* performing some retries (eg: connection error). Some states are transient and
|
||||
* do not last beyond process_session().
|
||||
*/
|
||||
enum cs_state {
|
||||
enum sc_state {
|
||||
SC_ST_INI = 0, /* CS not sollicitated yet */
|
||||
SC_ST_REQ, /* [transient] connection initiation desired and not started yet */
|
||||
SC_ST_QUE, /* CS waiting in queue */
|
||||
@ -121,7 +121,7 @@ enum cs_state {
|
||||
} __attribute__((packed));
|
||||
|
||||
/* state bits for use with lists of states */
|
||||
enum cs_state_bit {
|
||||
enum sc_state_bit {
|
||||
SC_SB_NONE = 0,
|
||||
SC_SB_INI = 1U << SC_ST_INI,
|
||||
SC_SB_REQ = 1U << SC_ST_REQ,
|
||||
@ -181,7 +181,7 @@ struct sc_app_ops {
|
||||
*/
|
||||
struct stconn {
|
||||
enum obj_type obj_type; /* differentiates connection from applet context */
|
||||
enum cs_state state; /* CS_ST* */
|
||||
enum sc_state state; /* CS_ST* */
|
||||
/* 2 bytes hole here */
|
||||
|
||||
unsigned int flags; /* SC_FL_* */
|
||||
|
@ -77,7 +77,7 @@ static inline struct task *sc_strm_task(const struct stconn *cs)
|
||||
}
|
||||
|
||||
/* returns the stream connector on the other side. Used during forwarding. */
|
||||
static inline struct stconn *cs_opposite(const struct stconn *cs)
|
||||
static inline struct stconn *sc_opposite(const struct stconn *cs)
|
||||
{
|
||||
struct stream *strm = __sc_strm(cs);
|
||||
|
||||
@ -86,7 +86,7 @@ static inline struct stconn *cs_opposite(const struct stconn *cs)
|
||||
|
||||
|
||||
/* to be called only when in SC_ST_DIS with SC_FL_ERR */
|
||||
static inline void cs_report_error(struct stconn *cs)
|
||||
static inline void sc_report_error(struct stconn *cs)
|
||||
{
|
||||
if (!__sc_strm(cs)->conn_err_type)
|
||||
__sc_strm(cs)->conn_err_type = STRM_ET_DATA_ERR;
|
||||
@ -98,23 +98,23 @@ static inline void cs_report_error(struct stconn *cs)
|
||||
/* sets the current and previous state of a stream connector to <state>. This is
|
||||
* mainly used to create one in the established state on incoming conncetions.
|
||||
*/
|
||||
static inline void cs_set_state(struct stconn *cs, int state)
|
||||
static inline void sc_set_state(struct stconn *cs, int state)
|
||||
{
|
||||
cs->state = __sc_strm(cs)->prev_conn_state = state;
|
||||
}
|
||||
|
||||
/* returns a bit for a stream connector state, to match against SC_SB_* */
|
||||
static inline enum cs_state_bit cs_state_bit(enum cs_state state)
|
||||
static inline enum sc_state_bit sc_state_bit(enum sc_state state)
|
||||
{
|
||||
BUG_ON(state > SC_ST_CLO);
|
||||
return 1U << state;
|
||||
}
|
||||
|
||||
/* returns true if <state> matches one of the SC_SB_* bits in <mask> */
|
||||
static inline int cs_state_in(enum cs_state state, enum cs_state_bit mask)
|
||||
static inline int sc_state_in(enum sc_state state, enum sc_state_bit mask)
|
||||
{
|
||||
BUG_ON(mask & ~SC_SB_ALL);
|
||||
return !!(cs_state_bit(state) & mask);
|
||||
return !!(sc_state_bit(state) & mask);
|
||||
}
|
||||
|
||||
/* Returns true if a connection is attached to the stream connector <cs> and if this
|
||||
@ -134,7 +134,7 @@ static inline int sc_conn_ready(const struct stconn *cs)
|
||||
* may hold pending data. This function returns true if such an error was
|
||||
* reported. Both the CS and the CONN must be valid.
|
||||
*/
|
||||
static inline int cs_is_conn_error(const struct stconn *cs)
|
||||
static inline int sc_is_conn_error(const struct stconn *cs)
|
||||
{
|
||||
const struct connection *conn;
|
||||
|
||||
@ -154,7 +154,7 @@ static inline int cs_is_conn_error(const struct stconn *cs)
|
||||
* stream connector and SE_FL_HAVE_NO_DATA cleared. The requester will be responsible
|
||||
* for calling this function to try again once woken up.
|
||||
*/
|
||||
static inline int cs_alloc_ibuf(struct stconn *cs, struct buffer_wait *wait)
|
||||
static inline int sc_alloc_ibuf(struct stconn *cs, struct buffer_wait *wait)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -319,13 +319,13 @@ static inline int sc_is_recv_allowed(const struct stconn *sc)
|
||||
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))
|
||||
sc_state_in(sc_opposite(cs)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO))
|
||||
sc_ep_clr(cs, SE_FL_APPLET_NEED_CONN);
|
||||
|
||||
if (!sc_is_recv_allowed(cs))
|
||||
return;
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
sc_ep_set(cs, SE_FL_HAVE_NO_DATA);
|
||||
@ -348,7 +348,7 @@ static inline void sc_update(struct stconn *cs)
|
||||
}
|
||||
|
||||
/* for debugging, reports the stream connector state name */
|
||||
static inline const char *cs_state_str(int state)
|
||||
static inline const char *sc_state_str(int state)
|
||||
{
|
||||
switch (state) {
|
||||
case SC_ST_INI: return "INI";
|
||||
|
@ -160,7 +160,7 @@ struct stream {
|
||||
int conn_retries; /* number of connect retries performed */
|
||||
unsigned int conn_exp; /* wake up time for connect, queue, turn-around, ... */
|
||||
unsigned int conn_err_type; /* first error detected, one of STRM_ET_* */
|
||||
enum cs_state prev_conn_state; /* CS_ST*, copy of previous state of the server stream connector */
|
||||
enum sc_state prev_conn_state; /* CS_ST*, copy of previous state of the server stream connector */
|
||||
|
||||
struct list list; /* position in the thread's streams list */
|
||||
struct mt_list by_srv; /* position in server stream list */
|
||||
|
@ -227,7 +227,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
|
||||
* some other processing if needed. The applet doesn't have anything to
|
||||
* do if it needs the buffer, it will be called again upon readiness.
|
||||
*/
|
||||
if (!cs_alloc_ibuf(cs, &app->buffer_wait))
|
||||
if (!sc_alloc_ibuf(cs, &app->buffer_wait))
|
||||
applet_have_more_data(app);
|
||||
|
||||
count = co_data(sc_oc(cs));
|
||||
@ -238,7 +238,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
|
||||
*/
|
||||
if (count != co_data(sc_oc(cs))) {
|
||||
sc_oc(cs)->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA;
|
||||
sc_have_room(cs_opposite(cs));
|
||||
sc_have_room(sc_opposite(cs));
|
||||
}
|
||||
|
||||
/* measure the call rate and check for anomalies when too high */
|
||||
|
@ -1836,7 +1836,7 @@ skip_reuse:
|
||||
if (!(srv_conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS)))
|
||||
sc_ep_clr(s->scb, SE_FL_WAIT_FOR_HS);
|
||||
|
||||
if (!cs_state_in(s->scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
if (!sc_state_in(s->scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
(srv_conn->flags & CO_FL_WAIT_XPRT) == 0) {
|
||||
s->conn_exp = TICK_ETERNITY;
|
||||
sc_oc(s->scb)->flags |= CF_WRITE_NULL;
|
||||
|
@ -1971,7 +1971,7 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr
|
||||
struct cmsghdr *cmsg;
|
||||
struct stconn *cs = appctx_cs(appctx);
|
||||
struct stream *s = __sc_strm(cs);
|
||||
struct connection *remote = sc_conn(cs_opposite(cs));
|
||||
struct connection *remote = sc_conn(sc_opposite(cs));
|
||||
struct msghdr msghdr;
|
||||
struct iovec iov;
|
||||
struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
|
||||
@ -2780,7 +2780,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
|
||||
sockaddr_free(&s->scb->dst);
|
||||
|
||||
cs_set_state(s->scb, SC_ST_INI);
|
||||
sc_set_state(s->scb, SC_ST_INI);
|
||||
s->scb->flags &= SC_FL_ISBACK | SC_FL_DONT_WAKE; /* we're in the context of process_stream */
|
||||
s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WROTE_DATA);
|
||||
s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA|CF_READ_NULL);
|
||||
|
@ -512,7 +512,7 @@ static void sc_app_shutr(struct stconn *cs)
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->rex = TICK_ETERNITY;
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
if (sc_oc(cs)->flags & CF_SHUTW) {
|
||||
@ -653,7 +653,7 @@ static void sc_app_shutr_conn(struct stconn *cs)
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->rex = TICK_ETERNITY;
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
if (sc_oc(cs)->flags & CF_SHUTW) {
|
||||
@ -758,7 +758,7 @@ static void sc_app_chk_rcv_conn(struct stconn *cs)
|
||||
BUG_ON(!sc_conn(cs));
|
||||
|
||||
/* (re)start reading */
|
||||
if (cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
tasklet_wakeup(cs->wait_event.tasklet);
|
||||
}
|
||||
|
||||
@ -774,7 +774,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs)
|
||||
|
||||
BUG_ON(!sc_conn(cs));
|
||||
|
||||
if (unlikely(!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST) ||
|
||||
if (unlikely(!sc_state_in(cs->state, SC_SB_RDY|SC_SB_EST) ||
|
||||
(oc->flags & CF_SHUTW)))
|
||||
return;
|
||||
|
||||
@ -788,7 +788,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs)
|
||||
if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(sc_oc(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) || sc_is_conn_error(cs)) {
|
||||
/* Write error on the file descriptor */
|
||||
if (cs->state >= SC_ST_CON)
|
||||
sc_ep_set(cs, SE_FL_ERROR);
|
||||
@ -806,7 +806,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)) {
|
||||
sc_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) {
|
||||
sc_shutw(cs);
|
||||
goto out_wakeup;
|
||||
}
|
||||
@ -851,7 +851,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs)
|
||||
if (likely((oc->flags & (CF_WRITE_NULL|CF_WRITE_ERROR|CF_SHUTW)) ||
|
||||
((oc->flags & CF_WAKE_WRITE) &&
|
||||
((channel_is_empty(oc) && !oc->to_forward) ||
|
||||
!cs_state_in(cs->state, SC_SB_EST))))) {
|
||||
!sc_state_in(cs->state, SC_SB_EST))))) {
|
||||
out_wakeup:
|
||||
if (!(cs->flags & SC_FL_DONT_WAKE))
|
||||
task_wakeup(sc_strm_task(cs), TASK_WOKEN_IO);
|
||||
@ -879,7 +879,7 @@ static void sc_app_shutr_applet(struct stconn *cs)
|
||||
|
||||
/* Note: on shutr, we don't call the applet */
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
if (sc_oc(cs)->flags & CF_SHUTW) {
|
||||
@ -1101,7 +1101,7 @@ static void sc_notify(struct stconn *cs)
|
||||
{
|
||||
struct channel *ic = sc_ic(cs);
|
||||
struct channel *oc = sc_oc(cs);
|
||||
struct stconn *cso = cs_opposite(cs);
|
||||
struct stconn *cso = sc_opposite(cs);
|
||||
struct task *task = sc_strm_task(cs);
|
||||
|
||||
/* process consumer side */
|
||||
@ -1192,7 +1192,7 @@ static void sc_notify(struct stconn *cs)
|
||||
/* wake the task up only when needed */
|
||||
if (/* changes on the production side */
|
||||
(ic->flags & (CF_READ_NULL|CF_READ_ERROR)) ||
|
||||
!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST) ||
|
||||
!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST) ||
|
||||
sc_ep_test(cs, SE_FL_ERROR) ||
|
||||
((ic->flags & CF_READ_PARTIAL) &&
|
||||
((ic->flags & CF_EOI) || !ic->to_forward || cso->state != SC_ST_EST)) ||
|
||||
@ -1240,7 +1240,7 @@ static void sc_conn_read0(struct stconn *cs)
|
||||
ic->flags |= CF_SHUTR;
|
||||
ic->rex = TICK_ETERNITY;
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
if (oc->flags & CF_SHUTW)
|
||||
@ -1398,7 +1398,7 @@ static int sc_conn_recv(struct stconn *cs)
|
||||
}
|
||||
|
||||
/* now we'll need a input buffer for the stream */
|
||||
if (!cs_alloc_ibuf(cs, &(__sc_strm(cs)->buffer_wait)))
|
||||
if (!sc_alloc_ibuf(cs, &(__sc_strm(cs)->buffer_wait)))
|
||||
goto end_recv;
|
||||
|
||||
/* For an HTX stream, if the buffer is stuck (no output data with some
|
||||
@ -1608,7 +1608,7 @@ static int sc_conn_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 (!sc_state_in(cs->state, SC_SB_RDY|SC_SB_EST))
|
||||
return 0;
|
||||
|
||||
if (!sc_mux_ops(cs))
|
||||
@ -1637,7 +1637,7 @@ static int sc_conn_send(struct stconn *cs)
|
||||
int ret;
|
||||
int did_send = 0;
|
||||
|
||||
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) || sc_is_conn_error(cs)) {
|
||||
/* We're probably there because the tasklet was woken up,
|
||||
* but process_stream() ran before, detected there were an
|
||||
* error and put the CS back to SC_ST_TAR. There's still
|
||||
@ -1756,7 +1756,7 @@ static int sc_conn_send(struct stconn *cs)
|
||||
if (cs->state == SC_ST_CON)
|
||||
cs->state = SC_ST_RDY;
|
||||
|
||||
sc_have_room(cs_opposite(cs));
|
||||
sc_have_room(sc_opposite(cs));
|
||||
}
|
||||
|
||||
if (sc_ep_test(cs, SE_FL_ERROR | SE_FL_ERR_PENDING)) {
|
||||
@ -1786,7 +1786,7 @@ void sc_conn_sync_send(struct stconn *cs)
|
||||
if (channel_is_empty(oc))
|
||||
return;
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
if (!sc_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
|
||||
return;
|
||||
|
||||
if (!sc_mux_ops(cs))
|
||||
@ -1827,7 +1827,7 @@ static int sc_conn_process(struct stconn *cs)
|
||||
*/
|
||||
|
||||
if (cs->state >= SC_ST_CON) {
|
||||
if (cs_is_conn_error(cs))
|
||||
if (sc_is_conn_error(cs))
|
||||
sc_ep_set(cs, SE_FL_ERROR);
|
||||
}
|
||||
|
||||
@ -1842,7 +1842,7 @@ static int sc_conn_process(struct stconn *cs)
|
||||
task_wakeup(sc_strm_task(cs), TASK_WOKEN_MSG);
|
||||
}
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
if (!sc_state_in(cs->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
(conn->flags & CO_FL_WAIT_XPRT) == 0) {
|
||||
__sc_strm(cs)->conn_exp = TICK_ETERNITY;
|
||||
oc->flags |= CF_WRITE_NULL;
|
||||
|
@ -1191,7 +1191,7 @@ int conn_send_proxy(struct connection *conn, unsigned int flag)
|
||||
if (cs && sc_strm(cs)) {
|
||||
ret = make_proxy_line(trash.area, trash.size,
|
||||
objt_server(conn->target),
|
||||
sc_conn(cs_opposite(cs)),
|
||||
sc_conn(sc_opposite(cs)),
|
||||
__sc_strm(cs));
|
||||
}
|
||||
else {
|
||||
|
@ -471,7 +471,7 @@ static void dns_session_io_handler(struct appctx *appctx)
|
||||
/* if the connection is not established, inform the stream that we want
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state < SC_ST_EST) {
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
@ -506,7 +506,7 @@ static void dns_session_io_handler(struct appctx *appctx)
|
||||
* the message so that we can take our reference there if we have to
|
||||
* stop before the end (ret=0).
|
||||
*/
|
||||
if (cs_opposite(cs)->state == SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state == SC_ST_EST) {
|
||||
/* we were already there, adjust the offset to be relative to
|
||||
* the buffer's head and remove us from the counter.
|
||||
*/
|
||||
|
@ -1391,13 +1391,13 @@ spoe_handle_connect_appctx(struct appctx *appctx)
|
||||
char *frame, *buf;
|
||||
int ret;
|
||||
|
||||
if (cs_state_in(cs->state, SC_SB_CER|SC_SB_DIS|SC_SB_CLO)) {
|
||||
if (sc_state_in(cs->state, SC_SB_CER|SC_SB_DIS|SC_SB_CLO)) {
|
||||
/* closed */
|
||||
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) {
|
||||
if (!sc_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) {
|
||||
/* not connected yet */
|
||||
applet_have_more_data(appctx);
|
||||
task_wakeup(__sc_strm(cs)->task, TASK_WOKEN_MSG);
|
||||
@ -1458,7 +1458,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
int ret;
|
||||
|
||||
|
||||
if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) {
|
||||
if (cs->state == SC_ST_CLO || sc_opposite(cs)->state == SC_ST_CLO) {
|
||||
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO;
|
||||
goto exit;
|
||||
}
|
||||
@ -1710,7 +1710,7 @@ spoe_handle_processing_appctx(struct appctx *appctx)
|
||||
struct spoe_agent *agent = SPOE_APPCTX(appctx)->agent;
|
||||
int ret, skip_sending = 0, skip_receiving = 0, active_s = 0, active_r = 0, close_asap = 0;
|
||||
|
||||
if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) {
|
||||
if (cs->state == SC_ST_CLO || sc_opposite(cs)->state == SC_ST_CLO) {
|
||||
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO;
|
||||
goto exit;
|
||||
}
|
||||
@ -1833,7 +1833,7 @@ spoe_handle_disconnect_appctx(struct appctx *appctx)
|
||||
char *frame, *buf;
|
||||
int ret;
|
||||
|
||||
if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO)
|
||||
if (cs->state == SC_ST_CLO || sc_opposite(cs)->state == SC_ST_CLO)
|
||||
goto exit;
|
||||
|
||||
if (appctx->st1 == SPOE_APPCTX_ERR_TOUT)
|
||||
@ -1885,7 +1885,7 @@ spoe_handle_disconnecting_appctx(struct appctx *appctx)
|
||||
char *frame;
|
||||
int ret;
|
||||
|
||||
if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) {
|
||||
if (cs->state == SC_ST_CLO || sc_opposite(cs)->state == SC_ST_CLO) {
|
||||
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO;
|
||||
goto exit;
|
||||
}
|
||||
|
10
src/hlua.c
10
src/hlua.c
@ -1955,7 +1955,7 @@ static void hlua_socket_handler(struct appctx *appctx)
|
||||
/* if the connection is not established, inform the stream that we want
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state < SC_ST_EST) {
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
@ -2000,7 +2000,7 @@ static int hlua_socket_init(struct appctx *appctx)
|
||||
* and retrieve data from the server. The connection is initialized
|
||||
* with the "struct server".
|
||||
*/
|
||||
cs_set_state(s->scb, SC_ST_ASS);
|
||||
sc_set_state(s->scb, SC_ST_ASS);
|
||||
|
||||
/* Force destination server. */
|
||||
s->flags |= SF_DIRECT | SF_ASSIGNED | SF_BE_ASSIGNED;
|
||||
@ -2425,7 +2425,7 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
|
||||
* the request buffer if its not required.
|
||||
*/
|
||||
if (s->req.buf.size == 0) {
|
||||
if (!cs_alloc_ibuf(cs, &appctx->buffer_wait))
|
||||
if (!sc_alloc_ibuf(cs, &appctx->buffer_wait))
|
||||
goto hlua_socket_write_yield_return;
|
||||
}
|
||||
|
||||
@ -2636,7 +2636,7 @@ __LJMP static int hlua_socket_getpeername(struct lua_State *L)
|
||||
|
||||
appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
|
||||
cs = appctx_cs(appctx);
|
||||
dst = sc_dst(cs_opposite(cs));
|
||||
dst = sc_dst(sc_opposite(cs));
|
||||
if (!dst) {
|
||||
xref_unlock(&socket->xref, peer);
|
||||
lua_pushnil(L);
|
||||
@ -2845,7 +2845,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
|
||||
cs = appctx_cs(appctx);
|
||||
s = __sc_strm(cs);
|
||||
|
||||
if (!sockaddr_alloc(&cs_opposite(cs)->dst, addr, sizeof(*addr))) {
|
||||
if (!sockaddr_alloc(&sc_opposite(cs)->dst, addr, sizeof(*addr))) {
|
||||
xref_unlock(&socket->xref, peer);
|
||||
WILL_LJMP(luaL_error(L, "connect: internal error"));
|
||||
}
|
||||
|
@ -1236,8 +1236,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
|
||||
struct fcgi_strm_params *params)
|
||||
{
|
||||
struct connection *cli_conn = objt_conn(fstrm->sess->origin);
|
||||
const struct sockaddr_storage *src = (sc_check(fcgi_strm_sc(fstrm)) ? conn_src(fconn->conn) : sc_src(cs_opposite(fcgi_strm_sc(fstrm))));
|
||||
const struct sockaddr_storage *dst = (sc_check(fcgi_strm_sc(fstrm)) ? conn_dst(fconn->conn) : sc_dst(cs_opposite(fcgi_strm_sc(fstrm))));
|
||||
const struct sockaddr_storage *src = (sc_check(fcgi_strm_sc(fstrm)) ? conn_src(fconn->conn) : sc_src(sc_opposite(fcgi_strm_sc(fstrm))));
|
||||
const struct sockaddr_storage *dst = (sc_check(fcgi_strm_sc(fstrm)) ? conn_dst(fconn->conn) : sc_dst(sc_opposite(fcgi_strm_sc(fstrm))));
|
||||
struct ist p;
|
||||
|
||||
if (!sl)
|
||||
|
@ -3820,7 +3820,7 @@ static int peers_dump_peer(struct buffer *msg, struct stconn *cs, struct peer *p
|
||||
peer_cs = appctx_cs(peer->appctx);
|
||||
peer_s = __sc_strm(peer_cs);
|
||||
|
||||
chunk_appendf(&trash, " state=%s", cs_state_str(cs_opposite(peer_cs)->state));
|
||||
chunk_appendf(&trash, " state=%s", sc_state_str(sc_opposite(peer_cs)->state));
|
||||
|
||||
conn = objt_conn(strm_orig(peer_s));
|
||||
if (conn)
|
||||
|
@ -332,7 +332,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
|
||||
/* if the connection is not established, inform the stream that we want
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state < SC_ST_EST) {
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
@ -371,7 +371,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
|
||||
* the message so that we can take our reference there if we have to
|
||||
* stop before the end (ret=0).
|
||||
*/
|
||||
if (cs_opposite(cs)->state == SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state == SC_ST_EST) {
|
||||
/* we were already there, adjust the offset to be relative to
|
||||
* the buffer's head and remove us from the counter.
|
||||
*/
|
||||
@ -472,7 +472,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
|
||||
/* if the connection is not established, inform the stream that we want
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state < SC_ST_EST) {
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
@ -511,7 +511,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
|
||||
* the message so that we can take our reference there if we have to
|
||||
* stop before the end (ret=0).
|
||||
*/
|
||||
if (cs_opposite(cs)->state == SC_ST_EST) {
|
||||
if (sc_opposite(cs)->state == SC_ST_EST) {
|
||||
/* we were already there, adjust the offset to be relative to
|
||||
* the buffer's head and remove us from the counter.
|
||||
*/
|
||||
|
44
src/stream.c
44
src/stream.c
@ -92,7 +92,7 @@ static const struct trace_event strm_trace_events[] = {
|
||||
{ .mask = STRM_EV_STRM_ANA, .name = "strm_ana", .desc = "stream analyzers" },
|
||||
{ .mask = STRM_EV_STRM_PROC, .name = "strm_proc", .desc = "stream processing" },
|
||||
|
||||
{ .mask = STRM_EV_CS_ST, .name = "cs_state", .desc = "processing connector states" },
|
||||
{ .mask = STRM_EV_CS_ST, .name = "sc_state", .desc = "processing connector states" },
|
||||
|
||||
{ .mask = STRM_EV_HTTP_ANA, .name = "http_ana", .desc = "HTTP analyzers" },
|
||||
{ .mask = STRM_EV_HTTP_ERR, .name = "http_err", .desc = "error during HTTP analyzis" },
|
||||
@ -173,7 +173,7 @@ static void strm_trace(enum trace_level level, uint64_t mask, const struct trace
|
||||
|
||||
/* Front and back stream connector state */
|
||||
chunk_appendf(&trace_buf, " CS=(%s,%s)",
|
||||
cs_state_str(s->scf->state), cs_state_str(s->scb->state));
|
||||
sc_state_str(s->scf->state), sc_state_str(s->scb->state));
|
||||
|
||||
/* If txn is defined, HTTP req/rep states */
|
||||
if (txn)
|
||||
@ -453,7 +453,7 @@ struct stream *stream_new(struct session *sess, struct stconn *cs, struct buffer
|
||||
if (!s->scb)
|
||||
goto out_fail_alloc_scb;
|
||||
|
||||
cs_set_state(s->scf, SC_ST_EST);
|
||||
sc_set_state(s->scf, SC_ST_EST);
|
||||
s->scf->hcto = sess->fe->timeout.clientfin;
|
||||
|
||||
if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
|
||||
@ -966,7 +966,7 @@ static void sess_set_term_flags(struct stream *s)
|
||||
}
|
||||
else if (s->scb->state == SC_ST_QUE)
|
||||
s->flags |= SF_FINST_Q;
|
||||
else if (cs_state_in(s->scb->state, SC_SB_REQ|SC_SB_TAR|SC_SB_ASS|SC_SB_CON|SC_SB_CER|SC_SB_RDY))
|
||||
else if (sc_state_in(s->scb->state, SC_SB_REQ|SC_SB_TAR|SC_SB_ASS|SC_SB_CON|SC_SB_CER|SC_SB_RDY))
|
||||
s->flags |= SF_FINST_C;
|
||||
else if (s->scb->state == SC_ST_EST || s->prev_conn_state == SC_ST_EST)
|
||||
s->flags |= SF_FINST_D;
|
||||
@ -1533,10 +1533,10 @@ static void stream_update_both_cs(struct stream *s)
|
||||
s->prev_conn_state = scb->state;
|
||||
|
||||
/* let's recompute both sides states */
|
||||
if (cs_state_in(scf->state, SC_SB_RDY|SC_SB_EST))
|
||||
if (sc_state_in(scf->state, SC_SB_RDY|SC_SB_EST))
|
||||
sc_update(scf);
|
||||
|
||||
if (cs_state_in(scb->state, SC_SB_RDY|SC_SB_EST))
|
||||
if (sc_state_in(scb->state, SC_SB_RDY|SC_SB_EST))
|
||||
sc_update(scb);
|
||||
|
||||
/* stream connectors are processed outside of process_stream() and must be
|
||||
@ -1753,10 +1753,10 @@ 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)) {
|
||||
if (sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS)) {
|
||||
sc_shutr(scf);
|
||||
sc_shutw(scf);
|
||||
cs_report_error(scf);
|
||||
sc_report_error(scf);
|
||||
if (!(req->analysers) && !(res->analysers)) {
|
||||
_HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
|
||||
@ -1773,10 +1773,10 @@ 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)) {
|
||||
if (sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) {
|
||||
sc_shutr(scb);
|
||||
sc_shutw(scb);
|
||||
cs_report_error(scb);
|
||||
sc_report_error(scb);
|
||||
_HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
|
||||
if (srv)
|
||||
_HA_ATOMIC_INC(&srv->counters.failed_resp);
|
||||
@ -1796,7 +1796,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
/* note: maybe we should process connection errors here ? */
|
||||
}
|
||||
|
||||
if (cs_state_in(scb->state, SC_SB_CON|SC_SB_RDY)) {
|
||||
if (sc_state_in(scb->state, SC_SB_CON|SC_SB_RDY)) {
|
||||
/* we were trying to establish a connection on the server side,
|
||||
* maybe it succeeded, maybe it failed, maybe we timed out, ...
|
||||
*/
|
||||
@ -1889,7 +1889,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
s->pending_events & TASK_WOKEN_MSG) {
|
||||
unsigned int flags = req->flags;
|
||||
|
||||
if (cs_state_in(scf->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
|
||||
if (sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
|
||||
int max_loops = global.tune.maxpollevents;
|
||||
unsigned int ana_list;
|
||||
unsigned int ana_back;
|
||||
@ -1990,7 +1990,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
s->pending_events & TASK_WOKEN_MSG) {
|
||||
unsigned int flags = res->flags;
|
||||
|
||||
if (cs_state_in(scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
|
||||
if (sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
|
||||
int max_loops = global.tune.maxpollevents;
|
||||
unsigned int ana_list;
|
||||
unsigned int ana_back;
|
||||
@ -2171,7 +2171,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
*/
|
||||
if (unlikely((!req->analysers || (req->analysers == AN_REQ_FLT_END && !(req->flags & CF_FLT_ANALYZE))) &&
|
||||
!(req->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
|
||||
(cs_state_in(scf->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) &&
|
||||
(sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) &&
|
||||
(req->to_forward != CHN_INFINITE_FORWARD))) {
|
||||
/* This buffer is freewheeling, there's no analyser
|
||||
* attached to it. If any data are left in, we'll permit them to
|
||||
@ -2250,7 +2250,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
/* we may have a pending connection request, or a connection waiting
|
||||
* for completion.
|
||||
*/
|
||||
if (cs_state_in(scb->state, SC_SB_REQ|SC_SB_QUE|SC_SB_TAR|SC_SB_ASS)) {
|
||||
if (sc_state_in(scb->state, SC_SB_REQ|SC_SB_QUE|SC_SB_TAR|SC_SB_ASS)) {
|
||||
/* prune the request variables and swap to the response variables. */
|
||||
if (s->vars_reqres.scope != SCOPE_RES) {
|
||||
if (!LIST_ISEMPTY(&s->vars_reqres.head))
|
||||
@ -2325,7 +2325,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
|
||||
/* Benchmarks have shown that it's optimal to do a full resync now */
|
||||
if (scf->state == SC_ST_DIS ||
|
||||
cs_state_in(scb->state, SC_SB_RDY|SC_SB_DIS) ||
|
||||
sc_state_in(scb->state, SC_SB_RDY|SC_SB_DIS) ||
|
||||
(sc_ep_test(scf, SE_FL_ERROR) && scf->state != SC_ST_CLO) ||
|
||||
(sc_ep_test(scb, SE_FL_ERROR) && scb->state != SC_ST_CLO))
|
||||
goto resync_stconns;
|
||||
@ -2343,7 +2343,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
*/
|
||||
if (unlikely((!res->analysers || (res->analysers == AN_RES_FLT_END && !(res->flags & CF_FLT_ANALYZE))) &&
|
||||
!(res->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
|
||||
cs_state_in(scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
|
||||
(res->to_forward != CHN_INFINITE_FORWARD))) {
|
||||
/* This buffer is freewheeling, there's no analyser
|
||||
* attached to it. If any data are left in, we'll permit them to
|
||||
@ -2449,7 +2449,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
}
|
||||
|
||||
if (scf->state == SC_ST_DIS ||
|
||||
cs_state_in(scb->state, SC_SB_RDY|SC_SB_DIS) ||
|
||||
sc_state_in(scb->state, SC_SB_RDY|SC_SB_DIS) ||
|
||||
(sc_ep_test(scf, SE_FL_ERROR) && scf->state != SC_ST_CLO) ||
|
||||
(sc_ep_test(scb, SE_FL_ERROR) && scb->state != SC_ST_CLO))
|
||||
goto resync_stconns;
|
||||
@ -2467,7 +2467,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
scf->flags &= ~SC_FL_DONT_WAKE;
|
||||
scb->flags &= ~SC_FL_DONT_WAKE;
|
||||
|
||||
if (likely((scf->state != SC_ST_CLO) || !cs_state_in(scb->state, SC_SB_INI|SC_SB_CLO) ||
|
||||
if (likely((scf->state != SC_ST_CLO) || !sc_state_in(scb->state, SC_SB_INI|SC_SB_CLO) ||
|
||||
(req->analysers & AN_REQ_FLT_END) || (res->analysers & AN_RES_FLT_END))) {
|
||||
if ((sess->fe->options & PR_O_CONTSTATS) && (s->flags & SF_BE_ASSIGNED) && !(s->flags & SF_IGNORE))
|
||||
stream_process_counters(s);
|
||||
@ -2782,7 +2782,7 @@ void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx, ch
|
||||
(s->txn ? h1_msg_state_str(s->txn->req.msg_state): "-"), (s->txn ? s->txn->req.flags : 0),
|
||||
(s->txn ? h1_msg_state_str(s->txn->rsp.msg_state): "-"), (s->txn ? s->txn->rsp.flags : 0), eol,
|
||||
pfx, req->flags, req->analysers, res->flags, res->analysers, eol,
|
||||
pfx, scf, cs_state_str(scf->state), scf->flags, scb, cs_state_str(scb->state), scb->flags, eol,
|
||||
pfx, scf, sc_state_str(scf->state), scf->flags, scb, sc_state_str(scb->state), scb->flags, eol,
|
||||
pfx, acf, acf ? acf->st0 : 0, acb, acb ? acb->st0 : 0, eol,
|
||||
pfx, cof, cof ? cof->flags : 0, conn_get_mux_name(cof), cof?cof->ctx:0, conn_get_xprt_name(cof),
|
||||
cof ? cof->xprt_ctx : 0, conn_get_ctrl_name(cof), conn_fd(cof), eol,
|
||||
@ -3304,7 +3304,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *cs, struct stream *strm
|
||||
|
||||
scf = strm->scf;
|
||||
chunk_appendf(&trash, " scf=%p flags=0x%08x state=%s endp=%s,%p,0x%08x sub=%d\n",
|
||||
scf, scf->flags, cs_state_str(scf->state),
|
||||
scf, scf->flags, sc_state_str(scf->state),
|
||||
(sc_ep_test(scf, SE_FL_T_MUX) ? "CONN" : (sc_ep_test(scf, SE_FL_T_APPLET) ? "APPCTX" : "NONE")),
|
||||
scf->sedesc->se, sc_ep_get(scf), scf->wait_event.events);
|
||||
|
||||
@ -3343,7 +3343,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *cs, struct stream *strm
|
||||
|
||||
scb = strm->scb;
|
||||
chunk_appendf(&trash, " scb=%p flags=0x%08x state=%s endp=%s,%p,0x%08x sub=%d\n",
|
||||
scb, scb->flags, cs_state_str(scb->state),
|
||||
scb, scb->flags, sc_state_str(scb->state),
|
||||
(sc_ep_test(scb, SE_FL_T_MUX) ? "CONN" : (sc_ep_test(scb, SE_FL_T_APPLET) ? "APPCTX" : "NONE")),
|
||||
scb->sedesc->se, sc_ep_get(scb), scb->wait_event.events);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user