]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Remove useless lock for RX packets
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 11 Aug 2022 09:40:01 +0000 (11:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Aug 2022 12:33:43 +0000 (14:33 +0200)
This lock was there be able to handle the RX packets for a connetion
from several threads. This is no more needed since a QUIC connection
is always handled by the same thread.

May be backported to 2.6

include/haproxy/xprt_quic-t.h
include/haproxy/xprt_quic.h
src/xprt_quic.c

index 2b219eaa1a64a7f2d4936e9a9de0d0e43fa3597e..f6fcf95e595d0ff08359e61fb80956a8569ea905 100644 (file)
@@ -517,8 +517,6 @@ struct quic_enc_level {
                /* The packets received by the listener I/O handler
                   with header protection removed. */
                struct eb_root pkts;
-               /* <pkts> root must be protected from concurrent accesses */
-               __decl_thread(HA_RWLOCK_T pkts_rwlock);
                /* Liste of QUIC packets with protected header. */
                struct mt_list pqpkts;
                /* Crypto frames */
index a9e29cbcd055815b59f9a93faab99ca0381e1cc4..4f85be876da511b41d739ca952ea5ece2e7fd6c2 100644 (file)
@@ -667,9 +667,7 @@ static inline int qc_el_rx_pkts(struct quic_enc_level *qel)
 {
        int ret;
 
-       HA_RWLOCK_RDLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
        ret = !eb_is_empty(&qel->rx.pkts);
-       HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
 
        return ret;
 }
@@ -728,7 +726,6 @@ static inline void qc_el_rx_pkts_del(struct quic_enc_level *qel)
 {
        struct eb64_node *node;
 
-       HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
        node = eb64_first(&qel->rx.pkts);
        while (node) {
                struct quic_rx_packet *pkt =
@@ -738,14 +735,12 @@ static inline void qc_el_rx_pkts_del(struct quic_enc_level *qel)
                eb64_delete(&pkt->pn_node);
                quic_rx_packet_refdec(pkt);
        }
-       HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
 }
 
 static inline void qc_list_qel_rx_pkts(struct quic_enc_level *qel)
 {
        struct eb64_node *node;
 
-       HA_RWLOCK_RDLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
        node = eb64_first(&qel->rx.pkts);
        while (node) {
                struct quic_rx_packet *pkt;
@@ -755,7 +750,6 @@ static inline void qc_list_qel_rx_pkts(struct quic_enc_level *qel)
                        pkt, pkt->type, (ull)pkt->pn_node.key);
                node = eb64_next(node);
        }
-       HA_RWLOCK_RDUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
 }
 
 static inline void qc_list_all_rx_pkts(struct quic_conn *qc)
index 436f7017108fb2cb3867f66f75b5a684dfde1ddd..05ff1e7efcd6368b770c329eb4d4d1fc73f78371 100644 (file)
@@ -3697,10 +3697,8 @@ static inline void qc_rm_hp_pkts(struct quic_conn *qc, struct quic_enc_level *el
                        pqpkt->aad_len = pqpkt->pn_offset + pqpkt->pnl;
                        /* Store the packet into the tree of packets to decrypt. */
                        pqpkt->pn_node.key = pqpkt->pn;
-                       HA_RWLOCK_WRLOCK(QUIC_LOCK, &el->rx.pkts_rwlock);
                        eb64_insert(&el->rx.pkts, &pqpkt->pn_node);
                        quic_rx_packet_refinc(pqpkt);
-                       HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &el->rx.pkts_rwlock);
                        TRACE_DEVEL("hp removed", QUIC_EV_CONN_ELRMHP, qc, pqpkt);
                }
                MT_LIST_DELETE_SAFE(pkttmp1);
@@ -3769,7 +3767,6 @@ int qc_treat_rx_pkts(struct quic_enc_level *cur_el, struct quic_enc_level *next_
        if (!qel)
                goto out;
 
-       HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
        node = eb64_first(&qel->rx.pkts);
        while (node) {
                struct quic_rx_packet *pkt;
@@ -3811,7 +3808,6 @@ int qc_treat_rx_pkts(struct quic_enc_level *cur_el, struct quic_enc_level *next_
                eb64_delete(&pkt->pn_node);
                quic_rx_packet_refdec(pkt);
        }
-       HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
 
        if (largest_pn != -1 && largest_pn > qel->pktns->rx.largest_pn) {
                /* Update the largest packet number. */
@@ -4325,7 +4321,6 @@ static int quic_conn_enc_level_init(struct quic_conn *qc,
        qel->tls_ctx.flags = 0;
 
        qel->rx.pkts = EB_ROOT;
-       HA_RWLOCK_INIT(&qel->rx.pkts_rwlock);
        MT_LIST_INIT(&qel->rx.pqpkts);
        qel->rx.crypto.offset = 0;
        qel->rx.crypto.frms = EB_ROOT_UNIQUE;
@@ -4931,9 +4926,7 @@ static void qc_pkt_insert(struct quic_conn *qc,
 
        pkt->pn_node.key = pkt->pn;
        quic_rx_packet_refinc(pkt);
-       HA_RWLOCK_WRLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
        eb64_insert(&qel->rx.pkts, &pkt->pn_node);
-       HA_RWLOCK_WRUNLOCK(QUIC_LOCK, &qel->rx.pkts_rwlock);
 
        TRACE_LEAVE(QUIC_EV_CONN_RXPKT, qc);
 }