summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/printing.c58
-rw-r--r--source3/rpc_parse/parse_spoolss.c2
-rw-r--r--source3/smbd/process.c13
-rw-r--r--source3/smbd/statcache.c2
4 files changed, 54 insertions, 21 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 1eb6c27555..0648715699 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -63,6 +63,8 @@ static pid_t local_pid;
#define PRINT_SPOOL_PREFIX "smbprn."
#define PRINT_DATABASE_VERSION 2
+static int get_queue_status(int, print_status_struct *);
+
/****************************************************************************
initialise the printing backend. Called once at startup.
Does not survive a fork
@@ -315,6 +317,7 @@ static void print_queue_update(int snum)
int numlines, i, qcount;
print_queue_struct *queue = NULL;
print_status_struct status;
+ print_status_struct old_status;
struct printjob *pjob;
struct traverse_struct tstruct;
fstring keystr, printer_name;
@@ -409,13 +412,26 @@ static void print_queue_update(int snum)
safe_free(tstruct.queue);
- /* store the queue status structure */
- status.qcount = qcount;
+ /*
+ * Get the old print status. We will use this to compare the
+ * number of jobs. If they have changed we need to send a
+ * "changed" message to the smbds.
+ */
+
+ if( qcount != get_queue_status(snum, &old_status)) {
+ DEBUG(10,("print_queue_update: queue status change %d jobs -> %d jobs for printer %s\n",
+ old_status.qcount, qcount, printer_name ));
+ message_send_all(MSG_PRINTER_NOTIFY, printer_name, strlen(printer_name) + 1, False);
+ }
+
+ /* store the new queue status structure */
slprintf(keystr, sizeof(keystr), "STATUS/%s", printer_name);
- data.dptr = (void *)&status;
- data.dsize = sizeof(status);
key.dptr = keystr;
key.dsize = strlen(keystr);
+
+ status.qcount = qcount;
+ data.dptr = (void *)&status;
+ data.dsize = sizeof(status);
tdb_store(tdb, key, data, TDB_REPLACE);
/* Unlock for database update */
@@ -713,31 +729,43 @@ static BOOL print_cache_expired(int snum)
}
/****************************************************************************
- Determine the number of jobs in a queue.
+ Get the queue status - do not update if db is out of date.
****************************************************************************/
-static int print_queue_length(int snum)
+static int get_queue_status(int snum, print_status_struct *status)
{
fstring keystr;
TDB_DATA data, key;
- print_status_struct status;
-
- /* make sure the database is up to date */
- if (print_cache_expired(snum)) print_queue_update(snum);
- /* also fetch the queue status */
- ZERO_STRUCTP(&status);
+ ZERO_STRUCTP(status);
slprintf(keystr, sizeof(keystr), "STATUS/%s", lp_servicename(snum));
key.dptr = keystr;
key.dsize = strlen(keystr);
data = tdb_fetch(tdb, key);
if (data.dptr) {
- if (data.dsize == sizeof(status)) {
- memcpy(&status, data.dptr, sizeof(status));
+ if (data.dsize == sizeof(print_status_struct)) {
+ memcpy(status, data.dptr, sizeof(print_status_struct));
}
free(data.dptr);
}
- return status.qcount;
+ return status->qcount;
+}
+
+/****************************************************************************
+ Determine the number of jobs in a queue.
+****************************************************************************/
+
+static int print_queue_length(int snum)
+{
+ fstring keystr;
+ TDB_DATA data, key;
+ print_status_struct status;
+
+ /* make sure the database is up to date */
+ if (print_cache_expired(snum)) print_queue_update(snum);
+
+ /* also fetch the queue status */
+ return get_queue_status(snum, &status);
}
/***************************************************************************
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 61206d4e70..fb6ce219e0 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -5922,7 +5922,7 @@ BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd,
********************************************************************/
BOOL spoolss_io_q_reply_rrpcn(char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth)
{
- prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter");
+ prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn");
depth++;
if(!prs_align(ps))
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index dc56534edb..ea0309599f 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -131,9 +131,6 @@ static void async_processing(fd_set *fds, char *buffer, int buffer_len)
reload_services(False);
reload_after_sighup = False;
}
-
- /* check for any pending internal messages */
- message_dispatch();
}
/****************************************************************************
@@ -166,6 +163,15 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout)
smb_read_error = 0;
+ again:
+
+ /*
+ * Note that this call must be before processing any SMB
+ * messages as we need to synchronously process any messages
+ * we may have sent to ourselves from the previous SMB.
+ */
+ message_dispatch();
+
/*
* Check to see if we already have a message on the smb queue.
* If so - copy and return it.
@@ -187,7 +193,6 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout)
* Setup the select read fd set.
*/
- again:
FD_ZERO(&fds);
FD_SET(smbd_server_fd(),&fds);
maxfd = setup_oplock_select_set(&fds);
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 8200c277b3..4c885f34f1 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -218,7 +218,7 @@ BOOL stat_cache_lookup(connection_struct *conn, char *name, char *dirpath,
*/
BOOL reset_stat_cache( void )
{
- static BOOL initialised;
+ static BOOL initialised = False;
if (!lp_stat_cache()) return True;
if (!initialised) {