]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: define is_active app-ops
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 1 Apr 2022 15:56:58 +0000 (17:56 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 7 Apr 2022 08:23:10 +0000 (10:23 +0200)
Add a new app layer operation is_active. This can be used by the MUX to
check if the connection can be considered as active or not. This is used
inside qcc_is_dead as a first check.

For example on HTTP/3, if there is at least one bidir client stream
opened the connection is active. This explicitly ignore the uni streams
used for control and qpack as they can never be closed during the
connection lifetime.

include/haproxy/mux_quic-t.h
src/h3.c
src/hq_interop.c
src/mux_quic.c

index edc693026d8c1c948fc895d8eb3ca321f1f0dcd2..2a1cd862d8b29672bf9e5354fcce981bcfcca276 100644 (file)
@@ -117,6 +117,7 @@ struct qcc_app_ops {
        int (*decode_qcs)(struct qcs *qcs, int fin, void *ctx);
        size_t (*snd_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
        int (*finalize)(void *ctx);
+       int (*is_active)(const struct qcc *qcc, void *ctx);
        void (*release)(void *ctx);
 };
 
index 3cce59563203bfaf31cd161d7e4859298baee34f..e39c54135f6e88abcf6b9af19daba99020166fd9 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -897,6 +897,18 @@ static void h3_release(void *ctx)
        pool_free(pool_head_h3, h3);
 }
 
+/* Check if the H3 connection can still be considered as active.
+ *
+ * Return true if active else false.
+ */
+static int h3_is_active(const struct qcc *qcc, void *ctx)
+{
+       if (qcc->strms[QCS_CLT_BIDI].nb_streams)
+               return 1;
+
+       return 0;
+}
+
 /* HTTP/3 application layer operations */
 const struct qcc_app_ops h3_ops = {
        .init        = h3_init,
@@ -904,5 +916,6 @@ const struct qcc_app_ops h3_ops = {
        .decode_qcs  = h3_decode_qcs,
        .snd_buf     = h3_snd_buf,
        .finalize    = h3_finalize,
+       .is_active   = h3_is_active,
        .release     = h3_release,
 };
index 79283736cd1de444ac29e8c7dc6b80b959ec753d..71419d1ea8735cf2d92b1b9232a86058cd72206b 100644 (file)
@@ -166,7 +166,16 @@ static size_t hq_interop_snd_buf(struct conn_stream *cs, struct buffer *buf,
        return total;
 }
 
+static int hq_is_active(const struct qcc *qcc, void *ctx)
+{
+       if (!eb_is_empty(&qcc->streams_by_id))
+               return 1;
+
+       return 0;
+}
+
 const struct qcc_app_ops hq_interop_ops = {
        .decode_qcs = hq_interop_decode_qcs,
        .snd_buf    = hq_interop_snd_buf,
+       .is_active  = hq_is_active,
 };
index ad1a69367aaadbb2c983969767894b070511960b..34e9291ae803d3e89e012b35f2d6d47a699a4170 100644 (file)
@@ -462,7 +462,11 @@ static void qcs_destroy(struct qcs *qcs)
 
 static inline int qcc_is_dead(const struct qcc *qcc)
 {
-       if (!qcc->strms[QCS_CLT_BIDI].nb_streams && !qcc->task)
+       if (qcc->app_ops && qcc->app_ops->is_active &&
+           qcc->app_ops->is_active(qcc, qcc->ctx))
+               return 0;
+
+       if (!qcc->task)
                return 1;
 
        return 0;