From 1a6c24ecaf5d26a3312b2c164282a4ae594917d3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa <404610+tatsuhiro-t@users.noreply.github.com> Date: Sat, 13 Mar 2021 05:37:34 +0900 Subject: [PATCH] QUIC: Process multiple post-handshake messages in a single call (#16) --- ssl/ssl_quic.c | 27 +++++++++++++-------------- test/sslapitest.c | 6 ++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ssl/ssl_quic.c b/ssl/ssl_quic.c index 49a4f3ab5c7ed..6cbd47ad2d390 100644 --- a/ssl/ssl_quic.c +++ b/ssl/ssl_quic.c @@ -334,20 +334,19 @@ int SSL_process_quic_post_handshake(SSL *ssl) } /* if there is no data, return success as BoringSSL */ - if (ssl->quic_input_data_head == NULL) - return 1; - - /* - * This is always safe (we are sure to be at a record boundary) because - * SSL_read()/SSL_write() are never used for QUIC connections -- the - * application data is handled at the QUIC layer instead. - */ - ossl_statem_set_in_init(ssl, 1); - ret = ssl->handshake_func(ssl); - ossl_statem_set_in_init(ssl, 0); - - if (ret <= 0) - return 0; + while (ssl->quic_input_data_head != NULL) { + /* + * This is always safe (we are sure to be at a record boundary) because + * SSL_read()/SSL_write() are never used for QUIC connections -- the + * application data is handled at the QUIC layer instead. + */ + ossl_statem_set_in_init(ssl, 1); + ret = ssl->handshake_func(ssl); + ossl_statem_set_in_init(ssl, 0); + + if (ret <= 0) + return 0; + } return 1; } diff --git a/test/sslapitest.c b/test/sslapitest.c index 56dd5690469a4..9897e60ca2054 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -9580,8 +9580,7 @@ static int test_quic_api_version(int clnt, int srvr) goto end; /* Deal with two NewSessionTickets */ - if (!TEST_true(SSL_process_quic_post_handshake(clientssl)) - || !TEST_true(SSL_process_quic_post_handshake(clientssl))) + if (!TEST_true(SSL_process_quic_post_handshake(clientssl))) goto end; /* Dummy handshake call should succeed */ @@ -9773,8 +9772,7 @@ static int quic_setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, return 0; /* Deal with two NewSessionTickets */ - if (!TEST_true(SSL_process_quic_post_handshake(*clientssl)) - || !TEST_true(SSL_process_quic_post_handshake(*clientssl))) + if (!TEST_true(SSL_process_quic_post_handshake(*clientssl))) return 0; *sess = SSL_get1_session(*clientssl);