diff options
author | Martin Pool <mbp@samba.org> | 2001-12-21 00:37:49 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2001-12-21 00:37:49 +0000 |
commit | bf65820af242786bd66d814fc3e9d89920a49f8e (patch) | |
tree | 59f7ab18083677a7857c37befb2e09b8316da1b2 /source3 | |
parent | df28dee653ea2f685c7779fed80fe639784699f5 (diff) | |
download | samba-bf65820af242786bd66d814fc3e9d89920a49f8e.tar.gz samba-bf65820af242786bd66d814fc3e9d89920a49f8e.tar.bz2 samba-bf65820af242786bd66d814fc3e9d89920a49f8e.zip |
Add an output parameter to message_send_all that says how many
messages were sent, so you know how many replies to expect.
Const and doc religion.
(This used to be commit 22e510ea0d69356be4fd2fa5ad9e9f4e84f62337)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/messages.c | 45 | ||||
-rw-r--r-- | source3/nmbd/nmbd_processlogon.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_netlog_nt.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc_nt.c | 9 | ||||
-rw-r--r-- | source3/smbd/lanman.c | 2 |
6 files changed, 43 insertions, 19 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index f63e2c4766..923005de71 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -3,6 +3,7 @@ Version 3.0 Samba internal messaging functions Copyright (C) Andrew Tridgell 2000 + Copyright (C) 2001 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +21,8 @@ */ /** + @defgroups messages Internal messaging framework + @{ @file messages.c This module is used for internal messaging between Samba daemons. @@ -158,7 +161,8 @@ static BOOL message_notify(pid_t pid) Send a message to a particular pid. ****************************************************************************/ -BOOL message_send_pid(pid_t pid, int msg_type, void *buf, size_t len, BOOL duplicates_allowed) +BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len, + BOOL duplicates_allowed) { TDB_DATA kbuf; TDB_DATA dbuf; @@ -205,7 +209,7 @@ BOOL message_send_pid(pid_t pid, int msg_type, void *buf, size_t len, BOOL dupli */ if (!memcmp(ptr, &rec, sizeof(rec))) { - if (!len || (len && !memcmp( ptr + sizeof(rec), (char *)buf, len))) { + if (!len || (len && !memcmp( ptr + sizeof(rec), buf, len))) { DEBUG(10,("message_send_pid: discarding duplicate message.\n")); SAFE_FREE(dbuf.dptr); tdb_chainunlock(tdb, kbuf); @@ -373,9 +377,10 @@ void message_deregister(int msg_type) struct msg_all { int msg_type; - void *buf; + const void *buf; size_t len; BOOL duplicates; + int n_sent; }; /**************************************************************************** @@ -397,8 +402,9 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void /* if the msg send fails because the pid was not found (i.e. smbd died), * the msg has already been deleted from the messages.tdb.*/ - if (!message_send_pid(crec.pid, msg_all->msg_type, msg_all->buf, msg_all->len, - msg_all->duplicates)) { + if (!message_send_pid(crec.pid, msg_all->msg_type, + msg_all->buf, msg_all->len, + msg_all->duplicates)) { /* if the pid was not found delete the entry from connections.tdb */ if (errno == ESRCH) { @@ -407,16 +413,26 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void tdb_delete(the_tdb, kbuf); } } + msg_all->n_sent++; 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(TDB_CONTEXT *conn_tdb, int msg_type, void *buf, size_t len, BOOL duplicates_allowed) +/** + * Send a message 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. + * + * @param n_sent Set to the number of messages sent. This should be + * equal to the number of processes, but be careful for races. + * + * @return True for success. + **/ +BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, + const void *buf, size_t len, + BOOL duplicates_allowed, + int *n_sent) { struct msg_all msg_all; @@ -424,7 +440,12 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, void *buf, size_t len msg_all.buf = buf; msg_all.len = len; msg_all.duplicates = duplicates_allowed; + msg_all.n_sent = 0; tdb_traverse(conn_tdb, traverse_fn, &msg_all); + if (n_sent) + *n_sent = msg_all.n_sent; return True; } + +/** @} **/ diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index bcd1e1a1ff..b348250f86 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -55,7 +55,7 @@ static void send_repl_message(uint32 low_serial) low_serial)); message_send_all(tdb, MSG_SMB_SAM_REPL, &low_serial, - sizeof(low_serial), False); + sizeof(low_serial), False, NULL); tdb_close(tdb); } diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8092488652..634e2540fa 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -91,7 +91,7 @@ static void send_sync_message(void) DEBUG(3, ("sending sam synchronisation message\n")); - message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False); + message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False, NULL); tdb_close(tdb); } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5794f1de04..3fe21eb968 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -690,7 +690,7 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) /*srv_spoolss_receive_message(printer);*/ DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); - message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */ + broadcast_printer_notify(printer); return True; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9fadba17dd..06cbbaa2dc 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1329,7 +1329,8 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, + 0, False, NULL); } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); @@ -1451,7 +1452,8 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, + NULL); /* * We don't call reload_services() here, the message will @@ -1514,7 +1516,8 @@ NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET delete_share_security(snum); /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, + NULL); lp_killservice(snum); diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 34dcf6c211..64da736ae2 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -1724,7 +1724,7 @@ static BOOL api_RNetShareAdd(connection_struct *conn,uint16 vuid, char *param,ch goto error_exit; } else { SAFE_FREE(command); - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } } else return False; |