From: Hugo Landau Date: Tue, 22 Nov 2022 17:56:18 +0000 (+0000) Subject: QUIC CHANNEL: Only pump the demuxer once per tick X-Git-Tag: openssl-3.2.0-alpha1~1487 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bf4dc8c2106982d4ae6ada0650383e60f96d6e6;p=thirdparty%2Fopenssl.git QUIC CHANNEL: Only pump the demuxer once per tick Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19703) --- diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c index e02773a430b..fc42e65ee6f 100644 --- a/ssl/quic/quic_channel.c +++ b/ssl/quic/quic_channel.c @@ -18,6 +18,7 @@ #define INIT_CRYPTO_BUF_LEN 8192 #define INIT_APP_BUF_LEN 8192 +static void ch_rx_pre(QUIC_CHANNEL *ch); static int ch_rx(QUIC_CHANNEL *ch); static int ch_tx(QUIC_CHANNEL *ch); static void ch_tick(QUIC_TICK_RESULT *res, void *arg); @@ -1007,8 +1008,11 @@ static void ch_tick(QUIC_TICK_RESULT *res, void *arg) } } + /* Handle any incoming data from network. */ + ch_rx_pre(ch); + do { - /* Handle any incoming data from the network. */ + /* Process queued incoming packets. */ ch_rx(ch); /* @@ -1062,7 +1066,20 @@ static void ch_tick(QUIC_TICK_RESULT *res, void *arg) res->want_net_write = (ossl_qtx_get_queue_len_datagrams(ch->qtx) > 0); } -/* Process incoming packets and handle frames, if any. */ +/* Process incoming datagrams, if any. */ +static void ch_rx_pre(QUIC_CHANNEL *ch) +{ + if (!ch->have_sent_any_pkt) + return; + + /* + * Get DEMUX to BIO_recvmmsg from the network and queue incoming datagrams + * to the appropriate QRX instance. + */ + ossl_quic_demux_pump(ch->demux); /* best effort */ +} + +/* Process queued incoming packets and handle frames, if any. */ static int ch_rx(QUIC_CHANNEL *ch) { int handled_any = 0; @@ -1074,12 +1091,6 @@ static int ch_rx(QUIC_CHANNEL *ch) */ return 1; - /* - * Get DEMUX to BIO_recvmmsg from the network and queue incoming datagrams - * to the appropriate QRX instance. - */ - ossl_quic_demux_pump(ch->demux); /* best effort */ - for (;;) { assert(ch->qrx_pkt == NULL);