summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-10-04 17:50:53 +0100
committerMatt Caswell <matt@openssl.org>2023-10-06 10:55:24 +0100
commit2e62b07a41cca299f7abb69c892053b99ec762b2 (patch)
tree2b5191204fd7e6207471cdf3059474b70f9171a9
parent4ace824852f385002facf077c5be2815b0780032 (diff)
Don't wait in the tesrver idle testing every time around the loop
If we wait for 100ms 600 times - then the test takes a minute to complete which is far too long. The purpose of the wait is to give the assistance thread a chance to catch up. We only do that if the event timeout has actually expired - otherwise we are waiting for no reason. Fixes #22156 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22284)
-rw-r--r--test/quic_tserver_test.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/quic_tserver_test.c b/test/quic_tserver_test.c
index 980c9a83ff..6ed84f0ae6 100644
--- a/test/quic_tserver_test.c
+++ b/test/quic_tserver_test.c
@@ -305,6 +305,9 @@ static int do_test(int use_thread_assist, int use_fake_time, int use_inject)
if (c_start_idle_test && !c_done_idle_test) {
/* This is more than our default idle timeout of 30s. */
if (idle_units_done < 600) {
+ struct timeval tv;
+ int isinf;
+
if (!TEST_true(CRYPTO_THREAD_write_lock(fake_time_lock)))
goto err;
fake_time = ossl_time_add(fake_time, ossl_ms2time(100));
@@ -312,7 +315,16 @@ static int do_test(int use_thread_assist, int use_fake_time, int use_inject)
++idle_units_done;
ossl_quic_conn_force_assist_thread_wake(c_ssl);
- OSSL_sleep(100); /* Ensure CPU scheduling for test purposes */
+
+ /*
+ * If the event timeout has expired then give the assistance
+ * thread a chance to catch up
+ */
+ if (!TEST_true(SSL_get_event_timeout(c_ssl, &tv, &isinf)))
+ goto err;
+ if (!isinf && ossl_time_compare(ossl_time_zero(),
+ ossl_time_from_timeval(tv)) >= 0)
+ OSSL_sleep(100); /* Ensure CPU scheduling for test purposes */
} else {
c_done_idle_test = 1;
}