summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-01-25 15:00:10 +0000
committerMatt Caswell <matt@openssl.org>2016-01-29 11:36:44 +0000
commitec4479249d9c0b0a9e2ba6a8c59a0ed62530e954 (patch)
tree3de699b498f28799d1ef631d70e647125bfcf859 /apps
parent35ade23b02a02b5514941586030016b67ac0934e (diff)
Implement Async SSL_shutdown
This extends the existing async functionality to SSL_shutdown(), i.e. SSL_shutdown() can now casuse an SSL_ERROR_WANT_ASYNC error to be returned from SSL_get_error() if async mode has been enabled. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/s_client.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index 717d7c146b..fe402ae3a8 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -218,6 +218,27 @@ static int restore_errno(void)
return ret;
}
+static void do_ssl_shutdown(SSL *ssl)
+{
+ int ret;
+
+ do {
+ /* We only do unidirectional shutdown */
+ ret = SSL_shutdown(ssl);
+ if (ret < 0) {
+ switch (SSL_get_error(ssl, ret)) {
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_ASYNC:
+ /* We just do busy waiting. Nothing clever */
+ continue;
+ }
+ ret = 0;
+ }
+ } while (ret < 0);
+}
+
+
#ifndef OPENSSL_NO_PSK
/* Default PSK identity and key */
static char *psk_identity = "Client_identity";
@@ -2002,7 +2023,7 @@ int s_client_main(int argc, char **argv)
reconnect--;
BIO_printf(bio_c_out,
"drop connection and then reconnect\n");
- SSL_shutdown(con);
+ do_ssl_shutdown(con);
SSL_set_connect_state(con);
SHUTDOWN(SSL_get_fd(con));
goto re_start;
@@ -2320,7 +2341,7 @@ int s_client_main(int argc, char **argv)
shut:
if (in_init)
print_stuff(bio_c_out, con, full_log);
- SSL_shutdown(con);
+ do_ssl_shutdown(con);
SHUTDOWN(SSL_get_fd(con));
end:
if (con != NULL) {