Skip to content

Commit

Permalink
Don't wait in the tesrver idle testing every time around the loop
Browse files Browse the repository at this point in the history
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 #22284)
  • Loading branch information
mattcaswell committed Oct 6, 2023
1 parent 4ace824 commit 2e62b07
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/quic_tserver_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,26 @@ 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));
CRYPTO_THREAD_unlock(fake_time_lock);

++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;
}
Expand Down

0 comments on commit 2e62b07

Please sign in to comment.