summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/printing/printing.c27
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c11
2 files changed, 20 insertions, 18 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index acdaed46ae..4f50b402c1 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -804,7 +804,9 @@ static BOOL print_cache_expired(int snum)
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
t2 = tdb_fetch_int(tdb, key);
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
- DEBUG(3, ("print cache expired\n"));
+ DEBUG(3, ("print cache expired for queue %s \
+(last_cache = %d, time now = %d, qcachetime = %d)\n", lp_servicename(snum),
+ (int)t2, (int)t, (int)lp_lpqcachetime() ));
return True;
}
return False;
@@ -835,15 +837,21 @@ static int get_queue_status(int snum, print_status_struct *status)
/****************************************************************************
Determine the number of jobs in a queue.
****************************************************************************/
-static int print_queue_length(int snum)
+
+int print_queue_length(int snum, print_status_struct *pstatus)
{
print_status_struct status;
-
+ int len;
+
/* make sure the database is up to date */
- if (print_cache_expired(snum)) print_queue_update(snum);
-
+ if (print_cache_expired(snum))
+ print_queue_update(snum);
+
/* also fetch the queue status */
- return get_queue_status(snum, &status);
+ len = get_queue_status(snum, &status);
+ if (pstatus)
+ *pstatus = status;
+ return len;
}
/****************************************************************************
@@ -873,6 +881,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
struct printjob pjob;
int next_jobid;
user_struct *vuser;
+ int njobs;
errno = 0;
@@ -907,9 +916,9 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
}
/* Insure the maximum queue size is not violated */
- if (lp_maxprintjobs(snum) && print_queue_length(snum) > lp_maxprintjobs(snum)) {
+ if (lp_maxprintjobs(snum) && (njobs = print_queue_length(snum,NULL)) > lp_maxprintjobs(snum)) {
DEBUG(3, ("print_job_start: number of jobs (%d) larger than max printjobs per queue (%d).\n",
- print_queue_length(snum), lp_maxprintjobs(snum) ));
+ njobs, lp_maxprintjobs(snum) ));
errno = ENOSPC;
return -1;
}
@@ -917,7 +926,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
/* Insure the maximum print jobs in the system is not violated */
if (lp_totalprintjobs() && get_total_jobs(snum) > lp_totalprintjobs()) {
DEBUG(3, ("print_job_start: number of jobs (%d) larger than max printjobs per system (%d).\n",
- print_queue_length(snum), lp_totalprintjobs() ));
+ njobs, lp_totalprintjobs() ));
errno = ENOSPC;
return -1;
}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 1d54c92bce..d49cee0d25 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1835,14 +1835,12 @@ static void spoolss_notify_status(int snum,
NT_PRINTER_INFO_LEVEL *printer,
TALLOC_CTX *mem_ctx)
{
- print_queue_struct *q=NULL;
print_status_struct status;
memset(&status, 0, sizeof(status));
- print_queue_status(snum, &q, &status);
+ print_queue_length(snum, &status);
data->notify_data.value[0]=(uint32) status.status;
data->notify_data.value[1] = 0;
- SAFE_FREE(q);
}
/*******************************************************************
@@ -1854,13 +1852,8 @@ static void spoolss_notify_cjobs(int snum,
NT_PRINTER_INFO_LEVEL *printer,
TALLOC_CTX *mem_ctx)
{
- print_queue_struct *q=NULL;
- print_status_struct status;
-
- memset(&status, 0, sizeof(status));
- data->notify_data.value[0] = print_queue_status(snum, &q, &status);
+ data->notify_data.value[0] = print_queue_length(snum, NULL);
data->notify_data.value[1] = 0;
- SAFE_FREE(q);
}
/*******************************************************************