diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index cb410fa7f..0b440125f 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -1511,7 +1511,7 @@ static void promex_appctx_handle_io(struct appctx *appctx) int ret; res_htx = htx_from_buf(&res->buf); - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) goto out; /* Check if the input buffer is available. */ diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index 1b597e8d0..354e56a16 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -433,7 +433,7 @@ static inline int channel_is_rewritable(const struct channel *chn) */ static inline int channel_may_send(const struct channel *chn) { - return chn_cons(chn)->state == CS_ST_EST; + return chn_cons(chn)->state == SC_ST_EST; } /* HTX version of channel_may_recv(). Returns non-zero if the channel can still diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index d933cff69..2294a4778 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -104,34 +104,34 @@ enum sc_flags { * do not last beyond process_session(). */ enum cs_state { - CS_ST_INI = 0, /* CS not sollicitated yet */ - CS_ST_REQ, /* [transient] connection initiation desired and not started yet */ - CS_ST_QUE, /* CS waiting in queue */ - CS_ST_TAR, /* CS in turn-around state after failed connect attempt */ - CS_ST_ASS, /* server just assigned to this CS */ - CS_ST_CON, /* initiated connection request (resource exists) */ - CS_ST_CER, /* [transient] previous connection attempt failed (resource released) */ - CS_ST_RDY, /* [transient] ready proven after I/O success during CS_ST_CON */ - CS_ST_EST, /* connection established (resource exists) */ - CS_ST_DIS, /* [transient] disconnected from other side, but cleanup not done yet */ - CS_ST_CLO, /* CS closed, might not existing anymore. Buffers shut. */ + 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 */ + SC_ST_TAR, /* CS in turn-around state after failed connect attempt */ + SC_ST_ASS, /* server just assigned to this CS */ + SC_ST_CON, /* initiated connection request (resource exists) */ + SC_ST_CER, /* [transient] previous connection attempt failed (resource released) */ + SC_ST_RDY, /* [transient] ready proven after I/O success during SC_ST_CON */ + SC_ST_EST, /* connection established (resource exists) */ + SC_ST_DIS, /* [transient] disconnected from other side, but cleanup not done yet */ + SC_ST_CLO, /* CS closed, might not existing anymore. Buffers shut. */ } __attribute__((packed)); /* state bits for use with lists of states */ enum cs_state_bit { - CS_SB_NONE = 0, - CS_SB_INI = 1U << CS_ST_INI, - CS_SB_REQ = 1U << CS_ST_REQ, - CS_SB_QUE = 1U << CS_ST_QUE, - CS_SB_TAR = 1U << CS_ST_TAR, - CS_SB_ASS = 1U << CS_ST_ASS, - CS_SB_CON = 1U << CS_ST_CON, - CS_SB_CER = 1U << CS_ST_CER, - CS_SB_RDY = 1U << CS_ST_RDY, - CS_SB_EST = 1U << CS_ST_EST, - CS_SB_DIS = 1U << CS_ST_DIS, - CS_SB_CLO = 1U << CS_ST_CLO, - CS_SB_ALL = CS_SB_INI|CS_SB_REQ|CS_SB_QUE|CS_SB_TAR|CS_SB_ASS|CS_SB_CON|CS_SB_CER|CS_SB_RDY|CS_SB_EST|CS_SB_DIS|CS_SB_CLO, + SC_SB_NONE = 0, + SC_SB_INI = 1U << SC_ST_INI, + SC_SB_REQ = 1U << SC_ST_REQ, + SC_SB_QUE = 1U << SC_ST_QUE, + SC_SB_TAR = 1U << SC_ST_TAR, + SC_SB_ASS = 1U << SC_ST_ASS, + SC_SB_CON = 1U << SC_ST_CON, + SC_SB_CER = 1U << SC_ST_CER, + SC_SB_RDY = 1U << SC_ST_RDY, + SC_SB_EST = 1U << SC_ST_EST, + SC_SB_DIS = 1U << SC_ST_DIS, + SC_SB_CLO = 1U << SC_ST_CLO, + SC_SB_ALL = SC_SB_INI|SC_SB_REQ|SC_SB_QUE|SC_SB_TAR|SC_SB_ASS|SC_SB_CON|SC_SB_CER|SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO, }; struct stconn; diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index ee20f307a..ad8dba7c4 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -85,7 +85,7 @@ static inline struct stconn *cs_opposite(struct stconn *cs) } -/* to be called only when in CS_ST_DIS with SC_FL_ERR */ +/* to be called only when in SC_ST_DIS with SC_FL_ERR */ static inline void cs_report_error(struct stconn *cs) { if (!__cs_strm(cs)->conn_err_type) @@ -103,17 +103,17 @@ static inline void cs_set_state(struct stconn *cs, int state) cs->state = __cs_strm(cs)->prev_conn_state = state; } -/* returns a bit for a stream connector state, to match against CS_SB_* */ +/* 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) { - BUG_ON(state > CS_ST_CLO); + BUG_ON(state > SC_ST_CLO); return 1U << state; } -/* returns true if matches one of the CS_SB_* bits in */ +/* returns true if matches one of the SC_SB_* bits in */ static inline int cs_state_in(enum cs_state state, enum cs_state_bit mask) { - BUG_ON(mask & ~CS_SB_ALL); + BUG_ON(mask & ~SC_SB_ALL); return !!(cs_state_bit(state) & mask); } @@ -130,7 +130,7 @@ static inline int cs_conn_ready(struct stconn *cs) /* The stream connector is only responsible for the connection during the early * states, before plugging a mux. Thus it should only care about CO_FL_ERROR - * before CS_ST_EST, and after that it must absolutely ignore it since the mux + * before SC_ST_EST, and after that it must absolutely ignore it since the mux * may hold pending data. This function returns true if such an error was * reported. Both the CS and the CONN must be valid. */ @@ -138,7 +138,7 @@ static inline int cs_is_conn_error(const struct stconn *cs) { struct connection *conn; - if (cs->state >= CS_ST_EST) + if (cs->state >= SC_ST_EST) return 0; conn = __cs_conn(cs); @@ -292,13 +292,13 @@ static inline void cs_shutw(struct stconn *cs) */ static inline void cs_chk_rcv(struct stconn *cs) { - if (sc_ep_test(cs, SE_FL_RXBLK_CONN) && cs_state_in(cs_opposite(cs)->state, CS_SB_RDY|CS_SB_EST|CS_SB_DIS|CS_SB_CLO)) + if (sc_ep_test(cs, SE_FL_RXBLK_CONN) && cs_state_in(cs_opposite(cs)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) cs_rx_conn_rdy(cs); if (cs_rx_blocked(cs) || !cs_rx_endp_ready(cs)) return; - if (!cs_state_in(cs->state, CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) return; sc_ep_set(cs, SE_FL_RX_WAIT_EP); @@ -322,17 +322,17 @@ static inline void cs_update(struct stconn *cs) static inline const char *cs_state_str(int state) { switch (state) { - case CS_ST_INI: return "INI"; - case CS_ST_REQ: return "REQ"; - case CS_ST_QUE: return "QUE"; - case CS_ST_TAR: return "TAR"; - case CS_ST_ASS: return "ASS"; - case CS_ST_CON: return "CON"; - case CS_ST_CER: return "CER"; - case CS_ST_RDY: return "RDY"; - case CS_ST_EST: return "EST"; - case CS_ST_DIS: return "DIS"; - case CS_ST_CLO: return "CLO"; + case SC_ST_INI: return "INI"; + case SC_ST_REQ: return "REQ"; + case SC_ST_QUE: return "QUE"; + case SC_ST_TAR: return "TAR"; + case SC_ST_ASS: return "ASS"; + case SC_ST_CON: return "CON"; + case SC_ST_CER: return "CER"; + case SC_ST_RDY: return "RDY"; + case SC_ST_EST: return "EST"; + case SC_ST_DIS: return "DIS"; + case SC_ST_CLO: return "CLO"; default: return "???"; } } diff --git a/include/haproxy/stream.h b/include/haproxy/stream.h index 6f670261a..49f715be0 100644 --- a/include/haproxy/stream.h +++ b/include/haproxy/stream.h @@ -341,12 +341,12 @@ static inline void stream_choose_redispatch(struct stream *s) sockaddr_free(&s->scb->dst); s->flags &= ~(SF_DIRECT | SF_ASSIGNED); - s->scb->state = CS_ST_REQ; + s->scb->state = SC_ST_REQ; } else { if (objt_server(s->target)) _HA_ATOMIC_INC(&__objt_server(s->target)->counters.retries); _HA_ATOMIC_INC(&s->be->be_counters.retries); - s->scb->state = CS_ST_ASS; + s->scb->state = SC_ST_ASS; } } diff --git a/src/backend.c b/src/backend.c index dc2083962..b1c33f640 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1294,7 +1294,7 @@ static int do_connect_server(struct stream *s, struct connection *conn) return ret; /* we're in the process of establishing a connection */ - s->scb->state = CS_ST_CON; + s->scb->state = SC_ST_CON; } else { /* try to reuse the existing connection, it will be @@ -1302,9 +1302,9 @@ static int do_connect_server(struct stream *s, struct connection *conn) */ /* Is the connection really ready ? */ if (conn->mux->ctl(conn, MUX_STATUS, NULL) & MUX_STATUS_READY) - s->scb->state = CS_ST_RDY; + s->scb->state = SC_ST_RDY; else - s->scb->state = CS_ST_CON; + s->scb->state = SC_ST_CON; } /* needs src ip/port for logging */ @@ -1821,7 +1821,7 @@ skip_reuse: } /* Now handle synchronously connected sockets. We know the stream connector - * is at least in state CS_ST_CON. These ones typically are UNIX + * is at least in state SC_ST_CON. These ones typically are UNIX * sockets, socket pairs, andoccasionally TCP connections on the * loopback on a heavily loaded system. */ @@ -1836,12 +1836,12 @@ 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, CS_SB_EST|CS_SB_DIS|CS_SB_CLO) && + if (!cs_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; cs_oc(s->scb)->flags |= CF_WRITE_NULL; - if (s->scb->state == CS_ST_CON) - s->scb->state = CS_ST_RDY; + if (s->scb->state == SC_ST_CON) + s->scb->state = SC_ST_RDY; } /* Report EOI on the channel if it was reached from the mux point of @@ -1924,7 +1924,7 @@ int srv_redispatch_connect(struct stream *s) case SRV_STATUS_QUEUED: s->conn_exp = tick_add_ifset(now_ms, s->be->timeout.queue); - s->scb->state = CS_ST_QUE; + s->scb->state = SC_ST_QUE; /* do nothing else and do not wake any other stream up */ return 1; @@ -1961,10 +1961,10 @@ static int back_may_abort_req(struct channel *req, struct stream *s) (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))); } -/* Update back stream connector status for input states CS_ST_ASS, CS_ST_QUE, - * CS_ST_TAR. Other input states are simply ignored. - * Possible output states are CS_ST_CLO, CS_ST_TAR, CS_ST_ASS, CS_ST_REQ, CS_ST_CON - * and CS_ST_EST. Flags must have previously been updated for timeouts and other +/* Update back stream connector status for input states SC_ST_ASS, SC_ST_QUE, + * SC_ST_TAR. Other input states are simply ignored. + * Possible output states are SC_ST_CLO, SC_ST_TAR, SC_ST_ASS, SC_ST_REQ, SC_ST_CON + * and SC_ST_EST. Flags must have previously been updated for timeouts and other * conditions. */ void back_try_conn_req(struct stream *s) @@ -1975,7 +1975,7 @@ void back_try_conn_req(struct stream *s) DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); - if (cs->state == CS_ST_ASS) { + if (cs->state == SC_ST_ASS) { /* Server assigned to connection request, we have to try to connect now */ int conn_err; @@ -1992,7 +1992,7 @@ void back_try_conn_req(struct stream *s) srv = objt_server(s->target); if (conn_err == SF_ERR_NONE) { - /* state = CS_ST_CON or CS_ST_EST now */ + /* state = SC_ST_CON or SC_ST_EST now */ if (srv) srv_inc_sess_ctr(srv); if (srv) @@ -2033,7 +2033,7 @@ void back_try_conn_req(struct stream *s) pendconn_cond_unlink(s->pend_pos); /* no stream was ever accounted for this server */ - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); DBG_TRACE_STATE("internal error during connection", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); @@ -2044,14 +2044,14 @@ void back_try_conn_req(struct stream *s) * turn-around now, as the problem is likely a source port * allocation problem, so we want to retry now. */ - cs->state = CS_ST_CER; + cs->state = SC_ST_CER; sc_ep_clr(cs, SE_FL_ERROR); back_handle_st_cer(s); DBG_TRACE_STATE("connection error, retry", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); - /* now cs->state is one of CS_ST_CLO, CS_ST_TAR, CS_ST_ASS, CS_ST_REQ */ + /* now cs->state is one of SC_ST_CLO, SC_ST_TAR, SC_ST_ASS, SC_ST_REQ */ } - else if (cs->state == CS_ST_QUE) { + else if (cs->state == SC_ST_QUE) { /* connection request was queued, check for any update */ if (!pendconn_dequeue(s)) { /* The connection is not in the queue anymore. Either @@ -2061,10 +2061,10 @@ void back_try_conn_req(struct stream *s) */ s->conn_exp = TICK_ETERNITY; if (unlikely(!(s->flags & SF_ASSIGNED))) - cs->state = CS_ST_REQ; + cs->state = SC_ST_REQ; else { s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now); - cs->state = CS_ST_ASS; + cs->state = SC_ST_ASS; } DBG_TRACE_STATE("dequeue connection request", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); goto end; @@ -2088,7 +2088,7 @@ void back_try_conn_req(struct stream *s) req->flags |= CF_WRITE_TIMEOUT; if (!s->conn_err_type) s->conn_err_type = STRM_ET_QUEUE_TO; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); DBG_TRACE_STATE("connection request still queued", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); @@ -2109,7 +2109,7 @@ void back_try_conn_req(struct stream *s) /* Nothing changed */ } - else if (cs->state == CS_ST_TAR) { + else if (cs->state == SC_ST_TAR) { /* Connection request might be aborted */ if (back_may_abort_req(req, s)) { s->conn_err_type |= STRM_ET_CONN_ABRT; @@ -2128,9 +2128,9 @@ void back_try_conn_req(struct stream *s) * FIXME: Should we force a redispatch attempt when the server is down ? */ if (s->flags & SF_ASSIGNED) - cs->state = CS_ST_ASS; + cs->state = SC_ST_ASS; else - cs->state = CS_ST_REQ; + cs->state = SC_ST_REQ; DBG_TRACE_STATE("retry connection now", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); } @@ -2145,7 +2145,7 @@ abort_connection: s->flags &= ~SF_CONN_EXP; cs_shutr(cs); cs_shutw(cs); - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); DBG_TRACE_DEVEL("leaving on error", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); @@ -2153,16 +2153,16 @@ abort_connection: } /* This function initiates a server connection request on a stream connector - * already in CS_ST_REQ state. Upon success, the state goes to CS_ST_ASS for + * already in SC_ST_REQ state. Upon success, the state goes to SC_ST_ASS for * a real connection to a server, indicating that a server has been assigned, - * or CS_ST_RDY for a successful connection to an applet. It may also return - * CS_ST_QUE, or CS_ST_CLO upon error. + * or SC_ST_RDY for a successful connection to an applet. It may also return + * SC_ST_QUE, or SC_ST_CLO upon error. */ void back_handle_st_req(struct stream *s) { struct stconn *cs = s->scb; - if (cs->state != CS_ST_REQ) + if (cs->state != SC_ST_REQ) return; DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); @@ -2170,9 +2170,9 @@ void back_handle_st_req(struct stream *s) if (unlikely(obj_type(s->target) == OBJ_TYPE_APPLET)) { struct appctx *appctx; - /* The target is an applet but the CS is in CS_ST_REQ. Thus it + /* The target is an applet but the CS is in SC_ST_REQ. Thus it * means no appctx are attached to the CS. Otherwise, it will be - * in CS_ST_RDY state. So, try to create the appctx now. + * in SC_ST_RDY state. So, try to create the appctx now. */ BUG_ON(cs_appctx(cs)); appctx = cs_applet_create(cs, objt_applet(s->target)); @@ -2187,7 +2187,7 @@ void back_handle_st_req(struct stream *s) cs_shutw(cs); s->req.flags |= CF_WRITE_ERROR; s->conn_err_type = STRM_ET_CONN_RES; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); DBG_TRACE_STATE("failed to register applet", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); @@ -2203,7 +2203,7 @@ void back_handle_st_req(struct stream *s) /* We did not get a server. Either we queued the * connection request, or we encountered an error. */ - if (cs->state == CS_ST_QUE) { + if (cs->state == SC_ST_QUE) { DBG_TRACE_STATE("connection request queued", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); goto end; } @@ -2214,7 +2214,7 @@ void back_handle_st_req(struct stream *s) s->req.flags |= CF_WRITE_ERROR; if (!s->conn_err_type) s->conn_err_type = STRM_ET_CONN_OTHER; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); DBG_TRACE_STATE("connection request failed", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); @@ -2223,7 +2223,7 @@ void back_handle_st_req(struct stream *s) /* The server is assigned */ s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now); - cs->state = CS_ST_ASS; + cs->state = SC_ST_ASS; be_set_sess_last(s->be); DBG_TRACE_STATE("connection request assigned to a server", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); @@ -2231,10 +2231,10 @@ void back_handle_st_req(struct stream *s) DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); } -/* This function is called with (cs->state == CS_ST_CON) meaning that a +/* This function is called with (cs->state == SC_ST_CON) meaning that a * connection was attempted and that the file descriptor is already allocated. * We must check for timeout, error and abort. Possible output states are - * CS_ST_CER (error), CS_ST_DIS (abort), and CS_ST_CON (no change). This only + * SC_ST_CER (error), SC_ST_DIS (abort), and SC_ST_CON (no change). This only * works with connection-based streams. We know that there were no I/O event * when reaching this function. Timeouts and errors are *not* cleared. */ @@ -2255,7 +2255,7 @@ void back_handle_st_con(struct stream *s) s->conn_err_type |= STRM_ET_CONN_ABRT; if (s->srv_error) s->srv_error(s, cs); - /* Note: state = CS_ST_DIS now */ + /* Note: state = SC_ST_DIS now */ DBG_TRACE_STATE("client abort during connection attempt", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); goto end; } @@ -2270,7 +2270,7 @@ void back_handle_st_con(struct stream *s) s->conn_err_type = STRM_ET_CONN_TO; } - cs->state = CS_ST_CER; + cs->state = SC_ST_CER; DBG_TRACE_STATE("connection failed, retry", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); } @@ -2278,13 +2278,13 @@ void back_handle_st_con(struct stream *s) DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); } -/* This function is called with (cs->state == CS_ST_CER) meaning that a +/* This function is called with (cs->state == SC_ST_CER) meaning that a * previous connection attempt has failed and that the file descriptor * has already been released. Possible causes include asynchronous error - * notification and time out. Possible output states are CS_ST_CLO when - * retries are exhausted, CS_ST_TAR when a delay is wanted before a new - * connection attempt, CS_ST_ASS when it's wise to retry on the same server, - * and CS_ST_REQ when an immediate redispatch is wanted. The buffers are + * notification and time out. Possible output states are SC_ST_CLO when + * retries are exhausted, SC_ST_TAR when a delay is wanted before a new + * connection attempt, SC_ST_ASS when it's wise to retry on the same server, + * and SC_ST_REQ when an immediate redispatch is wanted. The buffers are * marked as in error state. Timeouts and errors are cleared before retrying. */ void back_handle_st_cer(struct stream *s) @@ -2351,7 +2351,7 @@ void back_handle_st_cer(struct stream *s) s->req.flags |= CF_WRITE_ERROR; s->res.flags |= CF_READ_ERROR; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); @@ -2385,7 +2385,7 @@ void back_handle_st_cer(struct stream *s) s->req.flags |= CF_WRITE_ERROR; s->res.flags |= CF_READ_ERROR; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (s->srv_error) s->srv_error(s, cs); @@ -2415,10 +2415,10 @@ void back_handle_st_cer(struct stream *s) s->conn_err_type = STRM_ET_CONN_ERR; /* only wait when we're retrying on the same server */ - if ((cs->state == CS_ST_ASS || + if ((cs->state == SC_ST_ASS || (s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_RR || (s->be->srv_act <= 1)) && !reused) { - cs->state = CS_ST_TAR; + cs->state = SC_ST_TAR; s->conn_exp = tick_add(now_ms, MS_TO_TICKS(delay)); } DBG_TRACE_STATE("retry a new connection", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); @@ -2428,11 +2428,11 @@ void back_handle_st_cer(struct stream *s) DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); } -/* This function is called with (cs->state == CS_ST_RDY) meaning that a +/* This function is called with (cs->state == SC_ST_RDY) meaning that a * connection was attempted, that the file descriptor is already allocated, * and that it has succeeded. We must still check for errors and aborts. - * Possible output states are CS_ST_EST (established), CS_ST_CER (error), - * and CS_ST_DIS (abort). This only works with connection-based streams. + * Possible output states are SC_ST_EST (established), SC_ST_CER (error), + * and SC_ST_DIS (abort). This only works with connection-based streams. * Timeouts and errors are *not* cleared. */ void back_handle_st_rdy(struct stream *s) @@ -2445,7 +2445,7 @@ void back_handle_st_rdy(struct stream *s) if (unlikely(obj_type(s->target) == OBJ_TYPE_APPLET)) { /* Here the appctx must exists because the CS was set to - * CS_ST_RDY state when the appctx was created. + * SC_ST_RDY state when the appctx was created. */ BUG_ON(!cs_appctx(s->scb)); @@ -2463,7 +2463,7 @@ void back_handle_st_rdy(struct stream *s) * - an I/O error might have been reported after a successful transfer, * which is not retryable and needs to be logged correctly, and needs * established as well - * - CS_ST_CON implies !CF_WROTE_DATA but not conversely as we could + * - SC_ST_CON implies !CF_WROTE_DATA but not conversely as we could * have validated a connection with incoming data (e.g. TCP with a * banner protocol), or just a successful connect() probe. * - the client might have requested a connection abort, this needs to @@ -2492,7 +2492,7 @@ void back_handle_st_rdy(struct stream *s) if (sc_ep_test(cs, SE_FL_ERROR)) { if (!s->conn_err_type) s->conn_err_type = STRM_ET_CONN_ERR; - cs->state = CS_ST_CER; + cs->state = SC_ST_CER; DBG_TRACE_STATE("connection failed, retry", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); goto end; } @@ -2503,7 +2503,7 @@ void back_handle_st_rdy(struct stream *s) */ DBG_TRACE_STATE("connection established", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); s->conn_err_type = STRM_ET_NONE; - cs->state = CS_ST_EST; + cs->state = SC_ST_EST; end: DBG_TRACE_LEAVE(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); diff --git a/src/cache.c b/src/cache.c index 8b523f25f..8a79ef05c 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1466,7 +1466,7 @@ static void http_cache_io_handler(struct appctx *appctx) res_htx = htx_from_buf(&res->buf); total = res_htx->data; - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) goto out; /* Check if the input buffer is available. */ diff --git a/src/cli.c b/src/cli.c index dc7d79c87..273fe8684 100644 --- a/src/cli.c +++ b/src/cli.c @@ -904,7 +904,7 @@ static void cli_io_handler(struct appctx *appctx) int reql; int len; - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) goto out; /* Check if the input buffer is available. */ @@ -1170,7 +1170,7 @@ static void cli_io_handler(struct appctx *appctx) } } - if ((res->flags & CF_SHUTR) && (cs->state == CS_ST_EST)) { + 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); /* Other side has closed, let's abort if we have no more processing to do @@ -1181,7 +1181,7 @@ static void cli_io_handler(struct appctx *appctx) cs_shutw(cs); } - if ((req->flags & CF_SHUTW) && (cs->state == CS_ST_EST) && (appctx->st0 < CLI_ST_OUTPUT)) { + 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); /* We have no more processing to do, and nothing more to send, and @@ -2787,7 +2787,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, CS_ST_INI); + cs_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); diff --git a/src/conn_stream.c b/src/conn_stream.c index 655bcc9c2..e9c8b1521 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -127,7 +127,7 @@ static struct stconn *cs_new(struct sedesc *sedesc) cs->obj_type = OBJ_TYPE_CS; cs->flags = SC_FL_NONE; - cs->state = CS_ST_INI; + cs->state = SC_ST_INI; cs->hcto = TICK_ETERNITY; cs->app = NULL; cs->data_cb = NULL; @@ -493,7 +493,7 @@ struct appctx *cs_applet_create(struct stconn *cs, struct applet *app) cs_cant_get(cs); appctx_wakeup(appctx); - cs->state = CS_ST_RDY; + cs->state = SC_ST_RDY; return appctx; } @@ -514,11 +514,11 @@ static void sc_app_shutr(struct stconn *cs) ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY; - if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) return; if (cs_oc(cs)->flags & CF_SHUTW) { - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; __cs_strm(cs)->conn_exp = TICK_ETERNITY; } else if (cs->flags & SC_FL_NOHALF) { @@ -556,8 +556,8 @@ static void sc_app_shutw(struct stconn *cs) } switch (cs->state) { - case CS_ST_RDY: - case CS_ST_EST: + case SC_ST_RDY: + case SC_ST_EST: /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set. @@ -569,12 +569,12 @@ static void sc_app_shutw(struct stconn *cs) return; /* fall through */ - case CS_ST_CON: - case CS_ST_CER: - case CS_ST_QUE: - case CS_ST_TAR: + case SC_ST_CON: + case SC_ST_CER: + case SC_ST_QUE: + case SC_ST_TAR: /* Note that none of these states may happen with applets */ - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; /* fall through */ default: cs->flags &= ~SC_FL_NOLINGER; @@ -618,7 +618,7 @@ static void sc_app_chk_snd(struct stconn *cs) __FUNCTION__, cs, cs->state, cs_ic(cs)->flags, oc->flags); - if (unlikely(cs->state != CS_ST_EST || (oc->flags & CF_SHUTW))) + if (unlikely(cs->state != SC_ST_EST || (oc->flags & CF_SHUTW))) return; if (!sc_ep_test(cs, SE_FL_WAIT_DATA) || /* not waiting for data */ @@ -658,12 +658,12 @@ static void sc_app_shutr_conn(struct stconn *cs) ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY; - if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) return; if (cs_oc(cs)->flags & CF_SHUTW) { cs_conn_shut(cs); - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; __cs_strm(cs)->conn_exp = TICK_ETERNITY; } else if (cs->flags & SC_FL_NOHALF) { @@ -700,8 +700,8 @@ static void sc_app_shutw_conn(struct stconn *cs) } switch (cs->state) { - case CS_ST_RDY: - case CS_ST_EST: + case SC_ST_RDY: + case SC_ST_EST: /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set. @@ -734,16 +734,16 @@ static void sc_app_shutw_conn(struct stconn *cs) } /* fall through */ - case CS_ST_CON: + case SC_ST_CON: /* we may have to close a pending connection, and mark the * response buffer as shutr */ cs_conn_shut(cs); /* fall through */ - case CS_ST_CER: - case CS_ST_QUE: - case CS_ST_TAR: - cs->state = CS_ST_DIS; + case SC_ST_CER: + case SC_ST_QUE: + case SC_ST_TAR: + cs->state = SC_ST_DIS; /* fall through */ default: cs->flags &= ~SC_FL_NOLINGER; @@ -765,7 +765,7 @@ static void sc_app_chk_rcv_conn(struct stconn *cs) BUG_ON(!cs_conn(cs)); /* (re)start reading */ - if (cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) tasklet_wakeup(cs->wait_event.tasklet); } @@ -781,7 +781,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs) BUG_ON(!cs_conn(cs)); - if (unlikely(!cs_state_in(cs->state, CS_SB_RDY|CS_SB_EST) || + if (unlikely(!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST) || (oc->flags & CF_SHUTW))) return; @@ -797,7 +797,7 @@ static void sc_app_chk_snd_conn(struct stconn *cs) if (sc_ep_test(cs, SE_FL_ERROR | SE_FL_ERR_PENDING) || cs_is_conn_error(cs)) { /* Write error on the file descriptor */ - if (cs->state >= CS_ST_CON) + if (cs->state >= SC_ST_CON) sc_ep_set(cs, SE_FL_ERROR); goto out_wakeup; } @@ -813,7 +813,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, CS_SB_RDY|CS_SB_EST)) { + cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) { cs_shutw(cs); goto out_wakeup; } @@ -858,7 +858,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, CS_SB_EST))))) { + !cs_state_in(cs->state, SC_SB_EST))))) { out_wakeup: if (!(cs->flags & SC_FL_DONT_WAKE)) task_wakeup(cs_strm_task(cs), TASK_WOKEN_IO); @@ -887,12 +887,12 @@ static void sc_app_shutr_applet(struct stconn *cs) /* Note: on shutr, we don't call the applet */ - if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) return; if (cs_oc(cs)->flags & CF_SHUTW) { appctx_shut(__cs_appctx(cs)); - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; __cs_strm(cs)->conn_exp = TICK_ETERNITY; } else if (cs->flags & SC_FL_NOHALF) { @@ -931,8 +931,8 @@ static void sc_app_shutw_applet(struct stconn *cs) appctx_wakeup(__cs_appctx(cs)); switch (cs->state) { - case CS_ST_RDY: - case CS_ST_EST: + case SC_ST_RDY: + case SC_ST_EST: /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set. @@ -944,13 +944,13 @@ static void sc_app_shutw_applet(struct stconn *cs) return; /* fall through */ - case CS_ST_CON: - case CS_ST_CER: - case CS_ST_QUE: - case CS_ST_TAR: + case SC_ST_CON: + case SC_ST_CER: + case SC_ST_QUE: + case SC_ST_TAR: /* Note that none of these states may happen with applets */ appctx_shut(__cs_appctx(cs)); - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; /* fall through */ default: cs->flags &= ~SC_FL_NOLINGER; @@ -989,7 +989,7 @@ static void sc_app_chk_snd_applet(struct stconn *cs) __FUNCTION__, cs, cs->state, cs_ic(cs)->flags, oc->flags); - if (unlikely(cs->state != CS_ST_EST || (oc->flags & CF_SHUTW))) + if (unlikely(cs->state != SC_ST_EST || (oc->flags & CF_SHUTW))) return; /* we only wake the applet up if it was waiting for some data */ @@ -1121,7 +1121,7 @@ static void cs_notify(struct stconn *cs) struct connection *conn = cs_conn(cs); if (((oc->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW) && - (cs->state == CS_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS)))) + (cs->state == SC_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS)))) cs_shutw(cs); oc->wex = TICK_ETERNITY; } @@ -1202,10 +1202,10 @@ static void cs_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, CS_SB_CON|CS_SB_RDY|CS_SB_EST) || + !cs_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 != CS_ST_EST)) || + ((ic->flags & CF_EOI) || !ic->to_forward || cso->state != SC_ST_EST)) || /* changes on the consumption side */ (oc->flags & (CF_WRITE_NULL|CF_WRITE_ERROR)) || @@ -1213,7 +1213,7 @@ static void cs_notify(struct stconn *cs) ((oc->flags & CF_SHUTW) || (((oc->flags & CF_WAKE_WRITE) || !(oc->flags & (CF_AUTO_CLOSE|CF_SHUTW_NOW|CF_SHUTW))) && - (cso->state != CS_ST_EST || + (cso->state != SC_ST_EST || (channel_is_empty(oc) && !oc->to_forward)))))) { task_wakeup(task, TASK_WOKEN_IO); } @@ -1251,7 +1251,7 @@ static void cs_conn_read0(struct stconn *cs) ic->flags |= CF_SHUTR; ic->rex = TICK_ETERNITY; - if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) return; if (oc->flags & CF_SHUTW) @@ -1277,7 +1277,7 @@ static void cs_conn_read0(struct stconn *cs) cs_done_get(cs); - cs->state = CS_ST_DIS; + cs->state = SC_ST_DIS; __cs_strm(cs)->conn_exp = TICK_ETERNITY; return; } @@ -1296,7 +1296,7 @@ static int cs_conn_recv(struct stconn *cs) int flags = 0; /* If not established yet, do nothing. */ - if (cs->state != CS_ST_EST) + if (cs->state != SC_ST_EST) return 0; /* If another call to cs_conn_recv() failed, and we subscribed to @@ -1620,7 +1620,7 @@ static int cs_conn_recv(struct stconn *cs) */ int cs_conn_sync_recv(struct stconn *cs) { - if (!cs_state_in(cs->state, CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) return 0; if (!cs_conn_mux(cs)) @@ -1652,11 +1652,11 @@ static int cs_conn_send(struct stconn *cs) if (sc_ep_test(cs, SE_FL_ERROR | SE_FL_ERR_PENDING) || cs_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 CS_ST_TAR. There's still + * error and put the CS back to SC_ST_TAR. There's still * CO_FL_ERROR on the connection but we don't want to add * SE_FL_ERROR back, so give up */ - if (cs->state < CS_ST_CON) + if (cs->state < SC_ST_CON) return 0; sc_ep_set(cs, SE_FL_ERROR); return 1; @@ -1765,8 +1765,8 @@ static int cs_conn_send(struct stconn *cs) end: if (did_send) { oc->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA; - if (cs->state == CS_ST_CON) - cs->state = CS_ST_RDY; + if (cs->state == SC_ST_CON) + cs->state = SC_ST_RDY; cs_rx_room_rdy(cs_opposite(cs)); } @@ -1798,7 +1798,7 @@ void cs_conn_sync_send(struct stconn *cs) if (channel_is_empty(oc)) return; - if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST)) + if (!cs_state_in(cs->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST)) return; if (!cs_conn_mux(cs)) @@ -1838,7 +1838,7 @@ static int cs_conn_process(struct stconn *cs) * care of it. */ - if (cs->state >= CS_ST_CON) { + if (cs->state >= SC_ST_CON) { if (cs_is_conn_error(cs)) sc_ep_set(cs, SE_FL_ERROR); } @@ -1854,12 +1854,12 @@ static int cs_conn_process(struct stconn *cs) task_wakeup(cs_strm_task(cs), TASK_WOKEN_MSG); } - if (!cs_state_in(cs->state, CS_SB_EST|CS_SB_DIS|CS_SB_CLO) && + if (!cs_state_in(cs->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) && (conn->flags & CO_FL_WAIT_XPRT) == 0) { __cs_strm(cs)->conn_exp = TICK_ETERNITY; oc->flags |= CF_WRITE_NULL; - if (cs->state == CS_ST_CON) - cs->state = CS_ST_RDY; + if (cs->state == SC_ST_CON) + cs->state = SC_ST_RDY; } /* Report EOS on the channel if it was reached from the mux point of diff --git a/src/dns.c b/src/dns.c index cf61d1715..713008eb7 100644 --- a/src/dns.c +++ b/src/dns.c @@ -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 < CS_ST_EST) { + if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); cs_rx_conn_blk(cs); cs_rx_endp_more(cs); @@ -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 == CS_ST_EST) { + if (cs_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. */ diff --git a/src/flt_spoe.c b/src/flt_spoe.c index c96341d77..c745e1922 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -1390,13 +1390,13 @@ spoe_handle_connect_appctx(struct appctx *appctx) char *frame, *buf; int ret; - if (cs_state_in(cs->state, CS_SB_CER|CS_SB_DIS|CS_SB_CLO)) { + if (cs_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, CS_SB_RDY|CS_SB_EST)) { + if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) { /* not connected yet */ cs_rx_endp_more(cs); task_wakeup(__cs_strm(cs)->task, TASK_WOKEN_MSG); @@ -1457,7 +1457,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx) int ret; - if (cs->state == CS_ST_CLO || cs_opposite(cs)->state == CS_ST_CLO) { + if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) { SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO; goto exit; } @@ -1709,7 +1709,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 == CS_ST_CLO || cs_opposite(cs)->state == CS_ST_CLO) { + if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) { SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO; goto exit; } @@ -1832,7 +1832,7 @@ spoe_handle_disconnect_appctx(struct appctx *appctx) char *frame, *buf; int ret; - if (cs->state == CS_ST_CLO || cs_opposite(cs)->state == CS_ST_CLO) + if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) goto exit; if (appctx->st1 == SPOE_APPCTX_ERR_TOUT) @@ -1884,7 +1884,7 @@ spoe_handle_disconnecting_appctx(struct appctx *appctx) char *frame; int ret; - if (cs->state == CS_ST_CLO || cs_opposite(cs)->state == CS_ST_CLO) { + if (cs->state == SC_ST_CLO || cs_opposite(cs)->state == SC_ST_CLO) { SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_IO; goto exit; } diff --git a/src/hlua.c b/src/hlua.c index 4cda8257c..97da9312c 100644 --- a/src/hlua.c +++ b/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 < CS_ST_EST) { + if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); cs_rx_conn_blk(cs); cs_rx_endp_more(cs); @@ -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, CS_ST_ASS); + cs_set_state(s->scb, SC_ST_ASS); /* Force destination server. */ s->flags |= SF_DIRECT | SF_ASSIGNED | SF_BE_ASSIGNED; @@ -9329,7 +9329,7 @@ void hlua_applet_tcp_fct(struct appctx *ctx) } /* If the stream is disconnect or closed, ldo nothing. */ - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) return; /* Execute the function. */ @@ -9522,7 +9522,7 @@ void hlua_applet_http_fct(struct appctx *ctx) res_htx = htx_from_buf(&res->buf); /* If the stream is disconnect or closed, ldo nothing. */ - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) goto out; /* Check if the input buffer is available. */ @@ -10151,7 +10151,7 @@ static int hlua_cli_io_handler_fct(struct appctx *appctx) fcn = ctx->fcn; /* If the stream is disconnect or closed, ldo nothing. */ - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) return 1; /* Execute the function. */ diff --git a/src/http_ana.c b/src/http_ana.c index 66a36cb9d..308b7d666 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -4317,7 +4317,7 @@ void http_perform_server_redirect(struct stream *s, struct stconn *cs) cs_shutr(cs); cs_shutw(cs); s->conn_err_type = STRM_ET_NONE; - cs->state = CS_ST_CLO; + cs->state = SC_ST_CLO; if (!(s->flags & SF_ERR_MASK)) s->flags |= SF_ERR_LOCAL; diff --git a/src/sink.c b/src/sink.c index 804982a29..2ff2a66bc 100644 --- a/src/sink.c +++ b/src/sink.c @@ -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 < CS_ST_EST) { + if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); cs_rx_conn_blk(cs); cs_rx_endp_more(cs); @@ -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 == CS_ST_EST) { + if (cs_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. */ @@ -473,7 +473,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 < CS_ST_EST) { + if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); cs_rx_conn_blk(cs); cs_rx_endp_more(cs); @@ -512,7 +512,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 == CS_ST_EST) { + if (cs_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. */ diff --git a/src/stats.c b/src/stats.c index a4bdc695b..9d012bf90 100644 --- a/src/stats.c +++ b/src/stats.c @@ -4294,7 +4294,7 @@ static void http_stats_io_handler(struct appctx *appctx) res_htx = htx_from_buf(&res->buf); - if (unlikely(cs->state == CS_ST_DIS || cs->state == CS_ST_CLO)) + if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO)) goto out; /* Check if the input buffer is available. */ diff --git a/src/stream.c b/src/stream.c index acfe49422..99809ba62 100644 --- a/src/stream.c +++ b/src/stream.c @@ -420,7 +420,7 @@ struct stream *stream_new(struct session *sess, struct stconn *cs, struct buffer s->conn_retries = 0; s->conn_exp = TICK_ETERNITY; s->conn_err_type = STRM_ET_NONE; - s->prev_conn_state = CS_ST_INI; + s->prev_conn_state = SC_ST_INI; t->process = process_stream; t->context = s; t->expire = TICK_ETERNITY; @@ -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, CS_ST_EST); + cs_set_state(s->scf, SC_ST_EST); s->scf->hcto = sess->fe->timeout.clientfin; if (likely(sess->fe->options2 & PR_O2_INDEPSTR)) @@ -860,13 +860,13 @@ int stream_set_timeout(struct stream *s, enum act_timeout_name name, int timeout } /* - * This function handles the transition between the CS_ST_CON state and the - * CS_ST_EST state. It must only be called after switching from CS_ST_CON (or - * CS_ST_INI or CS_ST_RDY) to CS_ST_EST, but only when a ->proto is defined. - * Note that it will switch the interface to CS_ST_DIS if we already have + * This function handles the transition between the SC_ST_CON state and the + * SC_ST_EST state. It must only be called after switching from SC_ST_CON (or + * SC_ST_INI or SC_ST_RDY) to SC_ST_EST, but only when a ->proto is defined. + * Note that it will switch the interface to SC_ST_DIS if we already have * the CF_SHUTR flag, it means we were able to forward the request, and * receive the response, before process_stream() had the opportunity to - * make the switch from CS_ST_CON to CS_ST_EST. When that happens, we want + * make the switch from SC_ST_CON to SC_ST_EST. When that happens, we want * to go through back_establish() anyway, to make sure the analysers run. * Timeouts are cleared. Error are reported on the channel so that analysers * can handle them. @@ -940,9 +940,9 @@ static void back_establish(struct stream *s) } req->wex = TICK_ETERNITY; /* If we managed to get the whole response, and we don't have anything - * left to send, or can't, switch to CS_ST_DIS now. */ + * left to send, or can't, switch to SC_ST_DIS now. */ if (rep->flags & (CF_SHUTR | CF_SHUTW)) { - s->scb->state = CS_ST_DIS; + s->scb->state = SC_ST_DIS; DBG_TRACE_STATE("response channel shutdwn for read/write", STRM_EV_STRM_PROC|STRM_EV_CS_ST|STRM_EV_STRM_ERR, s); } @@ -956,7 +956,7 @@ static void back_establish(struct stream *s) static void sess_set_term_flags(struct stream *s) { if (!(s->flags & SF_FINST_MASK)) { - if (s->scb->state == CS_ST_INI) { + if (s->scb->state == SC_ST_INI) { /* anything before REQ in fact */ _HA_ATOMIC_INC(&strm_fe(s)->fe_counters.failed_req); if (strm_li(s) && strm_li(s)->counters) @@ -964,11 +964,11 @@ static void sess_set_term_flags(struct stream *s) s->flags |= SF_FINST_R; } - else if (s->scb->state == CS_ST_QUE) + else if (s->scb->state == SC_ST_QUE) s->flags |= SF_FINST_Q; - else if (cs_state_in(s->scb->state, CS_SB_REQ|CS_SB_TAR|CS_SB_ASS|CS_SB_CON|CS_SB_CER|CS_SB_RDY)) + 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)) s->flags |= SF_FINST_C; - else if (s->scb->state == CS_ST_EST || s->prev_conn_state == CS_ST_EST) + else if (s->scb->state == SC_ST_EST || s->prev_conn_state == SC_ST_EST) s->flags |= SF_FINST_D; else s->flags |= SF_FINST_L; @@ -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, CS_SB_RDY|CS_SB_EST)) + if (cs_state_in(scf->state, SC_SB_RDY|SC_SB_EST)) cs_update(scf); - if (cs_state_in(scb->state, CS_SB_RDY|CS_SB_EST)) + if (cs_state_in(scb->state, SC_SB_RDY|SC_SB_EST)) cs_update(scb); /* stream connectors are processed outside of process_stream() and must be @@ -1755,7 +1755,7 @@ 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, CS_SB_EST|CS_SB_DIS)) { + if (cs_state_in(scf->state, SC_SB_EST|SC_SB_DIS)) { cs_shutr(scf); cs_shutw(scf); cs_report_error(scf); @@ -1775,7 +1775,7 @@ 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, CS_SB_EST|CS_SB_DIS)) { + if (cs_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) { cs_shutr(scb); cs_shutw(scb); cs_report_error(scb); @@ -1798,23 +1798,23 @@ 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, CS_SB_CON|CS_SB_RDY)) { + if (cs_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, ... */ - if (scb->state == CS_ST_RDY) + if (scb->state == SC_ST_RDY) back_handle_st_rdy(s); - else if (s->scb->state == CS_ST_CON) + else if (s->scb->state == SC_ST_CON) back_handle_st_con(s); - if (scb->state == CS_ST_CER) + if (scb->state == SC_ST_CER) back_handle_st_cer(s); - else if (scb->state == CS_ST_EST) + else if (scb->state == SC_ST_EST) back_establish(s); - /* state is now one of CS_ST_CON (still in progress), CS_ST_EST - * (established), CS_ST_DIS (abort), CS_ST_CLO (last error), - * CS_ST_ASS/CS_ST_TAR/CS_ST_REQ for retryable errors. + /* state is now one of SC_ST_CON (still in progress), SC_ST_EST + * (established), SC_ST_DIS (abort), SC_ST_CLO (last error), + * SC_ST_ASS/SC_ST_TAR/SC_ST_REQ for retryable errors. */ } @@ -1827,8 +1827,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) DBG_TRACE_POINT(STRM_EV_STRM_PROC, s); /* nothing special to be done on client side */ - if (unlikely(scf->state == CS_ST_DIS)) { - scf->state = CS_ST_CLO; + if (unlikely(scf->state == SC_ST_DIS)) { + scf->state = SC_ST_CLO; /* This is needed only when debugging is enabled, to indicate * client-side close. @@ -1847,8 +1847,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* When a server-side connection is released, we have to count it and * check for pending connections on this server. */ - if (unlikely(scb->state == CS_ST_DIS)) { - scb->state = CS_ST_CLO; + if (unlikely(scb->state == SC_ST_DIS)) { + scb->state = SC_ST_CLO; srv = objt_server(s->target); if (srv) { if (s->flags & SF_CURR_SESS) { @@ -1866,7 +1866,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) { - if (s->prev_conn_state == CS_ST_EST) { + if (s->prev_conn_state == SC_ST_EST) { chunk_printf(&trash, "%08x:%s.srvcls[%04x:%04x]\n", s->uniq_id, s->be->id, (unsigned short)conn_fd(cs_conn(scf)), @@ -1891,7 +1891,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, CS_SB_EST|CS_SB_DIS|CS_SB_CLO)) { + if (cs_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; @@ -1992,7 +1992,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, CS_SB_EST|CS_SB_DIS|CS_SB_CLO)) { + if (cs_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; @@ -2105,11 +2105,11 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) sess_set_term_flags(s); /* Abort the request if a client error occurred while - * the backend stream connector is in the CS_ST_INI - * state. It is switched into the CS_ST_CLO state and + * the backend stream connector is in the SC_ST_INI + * state. It is switched into the SC_ST_CLO state and * the request channel is erased. */ - if (scb->state == CS_ST_INI) { - s->scb->state = CS_ST_CLO; + if (scb->state == SC_ST_INI) { + s->scb->state = SC_ST_CLO; channel_abort(req); if (IS_HTX_STRM(s)) channel_htx_erase(req, htxbuf(&req->buf)); @@ -2173,7 +2173,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, CS_SB_EST|CS_SB_DIS|CS_SB_CLO)) && + (cs_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 @@ -2226,14 +2226,14 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) * - there are data scheduled for emission in the buffer * - the CF_AUTO_CONNECT flag is set (active connection) */ - if (scb->state == CS_ST_INI) { + if (scb->state == SC_ST_INI) { if (!(req->flags & CF_SHUTW)) { if ((req->flags & CF_AUTO_CONNECT) || !channel_is_empty(req)) { /* If we have an appctx, there is no connect method, so we * immediately switch to the connected state, otherwise we * perform a connection request. */ - scb->state = CS_ST_REQ; /* new connection requested */ + scb->state = SC_ST_REQ; /* new connection requested */ s->conn_retries = 0; if ((s->be->retry_type &~ PR_RE_CONN_FAILED) && (s->be->mode == PR_MODE_HTTP) && @@ -2242,7 +2242,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) } } else { - s->scb->state = CS_ST_CLO; /* shutw+ini = abort */ + s->scb->state = SC_ST_CLO; /* shutw+ini = abort */ channel_shutw_now(req); /* fix buffer flags upon abort */ channel_shutr_now(res); } @@ -2252,7 +2252,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, CS_SB_REQ|CS_SB_QUE|CS_SB_TAR|CS_SB_ASS)) { + if (cs_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)) @@ -2264,26 +2264,26 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* nb: step 1 might switch from QUE to ASS, but we first want * to give a chance to step 2 to perform a redirect if needed. */ - if (scb->state != CS_ST_REQ) + if (scb->state != SC_ST_REQ) back_try_conn_req(s); - if (scb->state == CS_ST_REQ) + if (scb->state == SC_ST_REQ) back_handle_st_req(s); /* get a chance to complete an immediate connection setup */ - if (scb->state == CS_ST_RDY) + if (scb->state == SC_ST_RDY) goto resync_stconns; /* applets directly go to the ESTABLISHED state. Similarly, * servers experience the same fate when their connection * is reused. */ - if (unlikely(scb->state == CS_ST_EST)) + if (unlikely(scb->state == SC_ST_EST)) back_establish(s); srv = objt_server(s->target); - if (scb->state == CS_ST_ASS && srv && srv->rdr_len && (s->flags & SF_REDIRECTABLE)) + if (scb->state == SC_ST_ASS && srv && srv->rdr_len && (s->flags & SF_REDIRECTABLE)) http_perform_server_redirect(s, scb); - } while (scb->state == CS_ST_ASS); + } while (scb->state == SC_ST_ASS); } /* Let's see if we can send the pending request now */ @@ -2301,7 +2301,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) */ if (unlikely((req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CLOSE|CF_SHUTR)) == (CF_AUTO_CLOSE|CF_SHUTR) && - (scb->state != CS_ST_CON || (s->be->options & PR_O_ABRT_CLOSE)))) { + (scb->state != SC_ST_CON || (s->be->options & PR_O_ABRT_CLOSE)))) { channel_shutw_now(req); } @@ -2326,10 +2326,10 @@ 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 == CS_ST_DIS || - cs_state_in(scb->state, CS_SB_RDY|CS_SB_DIS) || - (sc_ep_test(scf, SE_FL_ERROR) && scf->state != CS_ST_CLO) || - (sc_ep_test(scb, SE_FL_ERROR) && scb->state != CS_ST_CLO)) + if (scf->state == SC_ST_DIS || + cs_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; /* otherwise we want to check if we need to resync the req buffer or not */ @@ -2345,7 +2345,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, CS_SB_EST|CS_SB_DIS|CS_SB_CLO) && + cs_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 @@ -2450,10 +2450,10 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) cs_shutr(scb); } - if (scf->state == CS_ST_DIS || - cs_state_in(scb->state, CS_SB_RDY|CS_SB_DIS) || - (sc_ep_test(scf, SE_FL_ERROR) && scf->state != CS_ST_CLO) || - (sc_ep_test(scb, SE_FL_ERROR) && scb->state != CS_ST_CLO)) + if (scf->state == SC_ST_DIS || + cs_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; if ((req->flags & ~rqf_last) & CF_MASK_ANALYSER) @@ -2469,7 +2469,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 != CS_ST_CLO) || !cs_state_in(scb->state, CS_SB_INI|CS_SB_CLO) || + if (likely((scf->state != SC_ST_CLO) || !cs_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);