aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2015-03-31 02:04:22 +0200
committerDan Fandrich <dan@coneharvesters.com>2015-03-31 02:04:22 +0200
commit049fe7fb5336d17bd98c53384c944563e360a17a (patch)
treeec7e079a3cee857764eea12d9bddbec79065c3eb /lib
parent6419aee248d76b0cf53d1ff78b31a855fbff6f03 (diff)
axtls: add timeout within Curl_axtls_connect
This allows test 405 to pass on axTLS.
Diffstat (limited to 'lib')
-rw-r--r--lib/vtls/axtls.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/vtls/axtls.c b/lib/vtls/axtls.c
index 08db9c568..1038432b9 100644
--- a/lib/vtls/axtls.c
+++ b/lib/vtls/axtls.c
@@ -464,9 +464,11 @@ Curl_axtls_connect(struct connectdata *conn,
int sockindex)
{
+ struct SessionHandle *data = conn->data;
CURLcode conn_step = connect_prep(conn, sockindex);
int ssl_fcn_return;
SSL *ssl = conn->ssl[sockindex].ssl;
+ long timeout_ms;
if(conn_step != CURLE_OK) {
Curl_axtls_close(conn, sockindex);
@@ -475,14 +477,23 @@ Curl_axtls_connect(struct connectdata *conn,
/* Check to make sure handshake was ok. */
while(ssl_handshake_status(ssl) != SSL_OK) {
+ /* check allowed time left */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
ssl_fcn_return = ssl_read(ssl, NULL);
if(ssl_fcn_return < 0) {
Curl_axtls_close(conn, sockindex);
ssl_display_error(ssl_fcn_return); /* goes to stdout. */
return map_error_to_curl(ssl_fcn_return);
}
+ /* TODO: avoid polling */
usleep(10000);
- /* TODO: check for timeout as this could hang indefinitely otherwise */
}
infof (conn->data, "handshake completed successfully\n");