summaryrefslogtreecommitdiffstats
path: root/source3/lib/messages_dgm.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-05-05 08:45:52 +0200
committerVolker Lendecke <vl@samba.org>2014-05-08 09:10:12 +0200
commitdca572ff1ce1559a2254d9ba46d4f86d48c38c21 (patch)
treea64405496fff30d898ab000e924262b6af4275d0 /source3/lib/messages_dgm.c
parent5601576d9d182ca1741da6db5eb7cae405333329 (diff)
downloadsamba-dca572ff1ce1559a2254d9ba46d4f86d48c38c21.tar.gz
samba-dca572ff1ce1559a2254d9ba46d4f86d48c38c21.tar.xz
samba-dca572ff1ce1559a2254d9ba46d4f86d48c38c21.zip
lib: Enhance poll_funcs_tevent for multiple tevent_contexts
With this patch it will be possible to use nested event contexts with messaging_filtered_read_send/recv. Before this patchset only the one and only event context a messaging_context is initialized with is able to receive datagrams from the unix domain socket. So if you want to code a synchronous RPC-like operation using a nested event context, you will not see the reply, because the nested event context does not have the required tevent_fd's. Unfortunately, this patchset has to add some advanced array voodoo. The idea is that state->watches[] contains what we hand out with watch_new, and state->contexts contains references to the tevent_contexts. For every watch we need a tevent_fd in every event context, and the routines make sure that the arrays are properly maintained. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib/messages_dgm.c')
-rw-r--r--source3/lib/messages_dgm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 354dac3677..56643b1ffd 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -30,7 +30,8 @@
struct messaging_dgm_context {
struct messaging_context *msg_ctx;
- struct poll_funcs msg_callbacks;
+ struct poll_funcs *msg_callbacks;
+ void *tevent_handle;
struct unix_msg_ctx *dgm_ctx;
char *cache_dir;
int lockfile_fd;
@@ -224,7 +225,18 @@ NTSTATUS messaging_dgm_init(struct messaging_context *msg_ctx,
return map_nt_error_from_unix(ret);
}
- poll_funcs_init_tevent(&ctx->msg_callbacks, msg_ctx->event_ctx);
+ ctx->msg_callbacks = poll_funcs_init_tevent(ctx);
+ if (ctx->msg_callbacks == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ctx->tevent_handle = poll_funcs_tevent_register(
+ ctx, ctx->msg_callbacks, msg_ctx->event_ctx);
+ if (ctx->tevent_handle == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
ok = directory_create_or_exist_strict(socket_dir, sec_initial_uid(),
0700);
@@ -239,7 +251,7 @@ NTSTATUS messaging_dgm_init(struct messaging_context *msg_ctx,
generate_random_buffer((uint8_t *)&cookie, sizeof(cookie));
- ret = unix_msg_init(socket_name, &ctx->msg_callbacks, 1024, cookie,
+ ret = unix_msg_init(socket_name, ctx->msg_callbacks, 1024, cookie,
messaging_dgm_recv, ctx, &ctx->dgm_ctx);
TALLOC_FREE(socket_name);
if (ret != 0) {