struct traverse_struct {
print_queue_struct *queue;
int qcount, snum, maxcount, total_jobs;
+ time_t lpq_time;
};
/****************************************************************************
completed, so delete the database entry. */
if (i == ts->qcount) {
- time_t cur_t = time(NULL);
/* A race can occur between the time a job is spooled and
when it appears in the lpq output. This happens when
the job is added to printing.tdb when another smbd
running print_queue_update() has completed a lpq and
is currently traversing the printing tdb and deleting jobs.
- A workaround is to not delete the job if it has been
- submitted less than lp_lpqcachetime() seconds ago. */
+ Don't delete the job if it was submitted after the lpq_time. */
- if ((cur_t - pjob.starttime) > lp_lpqcachetime())
+ if (pjob.starttime < ts->lpq_time)
pjob_delete(ts->snum, jobid);
else
ts->total_jobs++;
tstruct.qcount = qcount;
tstruct.snum = snum;
tstruct.total_jobs = 0;
+ tstruct.lpq_time = time(NULL);
tdb_traverse(pdb->tdb, traverse_fn_delete, (void *)&tstruct);