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>
This commit is contained in:
Matt Caswell
2016-01-25 15:28:57 +00:00
parent b32166b4fa
commit ff75a25749
21 changed files with 792 additions and 325 deletions

View File

@@ -81,9 +81,23 @@ struct async_job_st {
void *funcargs;
int ret;
int status;
int wake_set;
OSSL_ASYNC_FD wait_fd;
OSSL_ASYNC_FD wake_fd;
ASYNC_WAIT_CTX *waitctx;
};
struct fd_lookup_st {
const void *key;
OSSL_ASYNC_FD fd;
void *custom_data;
void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
int add;
int del;
struct fd_lookup_st *next;
};
struct async_wait_ctx_st {
struct fd_lookup_st *fds;
size_t numadd;
size_t numdel;
};
DEFINE_STACK_OF(ASYNC_JOB)
@@ -98,7 +112,6 @@ int async_global_init(void);
void async_local_cleanup(void);
void async_global_cleanup(void);
void async_start_func(void);
int async_pipe(OSSL_ASYNC_FD *pipefds);
int async_close_fd(OSSL_ASYNC_FD fd);
int async_write1(OSSL_ASYNC_FD fd, const void *buf);
int async_read1(OSSL_ASYNC_FD fd, void *buf);
void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);