CLEANUP: mux-fcgi: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the fcgi_strm struct and in the few functions using this. The
name was also updated in the "show fd" output.
This commit is contained in:
Willy Tarreau 2022-05-27 16:15:32 +02:00
parent 95acc8b07f
commit 5aa5e77cad

View File

@ -154,7 +154,7 @@ enum fcgi_strm_st {
/* FCGI stream descriptor */ /* FCGI stream descriptor */
struct fcgi_strm { struct fcgi_strm {
struct sedesc *endp; struct sedesc *sd;
struct session *sess; struct session *sess;
struct fcgi_conn *fconn; struct fcgi_conn *fconn;
@ -378,7 +378,7 @@ static const struct sedesc closed_ep = {
/* a dmumy management stream */ /* a dmumy management stream */
static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){ static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
.endp = (struct sedesc*)&closed_ep, .sd = (struct sedesc*)&closed_ep,
.fconn = NULL, .fconn = NULL,
.state = FCGI_SS_CLOSED, .state = FCGI_SS_CLOSED,
.flags = FCGI_SF_NONE, .flags = FCGI_SF_NONE,
@ -387,7 +387,7 @@ static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
/* and a dummy idle stream for use with any unknown stream */ /* and a dummy idle stream for use with any unknown stream */
static const struct fcgi_strm *fcgi_unknown_stream = &(const struct fcgi_strm){ static const struct fcgi_strm *fcgi_unknown_stream = &(const struct fcgi_strm){
.endp = (struct sedesc*)&closed_ep, .sd = (struct sedesc*)&closed_ep,
.fconn = NULL, .fconn = NULL,
.state = FCGI_SS_IDLE, .state = FCGI_SS_IDLE,
.flags = FCGI_SF_NONE, .flags = FCGI_SF_NONE,
@ -425,7 +425,7 @@ static inline const char *fstrm_st_to_str(enum fcgi_strm_st st)
/* returns the stconn associated to the FCGI stream */ /* returns the stconn associated to the FCGI stream */
static forceinline struct stconn *fcgi_strm_sc(const struct fcgi_strm *fstrm) static forceinline struct stconn *fcgi_strm_sc(const struct fcgi_strm *fstrm)
{ {
return fstrm->endp->sc; return fstrm->sd->sc;
} }
@ -927,7 +927,7 @@ static inline void fcgi_strm_error(struct fcgi_strm *fstrm)
fstrm->state = FCGI_SS_ERROR; fstrm->state = FCGI_SS_ERROR;
TRACE_STATE("switching to ERROR", FCGI_EV_FSTRM_ERR, fstrm->fconn->conn, fstrm); TRACE_STATE("switching to ERROR", FCGI_EV_FSTRM_ERR, fstrm->fconn->conn, fstrm);
} }
se_fl_set_error(fstrm->endp); se_fl_set_error(fstrm->sd);
} }
} }
@ -1013,7 +1013,7 @@ static inline void fcgi_strm_close(struct fcgi_strm *fstrm)
if (!fstrm->id) if (!fstrm->id)
fstrm->fconn->nb_reserved--; fstrm->fconn->nb_reserved--;
if (fcgi_strm_sc(fstrm)) { if (fcgi_strm_sc(fstrm)) {
if (!se_fl_test(fstrm->endp, SE_FL_EOS) && !b_data(&fstrm->rxbuf)) if (!se_fl_test(fstrm->sd, SE_FL_EOS) && !b_data(&fstrm->rxbuf))
fcgi_strm_notify_recv(fstrm); fcgi_strm_notify_recv(fstrm);
} }
fstrm->state = FCGI_SS_CLOSED; fstrm->state = FCGI_SS_CLOSED;
@ -1045,8 +1045,8 @@ static void fcgi_strm_destroy(struct fcgi_strm *fstrm)
*/ */
LIST_DEL_INIT(&fstrm->send_list); LIST_DEL_INIT(&fstrm->send_list);
tasklet_free(fstrm->shut_tl); tasklet_free(fstrm->shut_tl);
BUG_ON(fstrm->endp && !se_fl_test(fstrm->endp, SE_FL_ORPHAN)); BUG_ON(fstrm->sd && !se_fl_test(fstrm->sd, SE_FL_ORPHAN));
sedesc_free(fstrm->endp); sedesc_free(fstrm->sd);
pool_free(pool_head_fcgi_strm, fstrm); pool_free(pool_head_fcgi_strm, fstrm);
TRACE_LEAVE(FCGI_EV_FSTRM_END, conn); TRACE_LEAVE(FCGI_EV_FSTRM_END, conn);
@ -1081,7 +1081,7 @@ static struct fcgi_strm *fcgi_strm_new(struct fcgi_conn *fconn, int id)
fstrm->shut_tl->context = fstrm; fstrm->shut_tl->context = fstrm;
LIST_INIT(&fstrm->send_list); LIST_INIT(&fstrm->send_list);
fstrm->fconn = fconn; fstrm->fconn = fconn;
fstrm->endp = NULL; fstrm->sd = NULL;
fstrm->flags = FCGI_SF_NONE; fstrm->flags = FCGI_SF_NONE;
fstrm->proto_status = 0; fstrm->proto_status = 0;
fstrm->state = FCGI_SS_IDLE; fstrm->state = FCGI_SS_IDLE;
@ -1137,7 +1137,7 @@ static struct fcgi_strm *fcgi_stconn_new(struct fcgi_conn *fconn, struct stconn
} }
if (sc_attach_mux(sc, fstrm, fconn->conn) < 0) if (sc_attach_mux(sc, fstrm, fconn->conn) < 0)
goto out; goto out;
fstrm->endp = sc->sedesc; fstrm->sd = sc->sedesc;
fstrm->sess = sess; fstrm->sess = sess;
fconn->nb_sc++; fconn->nb_sc++;
@ -1178,9 +1178,9 @@ static void fcgi_strm_wake_one_stream(struct fcgi_strm *fstrm)
} }
if ((fconn->state == FCGI_CS_CLOSED || fconn->conn->flags & CO_FL_ERROR)) { if ((fconn->state == FCGI_CS_CLOSED || fconn->conn->flags & CO_FL_ERROR)) {
se_fl_set(fstrm->endp, SE_FL_ERR_PENDING); se_fl_set(fstrm->sd, SE_FL_ERR_PENDING);
if (se_fl_test(fstrm->endp, SE_FL_EOS)) if (se_fl_test(fstrm->sd, SE_FL_EOS))
se_fl_set(fstrm->endp, SE_FL_ERROR); se_fl_set(fstrm->sd, SE_FL_ERROR);
if (fstrm->state < FCGI_SS_ERROR) { if (fstrm->state < FCGI_SS_ERROR) {
fstrm->state = FCGI_SS_ERROR; fstrm->state = FCGI_SS_ERROR;
@ -2628,10 +2628,10 @@ static void fcgi_process_demux(struct fcgi_conn *fconn)
fcgi_conn_read0_pending(fconn) || fcgi_conn_read0_pending(fconn) ||
fstrm->state == FCGI_SS_CLOSED || fstrm->state == FCGI_SS_CLOSED ||
(fstrm->flags & FCGI_SF_ES_RCVD) || (fstrm->flags & FCGI_SF_ES_RCVD) ||
se_fl_test(fstrm->endp, SE_FL_ERROR | SE_FL_ERR_PENDING | SE_FL_EOS))) { se_fl_test(fstrm->sd, SE_FL_ERROR | SE_FL_ERR_PENDING | SE_FL_EOS))) {
/* we may have to signal the upper layers */ /* we may have to signal the upper layers */
TRACE_DEVEL("notifying stream before switching SID", FCGI_EV_RX_RECORD|FCGI_EV_STRM_WAKE, fconn->conn, fstrm); TRACE_DEVEL("notifying stream before switching SID", FCGI_EV_RX_RECORD|FCGI_EV_STRM_WAKE, fconn->conn, fstrm);
se_fl_set(fstrm->endp, SE_FL_RCV_MORE); se_fl_set(fstrm->sd, SE_FL_RCV_MORE);
fcgi_strm_notify_recv(fstrm); fcgi_strm_notify_recv(fstrm);
} }
fstrm = tmp_fstrm; fstrm = tmp_fstrm;
@ -2709,10 +2709,10 @@ static void fcgi_process_demux(struct fcgi_conn *fconn)
fcgi_conn_read0_pending(fconn) || fcgi_conn_read0_pending(fconn) ||
fstrm->state == FCGI_SS_CLOSED || fstrm->state == FCGI_SS_CLOSED ||
(fstrm->flags & FCGI_SF_ES_RCVD) || (fstrm->flags & FCGI_SF_ES_RCVD) ||
se_fl_test(fstrm->endp, SE_FL_ERROR | SE_FL_ERR_PENDING | SE_FL_EOS))) { se_fl_test(fstrm->sd, SE_FL_ERROR | SE_FL_ERR_PENDING | SE_FL_EOS))) {
/* we may have to signal the upper layers */ /* we may have to signal the upper layers */
TRACE_DEVEL("notifying stream before switching SID", FCGI_EV_RX_RECORD|FCGI_EV_STRM_WAKE, fconn->conn, fstrm); TRACE_DEVEL("notifying stream before switching SID", FCGI_EV_RX_RECORD|FCGI_EV_STRM_WAKE, fconn->conn, fstrm);
se_fl_set(fstrm->endp, SE_FL_RCV_MORE); se_fl_set(fstrm->sd, SE_FL_RCV_MORE);
fcgi_strm_notify_recv(fstrm); fcgi_strm_notify_recv(fstrm);
} }
@ -3124,7 +3124,7 @@ static int fcgi_process(struct fcgi_conn *fconn)
while (node) { while (node) {
fstrm = container_of(node, struct fcgi_strm, by_id); fstrm = container_of(node, struct fcgi_strm, by_id);
if (fcgi_strm_sc(fstrm) && se_fl_test(fstrm->endp, SE_FL_WAIT_FOR_HS)) if (fcgi_strm_sc(fstrm) && se_fl_test(fstrm->sd, SE_FL_WAIT_FOR_HS))
fcgi_strm_notify_recv(fstrm); fcgi_strm_notify_recv(fstrm);
node = eb32_next(node); node = eb32_next(node);
} }
@ -3527,13 +3527,13 @@ static size_t fcgi_strm_parse_response(struct fcgi_strm *fstrm, struct buffer *b
* Attach a new stream to a connection * Attach a new stream to a connection
* (Used for outgoing connections) * (Used for outgoing connections)
*/ */
static int fcgi_attach(struct connection *conn, struct sedesc *endp, struct session *sess) static int fcgi_attach(struct connection *conn, struct sedesc *sd, struct session *sess)
{ {
struct fcgi_strm *fstrm; struct fcgi_strm *fstrm;
struct fcgi_conn *fconn = conn->ctx; struct fcgi_conn *fconn = conn->ctx;
TRACE_ENTER(FCGI_EV_FSTRM_NEW, conn); TRACE_ENTER(FCGI_EV_FSTRM_NEW, conn);
fstrm = fcgi_stconn_new(fconn, endp->sc, sess); fstrm = fcgi_stconn_new(fconn, sd->sc, sess);
if (!fstrm) if (!fstrm)
goto err; goto err;
@ -3587,9 +3587,9 @@ static void fcgi_destroy(void *ctx)
/* /*
* Detach the stream from the connection and possibly release the connection. * Detach the stream from the connection and possibly release the connection.
*/ */
static void fcgi_detach(struct sedesc *endp) static void fcgi_detach(struct sedesc *sd)
{ {
struct fcgi_strm *fstrm = endp->se; struct fcgi_strm *fstrm = sd->se;
struct fcgi_conn *fconn; struct fcgi_conn *fconn;
struct session *sess; struct session *sess;
@ -3728,7 +3728,7 @@ static void fcgi_do_shutr(struct fcgi_strm *fstrm)
* for example because of a "tcp-request content reject" rule that is * for example because of a "tcp-request content reject" rule that is
* normally used to limit abuse. * normally used to limit abuse.
*/ */
if (se_fl_test(fstrm->endp, SE_FL_KILL_CONN) && if (se_fl_test(fstrm->sd, SE_FL_KILL_CONN) &&
!(fconn->flags & (FCGI_CF_ABRTS_SENT|FCGI_CF_ABRTS_FAILED))) { !(fconn->flags & (FCGI_CF_ABRTS_SENT|FCGI_CF_ABRTS_FAILED))) {
TRACE_STATE("stream wants to kill the connection", FCGI_EV_STRM_SHUT, fconn->conn, fstrm); TRACE_STATE("stream wants to kill the connection", FCGI_EV_STRM_SHUT, fconn->conn, fstrm);
fconn->state = FCGI_CS_CLOSED; fconn->state = FCGI_CS_CLOSED;
@ -3789,7 +3789,7 @@ static void fcgi_do_shutw(struct fcgi_strm *fstrm)
* for example because of a "tcp-request content reject" rule that is * for example because of a "tcp-request content reject" rule that is
* normally used to limit abuse. * normally used to limit abuse.
*/ */
if (se_fl_test(fstrm->endp, SE_FL_KILL_CONN) && if (se_fl_test(fstrm->sd, SE_FL_KILL_CONN) &&
!(fconn->flags & (FCGI_CF_ABRTS_SENT|FCGI_CF_ABRTS_FAILED))) { !(fconn->flags & (FCGI_CF_ABRTS_SENT|FCGI_CF_ABRTS_FAILED))) {
TRACE_STATE("stream wants to kill the connection", FCGI_EV_STRM_SHUT, fconn->conn, fstrm); TRACE_STATE("stream wants to kill the connection", FCGI_EV_STRM_SHUT, fconn->conn, fstrm);
fconn->state = FCGI_CS_CLOSED; fconn->state = FCGI_CS_CLOSED;
@ -3959,18 +3959,18 @@ static size_t fcgi_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count,
TRACE_STATE("fstrm rxbuf not allocated", FCGI_EV_STRM_RECV|FCGI_EV_FSTRM_BLK, fconn->conn, fstrm); TRACE_STATE("fstrm rxbuf not allocated", FCGI_EV_STRM_RECV|FCGI_EV_FSTRM_BLK, fconn->conn, fstrm);
if (b_data(&fstrm->rxbuf)) if (b_data(&fstrm->rxbuf))
se_fl_set(fstrm->endp, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); se_fl_set(fstrm->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
else { else {
se_fl_clr(fstrm->endp, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); se_fl_clr(fstrm->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
if (fstrm->state == FCGI_SS_ERROR || (fstrm->h1m.state == H1_MSG_DONE)) { if (fstrm->state == FCGI_SS_ERROR || (fstrm->h1m.state == H1_MSG_DONE)) {
se_fl_set(fstrm->endp, SE_FL_EOI); se_fl_set(fstrm->sd, SE_FL_EOI);
if (!(fstrm->h1m.flags & (H1_MF_VER_11|H1_MF_XFER_LEN))) if (!(fstrm->h1m.flags & (H1_MF_VER_11|H1_MF_XFER_LEN)))
se_fl_set(fstrm->endp, SE_FL_EOS); se_fl_set(fstrm->sd, SE_FL_EOS);
} }
if (fcgi_conn_read0_pending(fconn)) if (fcgi_conn_read0_pending(fconn))
se_fl_set(fstrm->endp, SE_FL_EOS); se_fl_set(fstrm->sd, SE_FL_EOS);
if (se_fl_test(fstrm->endp, SE_FL_ERR_PENDING)) if (se_fl_test(fstrm->sd, SE_FL_ERR_PENDING))
se_fl_set(fstrm->endp, SE_FL_ERROR); se_fl_set(fstrm->sd, SE_FL_ERROR);
fcgi_release_buf(fconn, &fstrm->rxbuf); fcgi_release_buf(fconn, &fstrm->rxbuf);
} }
@ -4023,7 +4023,7 @@ static size_t fcgi_snd_buf(struct stconn *sc, struct buffer *buf, size_t count,
if (id < 0) { if (id < 0) {
fcgi_strm_close(fstrm); fcgi_strm_close(fstrm);
se_fl_set(fstrm->endp, SE_FL_ERROR); se_fl_set(fstrm->sd, SE_FL_ERROR);
TRACE_DEVEL("couldn't get a stream ID, leaving in error", FCGI_EV_STRM_SEND|FCGI_EV_FSTRM_ERR|FCGI_EV_STRM_ERR, fconn->conn, fstrm); TRACE_DEVEL("couldn't get a stream ID, leaving in error", FCGI_EV_STRM_SEND|FCGI_EV_FSTRM_ERR|FCGI_EV_STRM_ERR, fconn->conn, fstrm);
return 0; return 0;
} }
@ -4120,7 +4120,7 @@ static size_t fcgi_snd_buf(struct stconn *sc, struct buffer *buf, size_t count,
if (fstrm->state == FCGI_SS_ERROR) { if (fstrm->state == FCGI_SS_ERROR) {
TRACE_DEVEL("reporting error to the app-layer stream", FCGI_EV_STRM_SEND|FCGI_EV_FSTRM_ERR|FCGI_EV_STRM_ERR, fconn->conn, fstrm); TRACE_DEVEL("reporting error to the app-layer stream", FCGI_EV_STRM_SEND|FCGI_EV_FSTRM_ERR|FCGI_EV_STRM_ERR, fconn->conn, fstrm);
se_fl_set_error(fstrm->endp); se_fl_set_error(fstrm->sd);
if (!(fstrm->flags & FCGI_SF_BEGIN_SENT) || fcgi_strm_send_abort(fconn, fstrm)) if (!(fstrm->flags & FCGI_SF_BEGIN_SENT) || fcgi_strm_send_abort(fconn, fstrm))
fcgi_strm_close(fstrm); fcgi_strm_close(fstrm);
} }
@ -4192,9 +4192,9 @@ static int fcgi_show_fd(struct buffer *msg, struct connection *conn)
(unsigned int)b_data(&fstrm->rxbuf), b_orig(&fstrm->rxbuf), (unsigned int)b_data(&fstrm->rxbuf), b_orig(&fstrm->rxbuf),
(unsigned int)b_head_ofs(&fstrm->rxbuf), (unsigned int)b_size(&fstrm->rxbuf), (unsigned int)b_head_ofs(&fstrm->rxbuf), (unsigned int)b_size(&fstrm->rxbuf),
fcgi_strm_sc(fstrm)); fcgi_strm_sc(fstrm));
if (fstrm->endp) { if (fstrm->sd) {
chunk_appendf(msg, " .endp.flg=0x%08x", se_fl_get(fstrm->endp)); chunk_appendf(msg, " .sd.flg=0x%08x", se_fl_get(fstrm->sd));
if (!se_fl_test(fstrm->endp, SE_FL_ORPHAN)) if (!se_fl_test(fstrm->sd, SE_FL_ORPHAN))
chunk_appendf(msg, " .sc.flg=0x%08x .sc.app=%p", chunk_appendf(msg, " .sc.flg=0x%08x .sc.app=%p",
fcgi_strm_sc(fstrm)->flags, fcgi_strm_sc(fstrm)->app); fcgi_strm_sc(fstrm)->flags, fcgi_strm_sc(fstrm)->app);
} }