]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: skip sending if no frame to send in io-cb
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 8 Aug 2022 16:15:24 +0000 (18:15 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 9 Aug 2022 14:03:49 +0000 (16:03 +0200)
Check on quic_conn_io_cb() if sending is required. This allows to skip
over Tx buffer allocation if not needed.

To implement this, we check if frame lists on current and next
encryption level are empty. We also need to check if there is no need to
send ACK, PROBE or CONNECTION_CLOSE. This has been isolated in a new
function qc_need_sending() which may be reuse in some other functions in
the future.

src/xprt_quic.c

index cc2afd1fee6f39e3cba8677b4b6670c4e79937b5..076d93699bbbb97bbc213bfbf242ad30328a9d17 100644 (file)
@@ -3837,6 +3837,15 @@ out:
        return t;
 }
 
+/* Returns a boolean if <qc> needs to emit frames for <qel> encryption level. */
+static int qc_need_sending(struct quic_conn *qc, struct quic_enc_level *qel)
+{
+       return (qc->flags & QUIC_FL_CONN_IMMEDIATE_CLOSE) ||
+              (qel->pktns->flags & QUIC_FL_PKTNS_ACK_REQUIRED) ||
+              qel->pktns->tx.pto_probe ||
+              !LIST_ISEMPTY(&qel->pktns->tx.frms);
+}
+
 /* QUIC connection packet handler task. */
 struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
 {
@@ -3952,6 +3961,9 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
        if (!quic_get_tls_enc_levels(&tel, &next_tel, st, 0))
                goto err;
 
+       if (!qc_need_sending(qc, qel) && !qc_need_sending(qc, next_qel))
+               goto skip_send;
+
        buf = qc_txb_alloc(qc);
        if (!buf)
                goto err;