]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Iterate over all received datagrams
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 28 Jan 2022 14:38:52 +0000 (15:38 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 28 Jan 2022 15:08:07 +0000 (16:08 +0100)
Make the listener datagram handler iterate over all received datagrams

src/xprt_quic.c

index a3a7bd0d6982a06ad38cb09d2fc4441e394cc507..caea3e67c75aa95e39526b79a09a297c38f4871c 100644 (file)
@@ -5368,37 +5368,39 @@ struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state)
        struct quic_dgram *dgram;
        int first_pkt = 1;
 
-       dgram = MT_LIST_POP(&dghdlr->dgrams, typeof(dgram), mt_list);
-       if (!dgram)
-               goto err;
+       while ((dgram = MT_LIST_POP(&dghdlr->dgrams, typeof(dgram), mt_list))) {
+               if (!dgram)
+                       goto err;
 
-       pos = dgram->buf;
-       end = pos + dgram->len;
-       do {
-               int ret;
-               struct quic_rx_packet *pkt;
+               pos = dgram->buf;
+               end = pos + dgram->len;
+               do {
+                       int ret;
+                       struct quic_rx_packet *pkt;
 
-               pkt = pool_zalloc(pool_head_quic_rx_packet);
-               if (!pkt)
-                       goto err;
+                       pkt = pool_zalloc(pool_head_quic_rx_packet);
+                       if (!pkt)
+                               goto err;
 
-               quic_rx_packet_refinc(pkt);
-               ret = qc_lstnr_pkt_rcv(pos, end, pkt, first_pkt, dgram);
-               first_pkt = 0;
-               pos += pkt->len;
-               quic_rx_packet_refdec(pkt);
-               if (ret == -1)
-                       /* If the packet length could not be found, we cannot continue. */
-                       break;
-       } while (pos < end);
-       /* Mark this datagram as consumed */
-       HA_ATOMIC_STORE(&dgram->buf, NULL);
+                       quic_rx_packet_refinc(pkt);
+                       ret = qc_lstnr_pkt_rcv(pos, end, pkt, first_pkt, dgram);
+                       first_pkt = 0;
+                       pos += pkt->len;
+                       quic_rx_packet_refdec(pkt);
+                       if (ret == -1)
+                               /* If the packet length could not be found, we cannot continue. */
+                               break;
+               } while (pos < end);
 
-       /* Increasing the received bytes counter by the UDP datagram length
-        * if this datagram could be associated to a connection.
-        */
-       if (dgram->qc)
-               dgram->qc->rx.bytes += dgram->len;
+               /* Mark this datagram as consumed */
+               HA_ATOMIC_STORE(&dgram->buf, NULL);
+
+               /* Increasing the received bytes counter by the UDP datagram length
+                * if this datagram could be associated to a connection.
+                */
+               if (dgram->qc)
+                       dgram->qc->rx.bytes += dgram->len;
+       }
 
        return t;