diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-09-13 07:07:17 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-09-13 07:07:17 +0000 |
commit | 5f91c24636f5d82486f22c10bc55e060f9c518bf (patch) | |
tree | f38a87f1f5608e49a5b74abcdc62b038a43bc875 /source/lib/messages.c | |
parent | a15e610bb34636448cb30e590277c53e7f9efe1a (diff) | |
download | samba-5f91c24636f5d82486f22c10bc55e060f9c518bf.tar.gz samba-5f91c24636f5d82486f22c10bc55e060f9c518bf.tar.xz samba-5f91c24636f5d82486f22c10bc55e060f9c518bf.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
Diffstat (limited to 'source/lib/messages.c')
-rw-r--r-- | source/lib/messages.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/lib/messages.c b/source/lib/messages.c index 939bf36004f..4153c21c23c 100644 --- a/source/lib/messages.c +++ b/source/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; +} |