summaryrefslogtreecommitdiffstats
path: root/test/handshake_helper.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-12-16 11:18:47 +0100
committerRichard Levitte <levitte@openssl.org>2016-12-17 11:48:33 +0100
commitf8641c9c693179fe7461608c51aaa8700dca6da2 (patch)
tree1bd49ce09337ab0b5f70e7a03958aa9447190e24 /test/handshake_helper.c
parent6c8e02af7e8d789d2b3dd6efe937b8c64784643f (diff)
test/ssl_test: give up if both client and server wait on read
In some cases, both client and server end of the test can end up in SSL_ERROR_WANT_READ and never get out of it, making the test spin. Detect it and give up instead of waiting endlessly. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2096) (cherry picked from commit ceb6d746941063eccf7655c7709ba56ca117044b)
Diffstat (limited to 'test/handshake_helper.c')
-rw-r--r--test/handshake_helper.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/handshake_helper.c b/test/handshake_helper.c
index c14d8e38c4..1d0e2a4b99 100644
--- a/test/handshake_helper.c
+++ b/test/handshake_helper.c
@@ -867,7 +867,7 @@ static HANDSHAKE_RESULT *do_handshake_internal(
HANDSHAKE_EX_DATA server_ex_data, client_ex_data;
CTX_DATA client_ctx_data, server_ctx_data, server2_ctx_data;
HANDSHAKE_RESULT *ret = HANDSHAKE_RESULT_new();
- int client_turn = 1;
+ int client_turn = 1, client_turn_count = 0;
connect_phase_t phase = HANDSHAKE;
handshake_status_t status = HANDSHAKE_RETRY;
const unsigned char* tick = NULL;
@@ -956,6 +956,7 @@ static HANDSHAKE_RESULT *do_handshake_internal(
switch (status) {
case HANDSHAKE_SUCCESS:
+ client_turn_count = 0;
phase = next_phase(test_ctx, phase);
if (phase == CONNECTION_DONE) {
ret->result = SSL_TEST_SUCCESS;
@@ -981,6 +982,16 @@ static HANDSHAKE_RESULT *do_handshake_internal(
ret->result = SSL_TEST_INTERNAL_ERROR;
goto err;
case HANDSHAKE_RETRY:
+ if (client_turn_count++ >= 2000) {
+ /*
+ * At this point, there's been so many PEER_RETRY in a row
+ * that it's likely both sides are stuck waiting for a read.
+ * It's time to give up.
+ */
+ ret->result = SSL_TEST_INTERNAL_ERROR;
+ goto err;
+ }
+
/* Continue. */
client_turn ^= 1;
break;