MINOR: muxes: Don't expect to call release function with no mux defined

For all muxes, the function responsible to release a mux is always called
with a defined mux. Thus there is no reason to test if it is defined or not.

Note the patch may seem huge but it is just because of indentation changes.
This commit is contained in:
Christopher Faulet 2022-04-14 11:36:41 +02:00
parent 4e61096e30
commit 4de1bff866
5 changed files with 107 additions and 133 deletions

View File

@ -840,34 +840,28 @@ static inline struct fcgi_strm *fcgi_conn_st_by_id(struct fcgi_conn *fconn, int
*/
static void fcgi_release(struct fcgi_conn *fconn)
{
struct connection *conn = NULL;
struct connection *conn = fconn->conn;
TRACE_POINT(FCGI_EV_FCONN_END);
if (fconn) {
conn = fconn->conn;
if (LIST_INLIST(&fconn->buf_wait.list))
LIST_DEL_INIT(&fconn->buf_wait.list);
TRACE_DEVEL("freeing fconn", FCGI_EV_FCONN_END, conn);
fcgi_release_buf(fconn, &fconn->dbuf);
fcgi_release_mbuf(fconn);
if (LIST_INLIST(&fconn->buf_wait.list))
LIST_DEL_INIT(&fconn->buf_wait.list);
fcgi_release_buf(fconn, &fconn->dbuf);
fcgi_release_mbuf(fconn);
if (fconn->task) {
fconn->task->context = NULL;
task_wakeup(fconn->task, TASK_WOKEN_OTHER);
fconn->task = NULL;
}
if (fconn->wait_event.tasklet)
tasklet_free(fconn->wait_event.tasklet);
if (conn && fconn->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, fconn->wait_event.events,
&fconn->wait_event);
pool_free(pool_head_fcgi_conn, fconn);
if (fconn->task) {
fconn->task->context = NULL;
task_wakeup(fconn->task, TASK_WOKEN_OTHER);
fconn->task = NULL;
}
if (fconn->wait_event.tasklet)
tasklet_free(fconn->wait_event.tasklet);
if (conn && fconn->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, fconn->wait_event.events,
&fconn->wait_event);
pool_free(pool_head_fcgi_conn, fconn);
if (conn) {
conn->mux = NULL;

View File

@ -1055,56 +1055,52 @@ static void h1_release(struct h1c *h1c)
TRACE_POINT(H1_EV_H1C_END);
if (h1c) {
/* The connection must be aattached to this mux to be released */
if (h1c->conn && h1c->conn->ctx == h1c)
conn = h1c->conn;
/* The connection must be aattached to this mux to be released */
if (h1c->conn && h1c->conn->ctx == h1c)
conn = h1c->conn;
TRACE_DEVEL("freeing h1c", H1_EV_H1C_END, conn);
if (conn && h1c->flags & H1C_F_UPG_H2C) {
TRACE_DEVEL("upgrading H1 to H2", H1_EV_H1C_END, conn);
/* Make sure we're no longer subscribed to anything */
if (h1c->wait_event.events)
conn->xprt->unsubscribe(conn, conn->xprt_ctx,
h1c->wait_event.events, &h1c->wait_event);
if (conn_upgrade_mux_fe(conn, NULL, &h1c->ibuf, ist("h2"), PROTO_MODE_HTTP) != -1) {
/* connection successfully upgraded to H2, this
* mux was already released */
return;
}
TRACE_ERROR("h2 upgrade failed", H1_EV_H1C_END|H1_EV_H1C_ERR, conn);
sess_log(conn->owner); /* Log if the upgrade failed */
if (conn && h1c->flags & H1C_F_UPG_H2C) {
TRACE_DEVEL("upgrading H1 to H2", H1_EV_H1C_END, conn);
/* Make sure we're no longer subscribed to anything */
if (h1c->wait_event.events)
conn->xprt->unsubscribe(conn, conn->xprt_ctx,
h1c->wait_event.events, &h1c->wait_event);
if (conn_upgrade_mux_fe(conn, NULL, &h1c->ibuf, ist("h2"), PROTO_MODE_HTTP) != -1) {
/* connection successfully upgraded to H2, this
* mux was already released */
return;
}
if (LIST_INLIST(&h1c->buf_wait.list))
LIST_DEL_INIT(&h1c->buf_wait.list);
h1_release_buf(h1c, &h1c->ibuf);
h1_release_buf(h1c, &h1c->obuf);
if (h1c->task) {
h1c->task->context = NULL;
task_wakeup(h1c->task, TASK_WOKEN_OTHER);
h1c->task = NULL;
}
if (h1c->wait_event.tasklet)
tasklet_free(h1c->wait_event.tasklet);
h1s_destroy(h1c->h1s);
if (conn) {
if (h1c->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, h1c->wait_event.events,
&h1c->wait_event);
h1_shutw_conn(conn);
}
HA_ATOMIC_DEC(&h1c->px_counters->open_conns);
pool_free(pool_head_h1c, h1c);
TRACE_ERROR("h2 upgrade failed", H1_EV_H1C_END|H1_EV_H1C_ERR, conn);
sess_log(conn->owner); /* Log if the upgrade failed */
}
if (LIST_INLIST(&h1c->buf_wait.list))
LIST_DEL_INIT(&h1c->buf_wait.list);
h1_release_buf(h1c, &h1c->ibuf);
h1_release_buf(h1c, &h1c->obuf);
if (h1c->task) {
h1c->task->context = NULL;
task_wakeup(h1c->task, TASK_WOKEN_OTHER);
h1c->task = NULL;
}
if (h1c->wait_event.tasklet)
tasklet_free(h1c->wait_event.tasklet);
h1s_destroy(h1c->h1s);
if (conn) {
if (h1c->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, h1c->wait_event.events,
&h1c->wait_event);
h1_shutw_conn(conn);
}
HA_ATOMIC_DEC(&h1c->px_counters->open_conns);
pool_free(pool_head_h1c, h1c);
if (conn) {
if (!conn_is_back(conn))
LIST_DEL_INIT(&conn->stopping_list);

View File

@ -1161,37 +1161,32 @@ static inline struct h2s *h2c_st_by_id(struct h2c *h2c, int id)
*/
static void h2_release(struct h2c *h2c)
{
struct connection *conn = NULL;
struct connection *conn = h2c->conn;
TRACE_ENTER(H2_EV_H2C_END);
if (h2c) {
conn = h2c->conn;
hpack_dht_free(h2c->ddht);
TRACE_DEVEL("freeing h2c", H2_EV_H2C_END, conn);
hpack_dht_free(h2c->ddht);
if (LIST_INLIST(&h2c->buf_wait.list))
LIST_DEL_INIT(&h2c->buf_wait.list);
if (LIST_INLIST(&h2c->buf_wait.list))
LIST_DEL_INIT(&h2c->buf_wait.list);
h2_release_buf(h2c, &h2c->dbuf);
h2_release_mbuf(h2c);
h2_release_buf(h2c, &h2c->dbuf);
h2_release_mbuf(h2c);
if (h2c->task) {
h2c->task->context = NULL;
task_wakeup(h2c->task, TASK_WOKEN_OTHER);
h2c->task = NULL;
}
if (h2c->wait_event.tasklet)
tasklet_free(h2c->wait_event.tasklet);
if (conn && h2c->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, h2c->wait_event.events,
&h2c->wait_event);
HA_ATOMIC_DEC(&h2c->px_counters->open_conns);
pool_free(pool_head_h2c, h2c);
if (h2c->task) {
h2c->task->context = NULL;
task_wakeup(h2c->task, TASK_WOKEN_OTHER);
h2c->task = NULL;
}
if (h2c->wait_event.tasklet)
tasklet_free(h2c->wait_event.tasklet);
if (conn && h2c->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, h2c->wait_event.events,
&h2c->wait_event);
HA_ATOMIC_DEC(&h2c->px_counters->open_conns);
pool_free(pool_head_h2c, h2c);
if (conn) {
if (!conn_is_back(conn))

View File

@ -200,22 +200,18 @@ static void mux_pt_destroy(struct mux_pt_ctx *ctx)
TRACE_POINT(PT_EV_CONN_END);
if (ctx) {
/* The connection must be attached to this mux to be released */
if (ctx->conn && ctx->conn->ctx == ctx)
conn = ctx->conn;
/* The connection must be attached to this mux to be released */
if (ctx->conn && ctx->conn->ctx == ctx)
conn = ctx->conn;
TRACE_DEVEL("freeing pt context", PT_EV_CONN_END, conn);
tasklet_free(ctx->wait_event.tasklet);
tasklet_free(ctx->wait_event.tasklet);
if (conn && ctx->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, ctx->wait_event.events,
&ctx->wait_event);
BUG_ON(ctx->endp && !(ctx->endp->flags & CS_EP_ORPHAN));
cs_endpoint_free(ctx->endp);
pool_free(pool_head_pt_ctx, ctx);
}
if (conn && ctx->wait_event.events != 0)
conn->xprt->unsubscribe(conn, conn->xprt_ctx, ctx->wait_event.events,
&ctx->wait_event);
BUG_ON(ctx->endp && !(ctx->endp->flags & CS_EP_ORPHAN));
cs_endpoint_free(ctx->endp);
pool_free(pool_head_pt_ctx, ctx);
if (conn) {
conn->mux = NULL;

View File

@ -495,39 +495,32 @@ static inline int qcc_may_expire(struct qcc *qcc)
*/
static void qc_release(struct qcc *qcc)
{
struct connection *conn = NULL;
struct connection *conn = qcc->conn;
struct eb64_node *node;
TRACE_ENTER(QMUX_EV_QCC_END);
if (qcc) {
struct eb64_node *node;
if (qcc->app_ops && qcc->app_ops->release)
qcc->app_ops->release(qcc->ctx);
conn = qcc->conn;
TRACE_DEVEL("freeing qcc", QMUX_EV_QCC_END, conn);
if (qcc->app_ops && qcc->app_ops->release)
qcc->app_ops->release(qcc->ctx);
if (qcc->task) {
task_destroy(qcc->task);
qcc->task = NULL;
}
if (qcc->wait_event.tasklet)
tasklet_free(qcc->wait_event.tasklet);
/* liberate remaining qcs instances */
node = eb64_first(&qcc->streams_by_id);
while (node) {
struct qc_stream_desc *stream = eb64_entry(node, struct qc_stream_desc, by_id);
node = eb64_next(node);
qcs_free(stream->ctx);
}
pool_free(pool_head_qcc, qcc);
if (qcc->task) {
task_destroy(qcc->task);
qcc->task = NULL;
}
if (qcc->wait_event.tasklet)
tasklet_free(qcc->wait_event.tasklet);
/* liberate remaining qcs instances */
node = eb64_first(&qcc->streams_by_id);
while (node) {
struct qc_stream_desc *stream = eb64_entry(node, struct qc_stream_desc, by_id);
node = eb64_next(node);
qcs_free(stream->ctx);
}
pool_free(pool_head_qcc, qcc);
if (conn) {
LIST_DEL_INIT(&conn->stopping_list);