From 7be9a4fd4c044fa98c434bbdbf0f8229f1101bbb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2000 07:07:17 +0000 Subject: first cut at smbcontrol program. It currently allows syntax like: smbcontrol nmbd debug 7 smbcontrol smbd debug 9 smbcontrol 3278 debug 1 smbcontrol nmbd force-election (This used to be commit 5f91c24636f5d82486f22c10bc55e060f9c518bf) --- source3/lib/messages.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source3/lib/messages.c') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 939bf36004..4153c21c23 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -304,3 +304,46 @@ void message_deregister(int msg_type) } } } + +static struct { + int msg_type; + void *buf; + size_t len; +} msg_all; + +/**************************************************************************** +send one of the messages for the broadcast +****************************************************************************/ +static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state) +{ + struct connections_data crec; + + memcpy(&crec, dbuf.dptr, sizeof(crec)); + + message_send_pid(crec.pid, msg_all.msg_type, msg_all.buf, msg_all.len); + return 0; +} + +/**************************************************************************** +this is a useful function for sending messages to all smbd processes. +It isn't very efficient, but should be OK for the sorts of applications that +use it. When we need efficient broadcast we can add it. +****************************************************************************/ +BOOL message_send_all(int msg_type, void *buf, size_t len) +{ + TDB_CONTEXT *tdb; + + tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); + if (!tdb) { + DEBUG(2,("Failed to open connections database in message_send_all\n")); + return False; + } + + msg_all.msg_type = msg_type; + msg_all.buf = buf; + msg_all.len = len; + + tdb_traverse(tdb, traverse_fn, NULL); + tdb_close(tdb); + return True; +} -- cgit