QUIC APL: Tick on SSL_read failure in non-blocking mode
authorHugo Landau <hlandau@openssl.org>
Thu, 6 Jul 2023 19:25:26 +0000 (20:25 +0100)
committerPauli <pauli@openssl.org>
Sun, 9 Jul 2023 23:09:30 +0000 (09:09 +1000)
...

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21381)

ssl/quic/quic_impl.c

index 2eb16027649aae4f1f83c1568019443f6755c82e..694e15b389358157d92acbd77386913c21430ea7 100644 (file)
@@ -2150,8 +2150,22 @@ static int quic_read(SSL *s, void *buf, size_t len, size_t *bytes_read, int peek
 
         ret = 1;
     } else {
-        /* We did not get any bytes and are not in blocking mode. */
-        ret = QUIC_RAISE_NORMAL_ERROR(&ctx, SSL_ERROR_WANT_READ);
+        /*
+         * We did not get any bytes and are not in blocking mode.
+         * Tick to see if this delivers any more.
+         */
+        ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(ctx.qc->ch), 0);
+
+        /* Try the read again. */
+        if (!quic_read_actual(&ctx, ctx.xso->stream, buf, len, bytes_read, peek)) {
+            ret = 0; /* quic_read_actual raised error here */
+            goto out;
+        }
+
+        if (*bytes_read > 0)
+            ret = 1; /* Succeeded this time. */
+        else
+            ret = QUIC_RAISE_NORMAL_ERROR(&ctx, SSL_ERROR_WANT_READ);
     }
 
 out: