summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/connection.c71
-rw-r--r--source3/smbd/process.c10
2 files changed, 65 insertions, 16 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index bc897a95cb..ad394a01ca 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -35,6 +35,17 @@ TDB_CONTEXT *conn_tdb_ctx(void)
return tdb;
}
+static void make_conn_key(connection_struct *conn,char *name, TDB_DATA *pkbuf, struct connections_key *pkey)
+{
+ ZERO_STRUCTP(pkey);
+ pkey->pid = sys_getpid();
+ pkey->cnum = conn?conn->cnum:-1;
+ fstrcpy(pkey->name, name);
+
+ pkbuf->dptr = (char *)pkey;
+ pkbuf->dsize = sizeof(*pkey);
+}
+
/****************************************************************************
Delete a connection record.
****************************************************************************/
@@ -49,13 +60,7 @@ BOOL yield_connection(connection_struct *conn,char *name)
DEBUG(3,("Yielding connection to %s\n",name));
- ZERO_STRUCT(key);
- key.pid = sys_getpid();
- key.cnum = conn?conn->cnum:-1;
- fstrcpy(key.name, name);
-
- kbuf.dptr = (char *)&key;
- kbuf.dsize = sizeof(key);
+ make_conn_key(conn, name, &kbuf, &key);
if (tdb_delete(tdb, kbuf) != 0) {
int dbg_lvl = (!conn && (tdb_error(tdb) == TDB_ERR_NOEXIST)) ? 3 : 0;
@@ -88,7 +93,7 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u
memcpy(&crec, dbuf.dptr, sizeof(crec));
- if (crec.cnum == -1)
+ if (crec.cnum == -1)
return 0;
/* If the pid was not found delete the entry from connections.tdb */
@@ -156,13 +161,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
DEBUG(5,("claiming %s %d\n",name,max_connections));
- ZERO_STRUCT(key);
- key.pid = sys_getpid();
- key.cnum = conn?conn->cnum:-1;
- fstrcpy(key.name, name);
-
- kbuf.dptr = (char *)&key;
- kbuf.dsize = sizeof(key);
+ make_conn_key(conn, name, &kbuf, &key);
/* fill in the crec */
ZERO_STRUCT(crec);
@@ -192,3 +191,45 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
return True;
}
+
+BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
+{
+ struct connections_key key;
+ struct connections_data *pcrec;
+ TDB_DATA kbuf, dbuf;
+
+ if (!tdb)
+ return False;
+
+ DEBUG(10,("register_message_flags: %s flags 0x%x\n",
+ doreg ? "adding" : "removing",
+ (unsigned int)msg_flags ));
+
+ make_conn_key(NULL, "", &kbuf, &key);
+
+ dbuf = tdb_fetch(tdb, kbuf);
+ if (!dbuf.dptr) {
+ DEBUG(0,("register_message_flags: tdb_fetch failed\n"));
+ return False;
+ }
+
+ pcrec = (struct connections_data *)dbuf.dptr;
+ pcrec->bcast_msg_flags = msg_flags;
+ if (doreg)
+ pcrec->bcast_msg_flags |= msg_flags;
+ else
+ pcrec->bcast_msg_flags &= ~msg_flags;
+
+ if (tdb_store(tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
+ DEBUG(0,("register_message_flags: tdb_store failed with error %s.\n",
+ tdb_errorstr(tdb) ));
+ SAFE_FREE(dbuf.dptr);
+ return False;
+ }
+
+ DEBUG(10,("register_message_flags: new flags 0x%x\n",
+ (unsigned int)pcrec->bcast_msg_flags ));
+
+ SAFE_FREE(dbuf.dptr);
+ return True;
+}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 2c35eadb18..c796797fad 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1030,7 +1030,11 @@ static int setup_select_timeout(void)
select_timeout *= 1000;
t = change_notify_timeout();
- if (t != -1) select_timeout = MIN(select_timeout, t*1000);
+ if (t != -1)
+ select_timeout = MIN(select_timeout, t*1000);
+
+ if (print_notify_messages_pending())
+ select_timeout = MIN(select_timeout, 1000);
return select_timeout;
}
@@ -1190,6 +1194,10 @@ machine %s in domain %s.\n", global_myname, global_myworkgroup ));
force_check_log_size();
check_log_size();
+ /* Send any queued printer notify message to interested smbd's. */
+
+ print_notify_send_messages();
+
/*
* Modify the select timeout depending upon
* what we have remaining in our queues.