Commit ed57129cd4 for openssl.org

commit ed57129cd43b77e077c68fd5f7ea951976766f38
Author: Ryan Hooper <ryanh@openssl.foundation>
Date:   Thu Sep 3 14:40:33 2026 -0400

    test/dtlsssllistenertest.c: fix flaky zero-wait handshake loops

    test_dtls_listener_max_dgram_size_functional()
    and test_dtls_notifier_signalled_on_accept_queue_push() drive a real
    loopback UDP handshake in a fixed 100-iteration loop that polls
    with a zero timeout and never sleeps between attempts.  If loopback
    delivery lags - as it does intermittently on macOS CI runners -
    the loop can exhaust its budget before a datagram becomes readable
    and the test fails with "did not converge", even though the listener
    is working correctly.

    This is the same bug fixed in drive_until_connection_queued()
    by 271222650b ("dtls: fix flaky cookie exchange loop in listener
    test"). Apply the same treatment here: sleep 10ms between iterations
    so a delayed datagram has time to arrive, and raise the iteration
    cap to 200 so the budget still covers the client's 1s initial
    retransmit timer if a datagram is lost outright.

    Every other real-socket convergence loop in the file already waits
    on the SSL_poll() call itself (poll_timeout.tv_usec = 100000) rather
    than busy-spinning, and the remaining zero-timeout loops are backed
    by an in-memory dgram BIO pair with synchronous delivery, so neither
    needed this fix.

    Assisted-by: Claude:claude-sonnet-5
    Reviewed-by: Jakub Zelenka <jakub.zelenka@openssl.foundation>
    Reviewed-by: Mounir Idrassi <mounir.idrassi@idrix.fr>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Merge-date: Wed Oct 14 11:41:42 2026
    Merged-from: https://github.com/openssl/openssl/pull/32673

diff --git a/test/dtlsssllistenertest.c b/test/dtlsssllistenertest.c
index 7e701a5bf7..8d327c9b77 100644
--- a/test/dtlsssllistenertest.c
+++ b/test/dtlsssllistenertest.c
@@ -4232,7 +4232,7 @@ static int test_dtls_listener_max_dgram_size_functional(void)

     SSL_set_connect_state(clientssl);
     while (serverssl == NULL) {
-        if (++abortctr > 100) {
+        if (++abortctr > 200) {
             TEST_error("connection did not converge (oversized ClientHello)");
             goto end;
         }
@@ -4260,6 +4260,9 @@ static int test_dtls_listener_max_dgram_size_functional(void)
         if (poll_result > 0 && (poll_item.revents & SSL_POLL_EVENT_IC) != 0)
             serverssl = SSL_accept_connection(listener,
                 SSL_ACCEPT_CONNECTION_NO_BLOCK);
+
+        /* Loopback delivery can lag and a lost datagram needs a retransmit */
+        OSSL_sleep(10);
     }

     if (!TEST_ptr(serverssl))
@@ -5022,7 +5025,7 @@ static int test_dtls_notifier_signalled_on_accept_queue_push(void)
     poll_timeout.tv_usec = 0;

     SSL_set_connect_state(clientssl);
-    for (abortctr = 0; abortctr < 100; abortctr++) {
+    for (abortctr = 0; abortctr < 200; abortctr++) {
         retc = SSL_connect(clientssl);
         err_code = SSL_get_error(clientssl, retc);
         if (retc <= 0
@@ -5055,6 +5058,9 @@ static int test_dtls_notifier_signalled_on_accept_queue_push(void)

         if ((poll_item.revents & SSL_POLL_EVENT_IC) != 0)
             break;
+
+        /* Loopback delivery can lag and a lost datagram needs a retransmit */
+        OSSL_sleep(10);
     }

     if (!TEST_size_t_gt(SSL_get_accept_connection_queue_len(listener), 0))