summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-12-05 00:54:33 +0000
committerJeremy Allison <jra@samba.org>2001-12-05 00:54:33 +0000
commit547263873017bd7e042f8826b68a3136c4e3b2f8 (patch)
tree34536c96e7bb46bba14410f62132a92dd7e34463 /source3/printing
parent38d10d2ac1e23681c025af8b37db037cd5d6b940 (diff)
downloadsamba-547263873017bd7e042f8826b68a3136c4e3b2f8.tar.gz
samba-547263873017bd7e042f8826b68a3136c4e3b2f8.tar.bz2
samba-547263873017bd7e042f8826b68a3136c4e3b2f8.zip
Improved efficiency of enumerating print queue's under a particular
extreme condition... Jeremy. (This used to be commit 425bb0f40526b4eb17a3033892ca907b1d5293a4)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/printing.c27
1 files changed, 18 insertions, 9 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;
}