summaryrefslogtreecommitdiffstats
path: root/source3/lib/messages.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-05-06 09:39:01 +0200
committerVolker Lendecke <vl@samba.org>2014-05-08 09:10:12 +0200
commite750e2b1eaf4b98a2870889cc100a150a1b09966 (patch)
tree413245130591bbf46abc3dc65433cfebbbccf292 /source3/lib/messages.c
parenta6e49f9cda6ae6c7ded534aca756b2387bdc8978 (diff)
downloadsamba-e750e2b1eaf4b98a2870889cc100a150a1b09966.tar.gz
samba-e750e2b1eaf4b98a2870889cc100a150a1b09966.tar.xz
samba-e750e2b1eaf4b98a2870889cc100a150a1b09966.zip
messaging3: Fix messaging_filtered_read_send
If we register an additional tevent context, we can now properly do nested event contexts, listening for just one message type inside a tevent_req_poll. At this point this only enhances things without ctdb, but I'm working fixing that soon. 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.c')
-rw-r--r--source3/lib/messages.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 6a08531f2a8..50c79a128d9 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -461,6 +461,7 @@ static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
struct messaging_filtered_read_state {
struct tevent_context *ev;
struct messaging_context *msg_ctx;
+ void *tevent_handle;
bool (*filter)(struct messaging_rec *rec, void *private_data);
void *private_data;
@@ -492,6 +493,18 @@ struct tevent_req *messaging_filtered_read_send(
state->private_data = private_data;
/*
+ * We have to defer the callback here, as we might be called from
+ * within a different tevent_context than state->ev
+ */
+ tevent_req_defer_callback(req, state->ev);
+
+ state->tevent_handle = messaging_dgm_register_tevent_context(
+ state, msg_ctx, ev);
+ if (tevent_req_nomem(state, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ /*
* We add ourselves to the "new_waiters" array, not the "waiters"
* array. If we are called from within messaging_read_done,
* messaging_dispatch_rec will be in an active for-loop on
@@ -529,6 +542,8 @@ static void messaging_filtered_read_cleanup(struct tevent_req *req,
tevent_req_set_cleanup_fn(req, NULL);
+ TALLOC_FREE(state->tevent_handle);
+
/*
* Just set the [new_]waiters entry to NULL, be careful not to mess
* with the other "waiters" array contents. We are often called from