]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: implement h3 stream context
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 27 Apr 2022 16:04:01 +0000 (18:04 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 28 Apr 2022 13:44:19 +0000 (15:44 +0200)
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.

src/h3.c

index 459e360bff457dcb76d52470d82531c648e77635..2a46c1e148f349a381cd2b681599ba899a3d9be3 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -68,6 +68,11 @@ struct h3 {
 
 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 @@ size_t h3_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int
        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 @@ static int h3_attach_ruqs(struct qcs *qcs, void *ctx)
        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 @@ static int h3_is_active(const struct qcc *qcc, void *ctx)
 /* 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,