diff options
author | Stefan Metzmacher <metze@samba.org> | 2012-05-11 15:19:55 +0200 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-06-12 15:38:56 +1000 |
commit | 4e6686e186e7f8efe95c48575846319985f74418 (patch) | |
tree | c6c70b5daa7a82a826c3a570f24f8d024f7ea794 /ctdb/lib | |
parent | c1d7791578faaf7c4c0c276b6daed2681eb7a7a3 (diff) | |
download | samba-4e6686e186e7f8efe95c48575846319985f74418.tar.gz samba-4e6686e186e7f8efe95c48575846319985f74418.tar.xz samba-4e6686e186e7f8efe95c48575846319985f74418.zip |
tevent: expose tevent_context_init_ops
This can be used to implement wrapper backends,
while passing a private pointer to the backens init function
via ev->additional_data.
metze
(This used to be ctdb commit 7ebc00dc6a89043a971a720e7c21baf5f2a0233d)
Diffstat (limited to 'ctdb/lib')
-rw-r--r-- | ctdb/lib/tevent/tevent.c | 8 | ||||
-rw-r--r-- | ctdb/lib/tevent/tevent.h | 14 |
2 files changed, 19 insertions, 3 deletions
diff --git a/ctdb/lib/tevent/tevent.c b/ctdb/lib/tevent/tevent.c index d3421a27180..6c6c6e7f8cc 100644 --- a/ctdb/lib/tevent/tevent.c +++ b/ctdb/lib/tevent/tevent.c @@ -210,8 +210,9 @@ int tevent_common_context_destructor(struct tevent_context *ev) NOTE: use tevent_context_init() inside of samba! */ -static struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx, - const struct tevent_ops *ops) +struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx, + const struct tevent_ops *ops, + void *additional_data) { struct tevent_context *ev; int ret; @@ -222,6 +223,7 @@ static struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx, talloc_set_destructor(ev, tevent_common_context_destructor); ev->ops = ops; + ev->additional_data = additional_data; ret = ev->ops->context_init(ev); if (ret != 0) { @@ -253,7 +255,7 @@ struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, for (e=tevent_backends;e;e=e->next) { if (strcmp(name, e->name) == 0) { - return tevent_context_init_ops(mem_ctx, e->ops); + return tevent_context_init_ops(mem_ctx, e->ops, NULL); } } return NULL; diff --git a/ctdb/lib/tevent/tevent.h b/ctdb/lib/tevent/tevent.h index e3b1ccd4935..60bc92ad272 100644 --- a/ctdb/lib/tevent/tevent.h +++ b/ctdb/lib/tevent/tevent.h @@ -126,6 +126,20 @@ struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx); struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name); /** + * @brief Create a custom event context + * + * @param[in] mem_ctx The memory context to use. + * @param[in] ops The function pointer table of the backend. + * @param[in] additional_data The additional/private data to this instance + * + * @return An allocated tevent context, NULL on error. + * + */ +struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx, + const struct tevent_ops *ops, + void *additional_data); + +/** * @brief List available backends. * * @param[in] mem_ctx The memory context to use. |