summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-04-12 15:52:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:04 -0500
commit4f972f5c3363863d24cc07a348993d9ed8a9c830 (patch)
treead72359dcb80771ad91bf52d7182e46c915021d2
parentaaddd93e46d127f054dc843d9247981f181b77ab (diff)
downloadsamba-4f972f5c3363863d24cc07a348993d9ed8a9c830.tar.gz
samba-4f972f5c3363863d24cc07a348993d9ed8a9c830.tar.bz2
samba-4f972f5c3363863d24cc07a348993d9ed8a9c830.zip
r15055: this was my version for the crash bug in the messaging code...
it also makes the function a bit shorter and clearer, as the tmp msg_types only have one handler and not a list metze (This used to be commit 7e709fd04dc4fb083bd8b01b3f0fa88b932aa9b7)
-rw-r--r--source4/lib/messaging/messaging.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index c02a79ab8d..62170b64f3 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -299,8 +299,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private,
msg->num_types = msg_type+1;
}
-
- d = talloc(msg->dispatch, struct dispatch_fn);
+ d = talloc_zero(msg->dispatch, struct dispatch_fn);
NT_STATUS_HAVE_NO_MEMORY(d);
d->msg_type = msg_type;
d->private = private;
@@ -343,37 +342,25 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private,
*/
void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private)
{
- struct dispatch_fn *d, *list, *next;
+ struct dispatch_fn *d, *next;
if (msg_type >= msg->num_types) {
- list = idr_find(msg->dispatch_tree, msg_type);
- } else {
- list = msg->dispatch[msg_type];
- }
-
- if (list == NULL) {
+ d = idr_find(msg->dispatch_tree, msg_type);
+ if (!d) return;
+ idr_remove(msg->dispatch_tree, msg_type);
+ talloc_free(d);
return;
}
- for (d = list; d; d = next) {
+ for (d = msg->dispatch[msg_type]; d; d = next) {
next = d->next;
if (d->private == private) {
- DLIST_REMOVE(list, d);
+ DLIST_REMOVE(msg->dispatch[msg_type], d);
talloc_free(d);
}
- }
-
- /* the list base possibly changed */
- if (msg_type >= msg->num_types) {
- if (list == NULL) {
- idr_remove(msg->dispatch_tree, msg_type);
- }
- } else {
- msg->dispatch[msg_type] = list;
}
}
-
/*
Send a message to a particular server
*/