mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 12:44:45 +02:00
Fix to timeout after 10 seconds in non-blocking mode if connect does not complete.
This commit is contained in:
@@ -101,6 +101,8 @@ static int NonBlockingSSL_Connect(WOLFSSL* ssl)
|
||||
int error;
|
||||
SOCKET_T sockfd;
|
||||
int select_ret = 0;
|
||||
const int maxSec = 10;
|
||||
int elapsedSec = 0;
|
||||
|
||||
#ifndef WOLFSSL_CALLBACKS
|
||||
ret = wolfSSL_connect(ssl);
|
||||
@@ -151,9 +153,15 @@ static int NonBlockingSSL_Connect(WOLFSSL* ssl)
|
||||
ret = wolfSSL_connect_ex(ssl, handShakeCB, timeoutCB, timeout);
|
||||
#endif
|
||||
error = wolfSSL_get_error(ssl, 0);
|
||||
elapsedSec = 0; /* reset elapsed */
|
||||
}
|
||||
else if (select_ret == TEST_TIMEOUT && !wolfSSL_dtls(ssl)) {
|
||||
error = WOLFSSL_ERROR_WANT_READ;
|
||||
|
||||
elapsedSec += currTimeout;
|
||||
if (elapsedSec > maxSec) {
|
||||
error = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_DTLS
|
||||
else if (select_ret == TEST_TIMEOUT && wolfSSL_dtls(ssl) &&
|
||||
|
Reference in New Issue
Block a user