summaryrefslogtreecommitdiffstats
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-05-02 09:20:40 +0000
committerVolker Lendecke <vl@samba.org>2014-05-08 09:10:12 +0200
commit5601576d9d182ca1741da6db5eb7cae405333329 (patch)
treef8d162678d9781fc40c4f6f59e3592dfba587d46 /source3/lib
parent8e719456917b3e862b4f13f759d6e6e6646055bd (diff)
downloadsamba-5601576d9d182ca1741da6db5eb7cae405333329.tar.gz
samba-5601576d9d182ca1741da6db5eb7cae405333329.tar.xz
samba-5601576d9d182ca1741da6db5eb7cae405333329.zip
messaging3: Add comments about not touching "waiters"
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')
-rw-r--r--source3/lib/messages.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 065782ac1b4..6a08531f2a8 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -491,6 +491,14 @@ struct tevent_req *messaging_filtered_read_send(
state->filter = filter;
state->private_data = private_data;
+ /*
+ * 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
+ * "waiters". We must be careful not to mess with this array, because
+ * it could mean that a single event is being delivered twice.
+ */
+
new_waiters_len = talloc_array_length(msg_ctx->new_waiters);
if (new_waiters_len == msg_ctx->num_new_waiters) {
@@ -521,6 +529,14 @@ static void messaging_filtered_read_cleanup(struct tevent_req *req,
tevent_req_set_cleanup_fn(req, NULL);
+ /*
+ * Just set the [new_]waiters entry to NULL, be careful not to mess
+ * with the other "waiters" array contents. We are often called from
+ * within "messaging_dispatch_rec", which loops over
+ * "waiters". Messing with the "waiters" array will mess up that
+ * for-loop.
+ */
+
for (i=0; i<msg_ctx->num_waiters; i++) {
if (msg_ctx->waiters[i] == req) {
msg_ctx->waiters[i] = NULL;