Skip to content

Commit

Permalink
Fix an issue with and time values (Issue #5538)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Mar 11, 2019
1 parent 488ec10 commit ba9d68c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES - 2.2.11 - 2019-02-27
CHANGES - 2.2.11 - 2019-03-11
=============================


Expand Down Expand Up @@ -30,6 +30,7 @@ Changes in CUPS v2.2.11
- Fixed compiler warnings with newer versions of GCC (Issue #5532, Issue #5533)
- Fixed some PPD caching and IPP Everywhere PPD accounting/password bugs
(Issue #5535)
- Fixed `PreserveJobHistory` bug with time values (Issue #5538)
- Media size matching now uses a tolerance of 0.5mm (rdar://33822024)
- The lpadmin command would hang with a bad PPD file (rdar://41495016)
- Fixed a potential crash bug in cups-driverd (rdar://46625579)
Expand Down
36 changes: 18 additions & 18 deletions scheduler/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,20 @@ cupsdCleanJobs(void)
curtime = time(NULL);
JobHistoryUpdate = 0;

cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCleanJobs: curtime=%d", (int)curtime);

for (job = (cupsd_job_t *)cupsArrayFirst(Jobs);
job;
job = (cupsd_job_t *)cupsArrayNext(Jobs))
{
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCleanJobs: Job %d, state=%d, printer=%p, history_time=%d, file_time=%d", job->id, (int)job->state_value, (void *)job->printer, (int)job->history_time, (int)job->file_time);

if ((job->history_time && job->history_time) < JobHistoryUpdate || !JobHistoryUpdate)
JobHistoryUpdate = job->history_time;

if ((job->file_time && job->file_time < JobHistoryUpdate) || !JobHistoryUpdate)
JobHistoryUpdate = job->file_time;

if (job->state_value >= IPP_JOB_CANCELED && !job->printer)
{
/*
Expand All @@ -456,21 +466,9 @@ cupsdCleanJobs(void)
else if (job->file_time && job->file_time <= curtime)
{
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Removing document files.");
cupsdLogJob(job, CUPSD_LOG_DEBUG2, "curtime=%ld, job->file_time=%ld", (long)curtime, (long)job->file_time);
remove_job_files(job);

cupsdMarkDirty(CUPSD_DIRTY_JOBS);

if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate)
JobHistoryUpdate = job->history_time;
}
else
{
if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate)
JobHistoryUpdate = job->history_time;

if (job->file_time < JobHistoryUpdate || !JobHistoryUpdate)
JobHistoryUpdate = job->file_time;
}
}
}
Expand Down Expand Up @@ -1729,7 +1727,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */
job->completed_time = attr->values[0].integer;

if (JobHistory < INT_MAX)
job->history_time = attr->values[0].integer + JobHistory;
job->history_time = job->completed_time + JobHistory;
else
job->history_time = INT_MAX;

Expand All @@ -1740,7 +1738,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */
JobHistoryUpdate = job->history_time;

if (JobFiles < INT_MAX)
job->file_time = attr->values[0].integer + JobFiles;
job->file_time = job->completed_time + JobFiles;
else
job->file_time = INT_MAX;

Expand Down Expand Up @@ -2862,8 +2860,10 @@ cupsdUpdateJobs(void)
* Update history/file expiration times...
*/

job->completed_time = attr->values[0].integer;

if (JobHistory < INT_MAX)
job->history_time = attr->values[0].integer + JobHistory;
job->history_time = job->completed_time + JobHistory;
else
job->history_time = INT_MAX;

Expand All @@ -2877,7 +2877,7 @@ cupsdUpdateJobs(void)
JobHistoryUpdate = job->history_time;

if (JobFiles < INT_MAX)
job->file_time = attr->values[0].integer + JobFiles;
job->file_time = job->completed_time + JobFiles;
else
job->file_time = INT_MAX;

Expand Down Expand Up @@ -4698,15 +4698,15 @@ set_time(cupsd_job_t *job, /* I - Job to update */
job->completed_time = curtime;

if (JobHistory < INT_MAX && attr)
job->history_time = attr->values[0].integer + JobHistory;
job->history_time = job->completed_time + JobHistory;
else
job->history_time = INT_MAX;

if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate)
JobHistoryUpdate = job->history_time;

if (JobFiles < INT_MAX && attr)
job->file_time = curtime + JobFiles;
job->file_time = job->completed_time + JobFiles;
else
job->file_time = INT_MAX;

Expand Down
2 changes: 1 addition & 1 deletion test/run-stp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ fi

# Requests logged
count=`wc -l $BASE/log/access_log | awk '{print $1}'`
expected=`expr 35 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
expected=`expr 35 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4 + 2`
if test $count != $expected; then
echo "FAIL: $count requests logged, expected $expected."
echo " <p>FAIL: $count requests logged, expected $expected.</p>" >>$strfile
Expand Down

0 comments on commit ba9d68c

Please sign in to comment.