MINOR: mux-quic: add a app-layer context in qcs
Define 2 new callback for qcc_app_ops : attach and detach. They are
called when a qcs instance is respectively allocated and freed. If
implemented, they can allocate a custom context stored in the new
abstract field ctx of qcs.
For now, h3 and hq-interop does not use these new callbacks. They will
be soon implemented by the h3 layer to allocate a context used for
stateful demuxing.
This change is required to support the demuxing of H3 frames bigger than
a buffer.
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 17adf46..5c5ba2c 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -116,6 +116,7 @@
qcs->qcc = qcc;
qcs->cs = NULL;
qcs->flags = QC_SF_NONE;
+ qcs->ctx = NULL;
/* allocate transport layer stream descriptor
*
@@ -126,6 +127,10 @@
if (!qcs->stream)
goto err;
+ if (qcc->app_ops->attach) {
+ if (qcc->app_ops->attach(qcs))
+ goto err;
+ }
qcs->endp = cs_endpoint_new();
if (!qcs->endp) {
@@ -169,6 +174,9 @@
return qcs;
err:
+ if (qcs->ctx && qcc->app_ops->detach)
+ qcc->app_ops->detach(qcs);
+
if (qcs->stream)
qc_stream_desc_release(qcs->stream);
@@ -188,6 +196,9 @@
BUG_ON(!qcs->qcc->strms[qcs_id_type(qcs->id)].nb_streams);
--qcs->qcc->strms[qcs_id_type(qcs->id)].nb_streams;
+ if (qcs->ctx && qcs->qcc->app_ops->detach)
+ qcs->qcc->app_ops->detach(qcs);
+
qc_stream_desc_release(qcs->stream);
BUG_ON(qcs->endp && !(qcs->endp->flags & CS_EP_ORPHAN));