MINOR: h3: implement h3 stream context
Define a new structure h3s used to provide context for a H3 stream. This
structure is allocated and stored in the qcs thanks to previous commit
which provides app-layer context storage.
For now, h3s is empty. It will soon be completed to be able to support
stateful demux : this is required to be able to demux an incomplete
frame if the rx buffer is full.
diff --git a/src/h3.c b/src/h3.c
index 459e360..2a46c1e 100644
--- a/src/h3.c
+++ b/src/h3.c
@@ -68,6 +68,11 @@
DECLARE_STATIC_POOL(pool_head_h3, "h3", sizeof(struct h3));
+struct h3s {
+};
+
+DECLARE_STATIC_POOL(pool_head_h3s, "h3s", sizeof(struct h3s));
+
/* Simple function to duplicate a buffer */
static inline struct buffer h3_b_dup(struct buffer *b)
{
@@ -720,6 +725,18 @@
return total;
}
+static int h3_attach(struct qcs *qcs)
+{
+ struct h3s *h3s;
+
+ h3s = pool_alloc(pool_head_h3s);
+ if (!h3s)
+ return 1;
+
+ qcs->ctx = h3s;
+ return 0;
+}
+
/* Finalize the initialization of remotely initiated uni-stream <qcs>.
* Return 1 if succeeded, 0 if not. In this latter case, set the ->err h3 error
* to inform the QUIC mux layer of the encountered error.
@@ -780,6 +797,13 @@
return 1;
}
+static void h3_detach(struct qcs *qcs)
+{
+ struct h3s *h3s = qcs->ctx;
+ pool_free(pool_head_h3s, h3s);
+ qcs->ctx = NULL;
+}
+
static int h3_finalize(void *ctx)
{
struct h3 *h3 = ctx;
@@ -928,9 +952,11 @@
/* HTTP/3 application layer operations */
const struct qcc_app_ops h3_ops = {
.init = h3_init,
+ .attach = h3_attach,
.attach_ruqs = h3_attach_ruqs,
.decode_qcs = h3_decode_qcs,
.snd_buf = h3_snd_buf,
+ .detach = h3_detach,
.finalize = h3_finalize,
.is_active = h3_is_active,
.release = h3_release,