diff options
author | Matt Caswell <matt@openssl.org> | 2016-01-25 15:28:57 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-02-29 12:58:44 +0000 |
commit | ff75a25749c7fceaff7503af6f09d4299a052996 (patch) | |
tree | 4f7d8161e709ea1b82e9ceef0d27f78393b18127 /apps/apps.c | |
parent | b32166b4fabd2a3aeec382521b0173b24a5d7c02 (diff) | |
download | openssl-ff75a25749c7fceaff7503af6f09d4299a052996.tar.gz |
Refactor the async wait fd logic
Implementation experience has shown that the original plan for async wait
fds was too simplistic. Originally the async logic created a pipe internally
and user/engine code could then get access to it via API calls. It is more
flexible if the engine is able to create its own fd and provide it to the
async code.
Another issue is that there can be a lot of churn in the fd value within
the context of (say) a single SSL connection leading to continually adding
and removing fds from (say) epoll. It is better if we can provide some
stability of the fd value across a whole SSL connection. This is
problematic because an engine has no concept of an SSL connection.
This commit refactors things to introduce an ASYNC_WAIT_CTX which acts as a
proxy for an SSL connection down at the engine layer.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/apps.c b/apps/apps.c index 5ad090a44c..9f60e76dd8 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -2638,15 +2638,27 @@ BIO *bio_open_default_quiet(const char *filename, char mode, int format) void wait_for_async(SSL *s) { - int width, fd; + int width = 0; fd_set asyncfds; + OSSL_ASYNC_FD *fds; + size_t numfds; - fd = SSL_get_async_wait_fd(s); - if (fd < 0) + if (!SSL_get_all_async_fds(s, NULL, &numfds)) + return; + if (numfds == 0) return; + fds = OPENSSL_malloc(sizeof(OSSL_ASYNC_FD) * numfds); + if (!SSL_get_all_async_fds(s, fds, &numfds)) { + OPENSSL_free(fds); + } - width = fd + 1; FD_ZERO(&asyncfds); - openssl_fdset(fd, &asyncfds); + while (numfds > 0) { + if (width <= (int)*fds) + width = (int)*fds + 1; + openssl_fdset((int)*fds, &asyncfds); + numfds--; + fds++; + } select(width, (void *)&asyncfds, NULL, NULL, NULL); } |