]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: return qcs instance from qcc_get_qcs
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 29 Mar 2022 12:57:19 +0000 (14:57 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 30 Mar 2022 14:12:18 +0000 (16:12 +0200)
Refactoring on qcc_get_qcs : return the qcs instance instead of the tree
node. This is useful to hide some eb64_entry macros for better
readability.

include/haproxy/mux_quic.h
src/mux_quic.c
src/xprt_quic.c

index ea6986c5869a99dcdc8c5ca9fb0f40488e3a9459..26d9250f7cad865b47fa13fd0a0b97f56d4f3955 100644 (file)
@@ -68,7 +68,7 @@ static inline int quic_stream_is_bidi(uint64_t id)
        return !quic_stream_is_uni(id);
 }
 
-struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id);
+struct qcs *qcc_get_qcs(struct qcc *qcc, uint64_t id);
 
 /* Install the <app_ops> applicative layer of a QUIC connection on mux <qcc>.
  * Returns 0 on success else non-zero.
index 025f91c609532f7c4679f71d941b05512f98d0f1..696dc8f20e02c46c6492139333443b52745091ca 100644 (file)
@@ -200,11 +200,12 @@ void qcs_notify_send(struct qcs *qcs)
  * several streams, depending on the already open ones.
  * Return this node if succeeded, NULL if not.
  */
-struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id)
+struct qcs *qcc_get_qcs(struct qcc *qcc, uint64_t id)
 {
        unsigned int strm_type;
        int64_t sub_id;
        struct eb64_node *strm_node;
+       struct qcs *qcs = NULL;
 
        strm_type = id & QCS_ID_TYPE_MASK;
        sub_id = id >> QCS_ID_TYPE_SHIFT;
@@ -216,6 +217,7 @@ struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id)
                        /* unknown stream id */
                        goto out;
                }
+               qcs = eb64_entry(strm_node, struct qcs, by_id);
        }
        else {
                /* Remote streams. */
@@ -244,29 +246,31 @@ struct eb64_node *qcc_get_qcs(struct qcc *qcc, uint64_t id)
                         * So, let's "open" these streams.
                         */
                        int64_t i;
-                       struct qcs *qcs;
+                       struct qcs *tmp_qcs;
 
-                       qcs = NULL;
+                       tmp_qcs = NULL;
                        for (i = largest_id + 1; i <= sub_id; i++) {
                                uint64_t id = (i << QCS_ID_TYPE_SHIFT) | strm_type;
                                enum qcs_type type = id & QCS_ID_DIR_BIT ? QCS_CLT_UNI : QCS_CLT_BIDI;
-                               qcs = qcs_new(qcc, id, type);
-                               if (!qcs) {
+                               tmp_qcs = qcs_new(qcc, id, type);
+                               if (!tmp_qcs) {
                                        /* allocation failure */
                                        goto out;
                                }
 
                                qcc->strms[qcs_type].largest_id = i;
                        }
-                       if (qcs)
-                               strm_node = &qcs->by_id;
+                       if (tmp_qcs)
+                               qcs = tmp_qcs;
                }
                else {
                        strm_node = eb64_lookup(strms, id);
+                       if (strm_node)
+                               qcs = eb64_entry(strm_node, struct qcs, by_id);
                }
        }
 
-       return strm_node;
+       return qcs;
 
  out:
        return NULL;
@@ -286,18 +290,16 @@ int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset,
              char fin, char *data, struct qcs **out_qcs)
 {
        struct qcs *qcs;
-       struct eb64_node *strm_node;
        size_t total, diff;
 
        TRACE_ENTER(QMUX_EV_QCC_RECV, qcc->conn);
 
-       strm_node = qcc_get_qcs(qcc, id);
-       if (!strm_node) {
+       qcs = qcc_get_qcs(qcc, id);
+       if (!qcs) {
                TRACE_DEVEL("leaving on stream not found", QMUX_EV_QCC_RECV|QMUX_EV_QCC_NQCS, qcc->conn, NULL, &id);
                return 1;
        }
 
-       qcs = eb64_entry(&strm_node->node, struct qcs, by_id);
        *out_qcs = qcs;
 
        if (offset > qcs->rx.offset)
index c2003704ac193c5761926a48d986f1a5082cf9fe..0af176ec1fdbf67244be6f8b06775b4b2ec23e10 100644 (file)
@@ -2165,17 +2165,15 @@ static int qc_handle_uni_strm_frm(struct quic_rx_packet *pkt,
                                   struct quic_conn *qc)
 {
        struct qcs *strm;
-       struct eb64_node *strm_node;
        struct quic_rx_strm_frm *frm;
        size_t strm_frm_len;
 
-       strm_node = qcc_get_qcs(qc->qcc, strm_frm->id);
-       if (!strm_node) {
+       strm = qcc_get_qcs(qc->qcc, strm_frm->id);
+       if (!strm) {
                TRACE_PROTO("Stream not found", QUIC_EV_CONN_PSTRM, qc);
                return 0;
        }
 
-       strm = eb64_entry(&strm_node->node, struct qcs, by_id);
        if (strm_frm->offset.key < strm->rx.offset) {
                size_t diff;