MINOR: mux-fcgi: remove the now unneeded conn_stream from the fcgi_strm

Since we always have a valid endpoint we can safely use it to access
the conn_stream and stop using fstrm->cs. That's one less pointer to
care about.
This commit is contained in:
Willy Tarreau 2022-05-10 15:30:53 +02:00
parent c84610c2ac
commit b57669e6a4

View File

@ -154,7 +154,6 @@ enum fcgi_strm_st {
/* FCGI stream descriptor */
struct fcgi_strm {
struct conn_stream *cs;
struct cs_endpoint *endp;
struct session *sess;
struct fcgi_conn *fconn;
@ -379,7 +378,6 @@ static const struct cs_endpoint closed_ep = {
/* a dmumy management stream */
static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
.cs = NULL,
.endp = (struct cs_endpoint*)&closed_ep,
.fconn = NULL,
.state = FCGI_SS_CLOSED,
@ -389,7 +387,6 @@ static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
/* and a dummy idle stream for use with any unknown stream */
static const struct fcgi_strm *fcgi_unknown_stream = &(const struct fcgi_strm){
.cs = NULL,
.endp = (struct cs_endpoint*)&closed_ep,
.fconn = NULL,
.state = FCGI_SS_IDLE,
@ -602,7 +599,7 @@ static int fcgi_buf_available(void *target)
}
if ((fconn->flags & FCGI_CF_DEM_SALLOC) &&
(fstrm = fcgi_conn_st_by_id(fconn, fconn->dsi)) && fstrm->cs &&
(fstrm = fcgi_conn_st_by_id(fconn, fconn->dsi)) && fstrm->endp->cs &&
b_alloc(&fstrm->rxbuf)) {
TRACE_STATE("unblocking fstrm, rxbuf allocated", FCGI_EV_STRM_RECV|FCGI_EV_FSTRM_BLK|FCGI_EV_STRM_WAKE, fconn->conn, fstrm);
fconn->flags &= ~FCGI_CF_DEM_SALLOC;
@ -924,8 +921,7 @@ static inline void fcgi_strm_error(struct fcgi_strm *fstrm)
fstrm->state = FCGI_SS_ERROR;
TRACE_STATE("switching to ERROR", FCGI_EV_FSTRM_ERR, fstrm->fconn->conn, fstrm);
}
if (fstrm->cs)
cs_ep_set_error(fstrm->endp);
cs_ep_set_error(fstrm->endp);
}
}
@ -975,9 +971,9 @@ static void fcgi_strm_alert(struct fcgi_strm *fstrm)
fcgi_strm_notify_recv(fstrm);
fcgi_strm_notify_send(fstrm);
}
else if (fstrm->cs && fstrm->cs->data_cb->wake != NULL) {
else if (fstrm->endp->cs && fstrm->endp->cs->data_cb->wake != NULL) {
TRACE_POINT(FCGI_EV_STRM_WAKE, fstrm->fconn->conn, fstrm);
fstrm->cs->data_cb->wake(fstrm->cs);
fstrm->endp->cs->data_cb->wake(fstrm->endp->cs);
}
}
@ -1010,7 +1006,7 @@ static inline void fcgi_strm_close(struct fcgi_strm *fstrm)
fstrm->fconn->nb_streams--;
if (!fstrm->id)
fstrm->fconn->nb_reserved--;
if (fstrm->cs) {
if (fstrm->endp->cs) {
if (!(fstrm->endp->flags & CS_EP_EOS) && !b_data(&fstrm->rxbuf))
fcgi_strm_notify_recv(fstrm);
}
@ -1079,7 +1075,6 @@ static struct fcgi_strm *fcgi_strm_new(struct fcgi_conn *fconn, int id)
fstrm->shut_tl->context = fstrm;
LIST_INIT(&fstrm->send_list);
fstrm->fconn = fconn;
fstrm->cs = NULL;
fstrm->endp = NULL;
fstrm->flags = FCGI_SF_NONE;
fstrm->proto_status = 0;
@ -1136,7 +1131,6 @@ static struct fcgi_strm *fcgi_conn_stream_new(struct fcgi_conn *fconn, struct co
}
if (cs_attach_mux(cs, fstrm, fconn->conn) < 0)
goto out;
fstrm->cs = cs;
fstrm->endp = cs->endp;
fstrm->sess = sess;
fconn->nb_cs++;
@ -1161,7 +1155,7 @@ static void fcgi_strm_wake_one_stream(struct fcgi_strm *fstrm)
TRACE_ENTER(FCGI_EV_STRM_WAKE, fconn->conn, fstrm);
if (!fstrm->cs) {
if (!fstrm->endp->cs) {
/* this stream was already orphaned */
fcgi_strm_destroy(fstrm);
TRACE_DEVEL("leaving with no fstrm", FCGI_EV_STRM_WAKE, fconn->conn);
@ -1236,8 +1230,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 = (cs_check(fstrm->cs) ? conn_src(fconn->conn) : cs_src(cs_opposite(fstrm->cs)));
const struct sockaddr_storage *dst = (cs_check(fstrm->cs) ? conn_dst(fconn->conn) : cs_dst(cs_opposite(fstrm->cs)));
const struct sockaddr_storage *src = (cs_check(fstrm->endp->cs) ? conn_src(fconn->conn) : cs_src(cs_opposite(fstrm->endp->cs)));
const struct sockaddr_storage *dst = (cs_check(fstrm->endp->cs) ? conn_dst(fconn->conn) : cs_dst(cs_opposite(fstrm->endp->cs)));
struct ist p;
if (!sl)
@ -2623,7 +2617,7 @@ static void fcgi_process_demux(struct fcgi_conn *fconn)
/* Only FCGI_CS_RECORD_D or FCGI_CS_RECORD_P */
tmp_fstrm = fcgi_conn_st_by_id(fconn, fconn->dsi);
if (tmp_fstrm != fstrm && fstrm && fstrm->cs &&
if (tmp_fstrm != fstrm && fstrm && fstrm->endp->cs &&
(b_data(&fstrm->rxbuf) ||
fcgi_conn_read0_pending(fconn) ||
fstrm->state == FCGI_SS_CLOSED ||
@ -2704,7 +2698,7 @@ static void fcgi_process_demux(struct fcgi_conn *fconn)
fail:
/* we can go here on missing data, blocked response or error */
if (fstrm && fstrm->cs &&
if (fstrm && fstrm->endp->cs &&
(b_data(&fstrm->rxbuf) ||
fcgi_conn_read0_pending(fconn) ||
fstrm->state == FCGI_SS_CLOSED ||
@ -3124,7 +3118,7 @@ static int fcgi_process(struct fcgi_conn *fconn)
while (node) {
fstrm = container_of(node, struct fcgi_strm, by_id);
if (fstrm->cs && fstrm->endp->flags & CS_EP_WAIT_FOR_HS)
if (fstrm->endp->cs && fstrm->endp->flags & CS_EP_WAIT_FOR_HS)
fcgi_strm_notify_recv(fstrm);
node = eb32_next(node);
}
@ -3319,11 +3313,11 @@ static void fcgi_strm_capture_bad_message(struct fcgi_conn *fconn, struct fcgi_s
struct proxy *other_end;
union error_snapshot_ctx ctx;
if (fstrm->cs && cs_strm(fstrm->cs)) {
if (fstrm->endp->cs && cs_strm(fstrm->endp->cs)) {
if (sess == NULL)
sess = __cs_strm(fstrm->cs)->sess;
sess = __cs_strm(fstrm->endp->cs)->sess;
if (!(h1m->flags & H1_MF_RESP))
other_end = __cs_strm(fstrm->cs)->be;
other_end = __cs_strm(fstrm->endp->cs)->be;
else
other_end = sess->fe;
} else
@ -3563,8 +3557,8 @@ static struct conn_stream *fcgi_get_first_cs(const struct connection *conn)
node = eb32_first(&fconn->streams_by_id);
while (node) {
fstrm = container_of(node, struct fcgi_strm, by_id);
if (fstrm->cs)
return fstrm->cs;
if (fstrm->endp->cs)
return fstrm->endp->cs;
node = eb32_next(node);
}
return NULL;
@ -3605,7 +3599,6 @@ static void fcgi_detach(struct conn_stream *cs)
sess = fstrm->sess;
fconn = fstrm->fconn;
fstrm->cs = NULL;
fconn->nb_cs--;
if (fstrm->proto_status == FCGI_PS_CANT_MPX_CONN) {
@ -3848,7 +3841,7 @@ struct task *fcgi_deferred_shut(struct task *t, void *ctx, unsigned int state)
/* We're done trying to send, remove ourself from the send_list */
LIST_DEL_INIT(&fstrm->send_list);
if (!fstrm->cs) {
if (!fstrm->endp->cs) {
fcgi_strm_destroy(fstrm);
if (fcgi_conn_is_dead(fconn))
fcgi_release(fconn);
@ -4166,7 +4159,7 @@ static int fcgi_show_fd(struct buffer *msg, struct connection *conn)
while (node) {
fstrm = container_of(node, struct fcgi_strm, by_id);
tree_cnt++;
if (!fstrm->cs)
if (!fstrm->endp->cs)
orph_cnt++;
node = eb32_next(node);
}
@ -4192,12 +4185,12 @@ static int fcgi_show_fd(struct buffer *msg, struct connection *conn)
fstrm, fstrm->id, fstrm->flags,
(unsigned int)b_data(&fstrm->rxbuf), b_orig(&fstrm->rxbuf),
(unsigned int)b_head_ofs(&fstrm->rxbuf), (unsigned int)b_size(&fstrm->rxbuf),
fstrm->cs);
fstrm->endp->cs);
if (fstrm->endp) {
chunk_appendf(msg, " .endp.flg=0x%08x", fstrm->endp->flags);
if (!(fstrm->endp->flags & CS_EP_ORPHAN))
chunk_appendf(msg, " .cs.flg=0x%08x .cs.app=%p",
fstrm->cs->flags, fstrm->cs->app);
fstrm->endp->cs->flags, fstrm->endp->cs->app);
}
chunk_appendf(&trash, " .subs=%p", fstrm->subs);
if (fstrm->subs) {