summaryrefslogtreecommitdiffstats
path: root/crypto/async
diff options
context:
space:
mode:
authorPing Yu <ping.yu@intel.com>2018-11-05 15:41:01 -0500
committerMatt Caswell <matt@openssl.org>2019-01-27 12:27:17 +0000
commit9f5a87fd665cb597fa1c1f4eef882d2d2f833e61 (patch)
tree3bad8287fe464c81267aa7cf43a41344fd6db414 /crypto/async
parent61e033308b1c004bd808352fb1d786547dcdf62b (diff)
add an additional async notification communication method based on callback
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Yang <yang.yang@baishancloud.com> Signed-off-by: Ping Yu <ping.yu@intel.com> Signed-off-by: Steven Linsell <stevenx.linsell@intel.com> (Merged from https://github.com/openssl/openssl/pull/7573)
Diffstat (limited to 'crypto/async')
-rw-r--r--crypto/async/async_locl.h3
-rw-r--r--crypto/async/async_wait.c35
2 files changed, 38 insertions, 0 deletions
diff --git a/crypto/async/async_locl.h b/crypto/async/async_locl.h
index 2325ce95ba..85dfcfa632 100644
--- a/crypto/async/async_locl.h
+++ b/crypto/async/async_locl.h
@@ -59,6 +59,9 @@ struct async_wait_ctx_st {
struct fd_lookup_st *fds;
size_t numadd;
size_t numdel;
+ ASYNC_callback_fn callback;
+ void *callback_arg;
+ int status;
};
DEFINE_STACK_OF(ASYNC_JOB)
diff --git a/crypto/async/async_wait.c b/crypto/async/async_wait.c
index 2553298e8e..642b781f7e 100644
--- a/crypto/async/async_wait.c
+++ b/crypto/async/async_wait.c
@@ -182,6 +182,41 @@ int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key)
return 0;
}
+int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx,
+ ASYNC_callback_fn callback,
+ void *callback_arg)
+{
+ if (ctx == NULL)
+ return 0;
+
+ ctx->callback = callback;
+ ctx->callback_arg = callback_arg;
+ return 1;
+}
+
+int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx,
+ ASYNC_callback_fn *callback,
+ void **callback_arg)
+{
+ if (ctx->callback == NULL)
+ return 0;
+
+ *callback = ctx->callback;
+ *callback_arg = ctx->callback_arg;
+ return 1;
+}
+
+int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status)
+{
+ ctx->status = status;
+ return 1;
+}
+
+int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx)
+{
+ return ctx->status;
+}
+
void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx)
{
struct fd_lookup_st *curr, *prev = NULL;