summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-12-14 01:00:16 +0000
committerJeremy Allison <jra@samba.org>2006-12-14 01:00:16 +0000
commiteb1d7b541d9330707bed6cc5a35f7ee4f13e65f0 (patch)
tree39d3f55fa076c79f62a2eda3db54c5f39adf4d1f
parent09a0068b0c7f43c814c31ea4992a45a001b326c6 (diff)
downloadsamba-eb1d7b541d9330707bed6cc5a35f7ee4f13e65f0.tar.gz
samba-eb1d7b541d9330707bed6cc5a35f7ee4f13e65f0.tar.xz
samba-eb1d7b541d9330707bed6cc5a35f7ee4f13e65f0.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.
-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;
}
}
}