summaryrefslogtreecommitdiff
path: root/source3/lib/messages.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-09-13 07:07:17 +0000
committerAndrew Tridgell <tridge@samba.org>2000-09-13 07:07:17 +0000
commit7be9a4fd4c044fa98c434bbdbf0f8229f1101bbb (patch)
tree4fb2514564d1ba64a5e4f358e066e8dbdc2a24cd /source3/lib/messages.c
parenta5ac83d2b2fe84d5e940d94269ae6fb61167a809 (diff)
downloadsamba-7be9a4fd4c044fa98c434bbdbf0f8229f1101bbb.tar.gz
samba-7be9a4fd4c044fa98c434bbdbf0f8229f1101bbb.tar.bz2
samba-7be9a4fd4c044fa98c434bbdbf0f8229f1101bbb.zip
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)
Diffstat (limited to 'source3/lib/messages.c')
-rw-r--r--source3/lib/messages.c43
1 files changed, 43 insertions, 0 deletions
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;
+}