]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: add missing traces on closure
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Jan 2023 14:36:51 +0000 (15:36 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Jan 2023 15:16:46 +0000 (16:16 +0100)
Add traces for function h3_shutdown() / h3_send_goaway(). This should
help to debug problems related to connection closure.

This should be backported up to 2.7.

src/h3.c

index 616110b723a2a5468a622a4546b2b744e5eac55c..07a7e7cfcdf5ff64ba5d50c47f7795357fd88f95 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -66,6 +66,8 @@ static const struct trace_event h3_trace_events[] = {
        { .mask = H3_EV_H3S_NEW,      .name = "h3s_new",     .desc = "new H3 stream" },
 #define           H3_EV_H3S_END       (1ULL <<  8)
        { .mask = H3_EV_H3S_END,      .name = "h3s_end",     .desc = "H3 stream terminated" },
+#define           H3_EV_H3C_END       (1ULL <<  9)
+       { .mask = H3_EV_H3C_END,      .name = "h3c_end",     .desc = "H3 connection terminated" },
        { }
 };
 
@@ -1711,8 +1713,12 @@ static int h3_send_goaway(struct h3c *h3c)
        unsigned char data[3 * QUIC_VARINT_MAX_SIZE];
        size_t frm_len = quic_int_getsize(h3c->id_goaway);
 
-       if (!qcs)
-               return 1;
+       TRACE_ENTER(H3_EV_H3C_END, h3c->qcc);
+
+       if (!qcs) {
+               TRACE_ERROR("control stream not initialized", H3_EV_H3C_END, h3c->qcc);
+               goto err;
+       }
 
        pos = b_make((char *)data, sizeof(data), 0, 0);
 
@@ -1723,13 +1729,19 @@ static int h3_send_goaway(struct h3c *h3c)
        res = mux_get_buf(qcs);
        if (!res || b_room(res) < b_data(&pos)) {
                /* Do not try forcefully to emit GOAWAY if no space left. */
-               return 1;
+               TRACE_ERROR("cannot send GOAWAY", H3_EV_H3C_END, h3c->qcc, qcs);
+               goto err;
        }
 
        b_force_xfer(res, &pos, b_data(&pos));
        qcc_send_stream(qcs, 1);
 
+       TRACE_LEAVE(H3_EV_H3C_END, h3c->qcc);
        return 0;
+
+ err:
+       TRACE_DEVEL("leaving in error", H3_EV_H3C_END, h3c->qcc);
+       return 1;
 }
 
 /* Initialize the HTTP/3 context for <qcc> mux.
@@ -1768,6 +1780,8 @@ static void h3_shutdown(void *ctx)
 {
        struct h3c *h3c = ctx;
 
+       TRACE_ENTER(H3_EV_H3C_END, h3c->qcc);
+
        /* RFC 9114 5.2. Connection Shutdown
         *
         * Even when a connection is not idle, either endpoint can decide to
@@ -1784,6 +1798,8 @@ static void h3_shutdown(void *ctx)
         * the connection.
         */
        qcc_emit_cc_app(h3c->qcc, H3_NO_ERROR, 0);
+
+       TRACE_LEAVE(H3_EV_H3C_END, h3c->qcc);
 }
 
 static void h3_release(void *ctx)