From: Amaury Denoyelle Date: Tue, 29 Mar 2022 12:57:19 +0000 (+0200) Subject: MINOR: mux-quic: return qcs instance from qcc_get_qcs X-Git-Tag: v2.6-dev5~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50742294f5c9e029f27b4db2e838941eaa656caa;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: return qcs instance from qcc_get_qcs 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. --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index ea6986c586..26d9250f7c 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -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 applicative layer of a QUIC connection on mux . * Returns 0 on success else non-zero. diff --git a/src/mux_quic.c b/src/mux_quic.c index 025f91c609..696dc8f20e 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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) diff --git a/src/xprt_quic.c b/src/xprt_quic.c index c2003704ac..0af176ec1f 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -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;