summaryrefslogtreecommitdiffstats
path: root/ctdb/common/ctdb_message.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-04-11 11:58:28 +1000
committerAndrew Tridgell <tridge@samba.org>2007-04-11 11:58:28 +1000
commitad1f17ab1c515cfb8ce892354b25fc9fc56e6440 (patch)
tree8a29bd3d58f53640d08f2a634f4f7d6369d04310 /ctdb/common/ctdb_message.c
parenta99a0470affcf3de46a20ad366e4b42298c1d430 (diff)
downloadsamba-ad1f17ab1c515cfb8ce892354b25fc9fc56e6440.tar.gz
samba-ad1f17ab1c515cfb8ce892354b25fc9fc56e6440.tar.xz
samba-ad1f17ab1c515cfb8ce892354b25fc9fc56e6440.zip
partially completed work towards full messaging system which will work in both daemon and standalone mode. Does not compile\! committing so ronnie can continue while I'm out
(This used to be ctdb commit 1b5e65a700e2bd0a5c913d7866024b25600a14c9)
Diffstat (limited to 'ctdb/common/ctdb_message.c')
-rw-r--r--ctdb/common/ctdb_message.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/ctdb/common/ctdb_message.c b/ctdb/common/ctdb_message.c
index ec39525942d..27c5c64bc0e 100644
--- a/ctdb/common/ctdb_message.c
+++ b/ctdb/common/ctdb_message.c
@@ -81,13 +81,35 @@ int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn,
}
/*
+ when a client goes away, we need to remove its srvid handler from the list
+ */
+static int message_handler_destructor(struct ctdb_message_list *m)
+{
+ DLIST_REMOVE(m->ctdb->message_list, m);
+}
+
+/*
setup handler for receipt of ctdb messages from ctdb_send_message()
*/
-int ctdb_set_message_handler(struct ctdb_context *ctdb, ctdb_message_fn_t handler,
- uint32_t srvid, void *private)
+int ctdb_register_message_handler(struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ uint32_t srvid,
+ ctdb_message_fn_t handler,
+ void *private)
{
- ctdb->message_handler = handler;
- ctdb->message_private = private;
+ struct ctdb_message_list *m;
+
+ m = talloc(mem_ctx, struct ctdb_message_list);
+ CTDB_NO_MEMORY(ctdb, m);
+
+ m->ctdb = ctdb;
+ m->srvid = srvid;
+ m->message_handler = handler;
+ m->message_private = private;
+
+ DLIST_ADD(ctdb->message_list, m);
+
+ talloc_set_destructor(m, message_handler_destructor);
+
return 0;
}
-