summaryrefslogtreecommitdiffstats
path: root/source/lib/messages.c
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
commit2e9b6faeae1474d65a5c12f5a19b0ae045d47c2e (patch)
tree86468c28734c1b6f88eb9ff04466022a453255ca /source/lib/messages.c
parent27a4c1121404e346432d90b97b518861e038e9f2 (diff)
downloadsamba-2e9b6faeae1474d65a5c12f5a19b0ae045d47c2e.tar.gz
samba-2e9b6faeae1474d65a5c12f5a19b0ae045d47c2e.tar.xz
samba-2e9b6faeae1474d65a5c12f5a19b0ae045d47c2e.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.
Diffstat (limited to 'source/lib/messages.c')
-rw-r--r--source/lib/messages.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/lib/messages.c b/source/lib/messages.c
index 10fc5af24d3..66bbebac270 100644
--- a/source/lib/messages.c
+++ b/source/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;
}
}
}