summaryrefslogtreecommitdiff
path: root/source3/lib/messages.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/messages.c')
-rw-r--r--source3/lib/messages.c94
1 files changed, 22 insertions, 72 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index e6d2de4a58..d9886a54da 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -382,10 +382,11 @@ void message_deregister(int msg_type)
struct msg_all {
int msg_type;
+ uint32 msg_flag;
const void *buf;
size_t len;
BOOL duplicates;
- int n_sent;
+ int n_sent;
};
/****************************************************************************
@@ -405,13 +406,20 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void
if (crec.cnum != -1)
return 0;
- /* if the msg send fails because the pid was not found (i.e. smbd died),
+ /* Don't send if the receiver hasn't registered an interest. */
+
+ if(!(crec.bcast_msg_flags & msg_all->msg_flag))
+ return 0;
+
+ /* 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 the pid was not found delete the entry from connections.tdb */
+ /* If the pid was not found delete the entry from connections.tdb */
+
if (errno == ESRCH) {
DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n",
(unsigned int)crec.pid, crec.cnum, crec.name));
@@ -442,6 +450,17 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type,
struct msg_all msg_all;
msg_all.msg_type = msg_type;
+ if (msg_type < 1000)
+ msg_all.msg_flag = FLAG_MSG_GENERAL;
+ else if (msg_type > 1000 && msg_type < 2000)
+ msg_all.msg_flag = FLAG_MSG_NMBD;
+ else if (msg_type > 2000 && msg_type < 3000)
+ msg_all.msg_flag = FLAG_MSG_PRINTING;
+ else if (msg_type > 3000 && msg_type < 4000)
+ msg_all.msg_flag = FLAG_MSG_SMBD;
+ else
+ return False;
+
msg_all.buf = buf;
msg_all.len = len;
msg_all.duplicates = duplicates_allowed;
@@ -452,73 +471,4 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type,
*n_sent = msg_all.n_sent;
return True;
}
-
-static SIG_ATOMIC_T gotalarm;
-
-/***************************************************************
- Signal function to tell us we timed out.
-****************************************************************/
-
-static void gotalarm_sig(void)
-{
- gotalarm = 1;
-}
-
-/**
- * Lock the messaging tdb based on a string - this is used as a primitive
- * form of mutex between smbd instances.
- *
- * @param name A string identifying the name of the mutex.
- */
-
-BOOL message_named_mutex(char *name, unsigned int timeout)
-{
- TDB_DATA key;
- int ret;
- void (*oldsig_handler)(int) = NULL;
-
- if (!message_init())
- return False;
-
- key.dptr = name;
- key.dsize = strlen(name)+1;
-
- if (timeout) {
- gotalarm = 0;
- oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
- alarm(timeout);
- }
-
- ret = tdb_chainlock(tdb, key);
-
- if (timeout) {
- alarm(0);
- CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);
- if (gotalarm)
- return False;
- }
-
- if (ret == 0)
- DEBUG(10,("message_named_mutex: got mutex for %s\n", name ));
-
- return (ret == 0);
-}
-
-/**
- * Unlock a named mutex.
- *
- * @param name A string identifying the name of the mutex.
- */
-
-void message_named_mutex_release(char *name)
-{
- TDB_DATA key;
-
- key.dptr = name;
- key.dsize = strlen(name)+1;
-
- tdb_chainunlock(tdb, key);
- DEBUG(10,("message_named_mutex: released mutex for %s\n", name ));
-}
-
/** @} **/