]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: mux-quic/h3: complete BUG_ON with comments
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 11 May 2023 14:55:30 +0000 (16:55 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 22 May 2023 09:17:18 +0000 (11:17 +0200)
Complete each useful BUG_ON statements with a comment to explain its
purpose. Also convert BUG_ON_HOT to BUG_ON as they should not have a
big impact.

This should be backported up to 2.7.

src/h3.c
src/mux_quic.c

index 59e57c2bf5bdc3ffbd63e4fbd084c5e6e9a8ebf5..bff31c90f9b416433d1e1c869ddf7701b0cc449d 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -177,8 +177,8 @@ static ssize_t h3_init_uni_stream(struct h3c *h3c, struct qcs *qcs,
 
        TRACE_ENTER(H3_EV_H3S_NEW, qcs->qcc->conn, qcs);
 
-       BUG_ON_HOT(!quic_stream_is_uni(qcs->id) ||
-                  h3s->flags & H3_SF_UNI_INIT);
+       /* Function reserved to uni streams. Must be called only once per stream instance. */
+       BUG_ON(!quic_stream_is_uni(qcs->id) || h3s->flags & H3_SF_UNI_INIT);
 
        ret = b_quic_dec_int(&type, b, &len);
        if (!ret) {
@@ -257,8 +257,8 @@ static ssize_t h3_parse_uni_stream_no_h3(struct qcs *qcs, struct buffer *b, int
 {
        struct h3s *h3s = qcs->ctx;
 
-       BUG_ON_HOT(!quic_stream_is_uni(qcs->id) ||
-                  !(h3s->flags & H3_SF_UNI_NO_H3));
+       /* Function reserved to non-HTTP/3 unidirectional streams. */
+       BUG_ON(!quic_stream_is_uni(qcs->id) || !(h3s->flags & H3_SF_UNI_NO_H3));
 
        switch (h3s->type) {
        case H3S_T_QPACK_DEC:
@@ -309,7 +309,8 @@ static int h3_is_frame_valid(struct h3c *h3c, struct qcs *qcs, uint64_t ftype)
        struct h3s *h3s = qcs->ctx;
        const uint64_t id = qcs->id;
 
-       BUG_ON_HOT(h3s->type == H3S_T_UNKNOWN);
+       /* Stream type must be known to ensure frame is valid for this stream. */
+       BUG_ON(h3s->type == H3S_T_UNKNOWN);
 
        switch (ftype) {
        case H3_FT_DATA:
index c4b695754f0dfc4027c0788efa7bd178ec6c0378..24a5279187837bfe3127203de37e469d903ef013 100644 (file)
@@ -183,7 +183,7 @@ static forceinline void qcc_reset_idle_start(struct qcc *qcc)
 /* Decrement <qcc> sc. */
 static forceinline void qcc_rm_sc(struct qcc *qcc)
 {
-       BUG_ON_HOT(!qcc->nb_sc);
+       BUG_ON(!qcc->nb_sc); /* Ensure sc count is always valid (ie >=0). */
        --qcc->nb_sc;
 
        /* Reset qcc idle start for http-keep-alive timeout. Timeout will be
@@ -196,7 +196,7 @@ static forceinline void qcc_rm_sc(struct qcc *qcc)
 /* Decrement <qcc> hreq. */
 static forceinline void qcc_rm_hreq(struct qcc *qcc)
 {
-       BUG_ON_HOT(!qcc->nb_hreq);
+       BUG_ON(!qcc->nb_hreq); /* Ensure http req count is always valid (ie >=0). */
        --qcc->nb_hreq;
 
        /* Reset qcc idle start for http-keep-alive timeout. Timeout will be
@@ -587,7 +587,8 @@ static struct qcs *qcc_init_stream_remote(struct qcc *qcc, uint64_t id)
 
        TRACE_ENTER(QMUX_EV_QCS_NEW, qcc->conn);
 
-       BUG_ON_HOT(quic_stream_is_local(qcc, id));
+       /* Function reserved to remote stream IDs. */
+       BUG_ON(quic_stream_is_local(qcc, id));
 
        if (quic_stream_is_bidi(id)) {
                largest = &qcc->largest_bidi_r;