summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-12-14 01:00:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:28 -0500
commit7f5fefb7bb65ef35916769988abbec8209889225 (patch)
tree1eb77e8ded2fc7e5cc1944ff5fe2eeaf8d71c72a
parent25f897053946eb9eeb56acb090ef691bf0e7edd4 (diff)
downloadsamba-7f5fefb7bb65ef35916769988abbec8209889225.tar.gz
samba-7f5fefb7bb65ef35916769988abbec8209889225.tar.bz2
samba-7f5fefb7bb65ef35916769988abbec8209889225.zip
r20165: Change messaging subsystem to only allow one message
per type - this is all we use right now and makes re-entrancy problems with deleting handlers with a message dispatch loop go away. Jeremy. (This used to be commit 2e9b6faeae1474d65a5c12f5a19b0ae045d47c2e)
-rw-r--r--source3/lib/messages.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 10fc5af24d..66bbebac27 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -458,8 +458,7 @@ static BOOL message_recv(char *msgs_buf, size_t total_len, int *msg_type,
/****************************************************************************
Receive and dispatch any messages pending for this process.
- Notice that all dispatch handlers for a particular msg_type get called,
- so you can register multiple handlers for a message.
+ JRA changed Dec 13 2006. Only one message handler now permitted per type.
*NOTE*: Dispatch functions must be able to cope with incoming
messages on an *odd* byte boundary.
****************************************************************************/
@@ -509,7 +508,8 @@ void message_dispatch(void)
}
/****************************************************************************
- Register a dispatch function for a particular message type.
+ Register/replace a dispatch function for a particular message type.
+ JRA changed Dec 13 2006. Only one message handler now permitted per type.
*NOTE*: Dispatch functions must be able to cope with incoming
messages on an *odd* byte boundary.
****************************************************************************/
@@ -520,6 +520,13 @@ void message_register(int msg_type,
{
struct dispatch_fns *dfn;
+ for (dfn = dispatch_fns; dfn; dfn = dfn->next) {
+ if (dfn->msg_type == msg_type) {
+ dfn->fn = fn;
+ return;
+ }
+ }
+
dfn = SMB_MALLOC_P(struct dispatch_fns);
if (dfn != NULL) {
@@ -550,6 +557,7 @@ void message_deregister(int msg_type)
if (dfn->msg_type == msg_type) {
DLIST_REMOVE(dispatch_fns, dfn);
SAFE_FREE(dfn);
+ return;
}
}
}