summaryrefslogtreecommitdiffstats
path: root/apps/s_server.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-07-24 08:15:31 +0100
committerMatt Caswell <matt@openssl.org>2015-11-20 23:33:46 +0000
commitf4da39d200a8c2068595b8d5bd5efb78af4224e1 (patch)
treeeb329d8d472063fc60ba93c76a83af7d3217b602 /apps/s_server.c
parent252d6d3aa62dccf0dc826644b7da0b6bafa3831b (diff)
Initial Async notify code changes
Initial API implemented for notifying applications that an ASYNC_JOB has completed. Currently only s_server is using this. The Dummy Async engine "cheats" in that it notifies that it has completed *before* it pauses the job. A normal async engine would not do that. Only the posix version of this has been implemented so far, so it will probably fail to compile on Windows at the moment. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/s_server.c')
-rw-r--r--apps/s_server.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/s_server.c b/apps/s_server.c
index 6fb8f675a3..75a3ba0a36 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -194,6 +194,7 @@ typedef unsigned int u_int;
static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength);
#endif
static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
+static void wait_for_async(SSL *s);
static int sv_body(char *hostname, int s, int stype, unsigned char *context);
static int www_body(char *hostname, int s, int stype, unsigned char *context);
static int rev_body(char *hostname, int s, int stype, unsigned char *context);
@@ -1735,7 +1736,7 @@ int s_server_main(int argc, char *argv[])
SSL_CTX_sess_set_cache_size(ctx2, 128);
if (async)
- SSL_CTX_set_mode(ctx2, SSL_MODE_ASYNC);
+ SSL_CTX_set_mode(ctx2, SSL_MODE_ASYNC);
if ((!SSL_CTX_load_verify_locations(ctx2, CAfile, CApath)) ||
(!SSL_CTX_set_default_verify_paths(ctx2))) {
@@ -2007,6 +2008,21 @@ static void print_stats(BIO *bio, SSL_CTX *ssl_ctx)
SSL_CTX_sess_get_cache_size(ssl_ctx));
}
+static void wait_for_async(SSL *s)
+{
+ int width, fd;
+ fd_set asyncfds;
+
+ fd = SSL_get_async_wait_fd(s);
+ if (!fd)
+ return;
+
+ width = fd + 1;
+ FD_ZERO(&asyncfds);
+ openssl_fdset(fd, &asyncfds);
+ select(width, (void *)&asyncfds, NULL, NULL, NULL);
+}
+
static int sv_body(char *hostname, int s, int stype, unsigned char *context)
{
char *buf = NULL;
@@ -2302,6 +2318,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
break;
case SSL_ERROR_WANT_ASYNC:
BIO_printf(bio_s_out, "Write BLOCK (Async)\n");
+ wait_for_async(con);
break;
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_READ:
@@ -2368,6 +2385,9 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
goto again;
break;
case SSL_ERROR_WANT_ASYNC:
+ BIO_printf(bio_s_out, "Read BLOCK (Async)\n");
+ wait_for_async(con);
+ break;
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_READ:
BIO_printf(bio_s_out, "Read BLOCK\n");