mirror of
https://github.com/samba-team/samba.git
synced 2025-02-08 05:57:51 +03:00
Improved efficiency of enumerating print queue's under a particular
extreme condition... Jeremy. (This used to be commit 425bb0f40526b4eb17a3033892ca907b1d5293a4)
This commit is contained in:
parent
38d10d2ac1
commit
5472638730
@ -804,7 +804,9 @@ static BOOL print_cache_expired(int snum)
|
|||||||
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
|
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
|
||||||
t2 = tdb_fetch_int(tdb, key);
|
t2 = tdb_fetch_int(tdb, key);
|
||||||
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
|
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 True;
|
||||||
}
|
}
|
||||||
return False;
|
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.
|
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;
|
print_status_struct status;
|
||||||
|
int len;
|
||||||
|
|
||||||
/* make sure the database is up to date */
|
/* 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 */
|
/* 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;
|
struct printjob pjob;
|
||||||
int next_jobid;
|
int next_jobid;
|
||||||
user_struct *vuser;
|
user_struct *vuser;
|
||||||
|
int njobs;
|
||||||
|
|
||||||
errno = 0;
|
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 */
|
/* 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",
|
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;
|
errno = ENOSPC;
|
||||||
return -1;
|
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 */
|
/* Insure the maximum print jobs in the system is not violated */
|
||||||
if (lp_totalprintjobs() && get_total_jobs(snum) > lp_totalprintjobs()) {
|
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",
|
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;
|
errno = ENOSPC;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1835,14 +1835,12 @@ static void spoolss_notify_status(int snum,
|
|||||||
NT_PRINTER_INFO_LEVEL *printer,
|
NT_PRINTER_INFO_LEVEL *printer,
|
||||||
TALLOC_CTX *mem_ctx)
|
TALLOC_CTX *mem_ctx)
|
||||||
{
|
{
|
||||||
print_queue_struct *q=NULL;
|
|
||||||
print_status_struct status;
|
print_status_struct status;
|
||||||
|
|
||||||
memset(&status, 0, sizeof(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[0]=(uint32) status.status;
|
||||||
data->notify_data.value[1] = 0;
|
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,
|
NT_PRINTER_INFO_LEVEL *printer,
|
||||||
TALLOC_CTX *mem_ctx)
|
TALLOC_CTX *mem_ctx)
|
||||||
{
|
{
|
||||||
print_queue_struct *q=NULL;
|
data->notify_data.value[0] = print_queue_length(snum, 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[1] = 0;
|
data->notify_data.value[1] = 0;
|
||||||
SAFE_FREE(q);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user