]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: mux-quic: move qc_release()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 15 Jul 2022 08:32:53 +0000 (10:32 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 15 Jul 2022 13:56:13 +0000 (15:56 +0200)
This change is purely cosmetic. qc_release() function is moved just
before qc_io_cb(). It's cleaner as it brings it closer where it is used.
More importantly, this will be required to be able to use it in
qc_send() function.

src/mux_quic.c

index 5a0d9879e75987563bdd285d360be86bf68b99cf..74f91d90c0b4a0b20b42a5d03a8752280b85caa5 100644 (file)
@@ -1014,74 +1014,6 @@ static inline int qcc_may_expire(struct qcc *qcc)
        return !qcc->nb_sc;
 }
 
-/* release function. This one should be called to free all resources allocated
- * to the mux.
- */
-static void qc_release(struct qcc *qcc)
-{
-       struct connection *conn = qcc->conn;
-       struct eb64_node *node;
-
-       TRACE_ENTER(QMUX_EV_QCC_END);
-
-       if (qcc->app_ops && qcc->app_ops->release) {
-               /* Application protocol with dedicated connection closing
-                * procedure.
-                */
-               qcc->app_ops->release(qcc->ctx);
-       }
-       else {
-               qcc_emit_cc_app(qcc, QC_ERR_NO_ERROR, 0);
-       }
-
-       if (qcc->task) {
-               task_destroy(qcc->task);
-               qcc->task = NULL;
-       }
-
-       if (qcc->wait_event.tasklet)
-               tasklet_free(qcc->wait_event.tasklet);
-       if (conn && qcc->wait_event.events) {
-               conn->xprt->unsubscribe(conn, conn->xprt_ctx,
-                                       qcc->wait_event.events,
-                                       &qcc->wait_event);
-       }
-
-       /* liberate remaining qcs instances */
-       node = eb64_first(&qcc->streams_by_id);
-       while (node) {
-               struct qcs *qcs = eb64_entry(node, struct qcs, by_id);
-               node = eb64_next(node);
-               qcs_free(qcs);
-       }
-
-       while (!LIST_ISEMPTY(&qcc->lfctl.frms)) {
-               struct quic_frame *frm = LIST_ELEM(qcc->lfctl.frms.n, struct quic_frame *, list);
-               LIST_DELETE(&frm->list);
-               pool_free(pool_head_quic_frame, frm);
-       }
-
-       pool_free(pool_head_qcc, qcc);
-
-       if (conn) {
-               LIST_DEL_INIT(&conn->stopping_list);
-
-               conn->handle.qc->conn = NULL;
-               conn->mux = NULL;
-               conn->ctx = NULL;
-
-               TRACE_DEVEL("freeing conn", QMUX_EV_QCC_END, conn);
-
-               conn_stop_tracking(conn);
-               conn_full_close(conn);
-               if (conn->destroy_cb)
-                       conn->destroy_cb(conn);
-               conn_free(conn);
-       }
-
-       TRACE_LEAVE(QMUX_EV_QCC_END);
-}
-
 /* Transfer as much as possible data on <qcs> from <in> to <out>. This is done
  * in respect with available flow-control at stream and connection level.
  *
@@ -1654,6 +1586,74 @@ static int qc_purge_streams(struct qcc *qcc)
        return release;
 }
 
+/* release function. This one should be called to free all resources allocated
+ * to the mux.
+ */
+static void qc_release(struct qcc *qcc)
+{
+       struct connection *conn = qcc->conn;
+       struct eb64_node *node;
+
+       TRACE_ENTER(QMUX_EV_QCC_END);
+
+       if (qcc->app_ops && qcc->app_ops->release) {
+               /* Application protocol with dedicated connection closing
+                * procedure.
+                */
+               qcc->app_ops->release(qcc->ctx);
+       }
+       else {
+               qcc_emit_cc_app(qcc, QC_ERR_NO_ERROR, 0);
+       }
+
+       if (qcc->task) {
+               task_destroy(qcc->task);
+               qcc->task = NULL;
+       }
+
+       if (qcc->wait_event.tasklet)
+               tasklet_free(qcc->wait_event.tasklet);
+       if (conn && qcc->wait_event.events) {
+               conn->xprt->unsubscribe(conn, conn->xprt_ctx,
+                                       qcc->wait_event.events,
+                                       &qcc->wait_event);
+       }
+
+       /* liberate remaining qcs instances */
+       node = eb64_first(&qcc->streams_by_id);
+       while (node) {
+               struct qcs *qcs = eb64_entry(node, struct qcs, by_id);
+               node = eb64_next(node);
+               qcs_free(qcs);
+       }
+
+       while (!LIST_ISEMPTY(&qcc->lfctl.frms)) {
+               struct quic_frame *frm = LIST_ELEM(qcc->lfctl.frms.n, struct quic_frame *, list);
+               LIST_DELETE(&frm->list);
+               pool_free(pool_head_quic_frame, frm);
+       }
+
+       pool_free(pool_head_qcc, qcc);
+
+       if (conn) {
+               LIST_DEL_INIT(&conn->stopping_list);
+
+               conn->handle.qc->conn = NULL;
+               conn->mux = NULL;
+               conn->ctx = NULL;
+
+               TRACE_DEVEL("freeing conn", QMUX_EV_QCC_END, conn);
+
+               conn_stop_tracking(conn);
+               conn_full_close(conn);
+               if (conn->destroy_cb)
+                       conn->destroy_cb(conn);
+               conn_free(conn);
+       }
+
+       TRACE_LEAVE(QMUX_EV_QCC_END);
+}
+
 static struct task *qc_io_cb(struct task *t, void *ctx, unsigned int status)
 {
        struct qcc *qcc = ctx;