summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-03-10 16:45:45 +1100
committerKarolin Seeger <kseeger@samba.org>2009-03-27 13:06:53 +0100
commite8c1a7eba2ff153defcf5e5dd89db251634ea973 (patch)
tree72718a54525d9943eb1eef44498d19c9591edfce
parente6b8b7e442f32a73ca87436617f0d63014cc5ade (diff)
downloadsamba-e8c1a7eba2ff153defcf5e5dd89db251634ea973.tar.gz
samba-e8c1a7eba2ff153defcf5e5dd89db251634ea973.tar.xz
samba-e8c1a7eba2ff153defcf5e5dd89db251634ea973.zip
fixed a bug in message handling for code the change notify code
The change notify code registered a separate message handler for each tree connect. This registration uses the global messaging context. The messaging code would consider a 2nd registration for the same messaging type as being an 'update' of the handler, rather than a new handler. It also would only call the first handler in the linked list for a given message type when dispatching messages. This patch changes the messaging code to allow for multiple registrations of the same message type, and allow for multiple calls to different messaging handler for one incoming message. This fixes the problem with the test_notify_tcon() test that I recently committed to the S4 smbtorture (cherry picked from commit 89e340e09fbdc375c0aa85506add525b8ba5dcd0) (cherry picked from commit 733881d22f9864ea371b29d7d1817fb4af6b865c)
-rw-r--r--source/lib/messages.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/lib/messages.c b/source/lib/messages.c
index ea03f8d43b5..641ff5321cc 100644
--- a/source/lib/messages.c
+++ b/source/lib/messages.c
@@ -278,7 +278,15 @@ NTSTATUS messaging_register(struct messaging_context *msg_ctx,
*/
for (cb = msg_ctx->callbacks; cb != NULL; cb = cb->next) {
- if (cb->msg_type == msg_type) {
+ /* we allow a second registration of the same message
+ type if it has a different private pointer. This is
+ needed in, for example, the internal notify code,
+ which creates a new notify context for each tree
+ connect, and expects to receive messages to each of
+ them. */
+ if (cb->msg_type == msg_type && private_data == cb->private_data) {
+ DEBUG(5,("Overriding messaging pointer for type %u - private_data=%p\n",
+ (unsigned)msg_type, private_data));
cb->fn = fn;
cb->private_data = private_data;
return NT_STATUS_OK;
@@ -309,6 +317,8 @@ void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
next = cb->next;
if ((cb->msg_type == msg_type)
&& (cb->private_data == private_data)) {
+ DEBUG(5,("Deregistering messaging pointer for type %u - private_data=%p\n",
+ (unsigned)msg_type, private_data));
DLIST_REMOVE(ctx->callbacks, cb);
TALLOC_FREE(cb);
}
@@ -354,7 +364,11 @@ void messaging_dispatch_rec(struct messaging_context *msg_ctx,
if (cb->msg_type == rec->msg_type) {
cb->fn(msg_ctx, cb->private_data, rec->msg_type,
rec->src, &rec->buf);
- return;
+ /* we continue looking for matching messages
+ after finding one. This matters for
+ subsystems like the internal notify code
+ which register more than one handler for
+ the same message type */
}
}
return;