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>
This commit is contained in:
Matt Caswell
2015-07-24 08:15:31 +01:00
parent 252d6d3aa6
commit f4da39d200
9 changed files with 140 additions and 12 deletions

View File

@@ -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");