From a0e852690339e88f4810ee8b660b73c6c2311e0f Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Wed, 11 May 2016 10:39:23 -0400 Subject: [PATCH] Mirror fix from master. --- CHANGES.txt | 4 +++- scheduler/ipp.c | 21 ++++++++++++++++++++- scheduler/job.c | 22 +++++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d5c883df8d..5c21e4fd66 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,10 @@ -CHANGES.txt - 2.1.4 - 2016-03-24 +CHANGES.txt - 2.1.4 - 2016-05-11 -------------------------------- CHANGES IN CUPS V2.1.4 + - The scheduler did not implement the Hold-New-Jobs opertion correctly + (Issue #4767) - The ipptool program truncated values at 8k (Issue #4786) - The ipptool program did not correctly report uriScheme values in plist output (Issue #4785) diff --git a/scheduler/ipp.c b/scheduler/ipp.c index b7c65fda33..06a236b94b 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1692,7 +1692,24 @@ add_job(cupsd_client_t *con, /* I - Client connection */ attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until", NULL, val); } - if (attr && strcmp(attr->values[0].string.text, "no-hold")) + + if (printer->holding_new_jobs) + { + /* + * Hold all new jobs on this printer... + */ + + if (attr && strcmp(attr->values[0].string.text, "no-hold")) + cupsdSetJobHoldUntil(job, ippGetString(attr, 0, NULL), 0); + else + cupsdSetJobHoldUntil(job, "indefinite", 0); + + job->state->values[0].integer = IPP_JOB_HELD; + job->state_value = IPP_JOB_HELD; + + ippSetString(job->attrs, &job->reasons, 0, "job-held-on-create"); + } + else if (attr && strcmp(attr->values[0].string.text, "no-hold")) { /* * Hold job until specified time... @@ -8668,6 +8685,8 @@ release_held_new_jobs( "Printer \"%s\" now printing pending/new jobs (\"%s\").", printer->name, get_username(con)); + cupsdCheckJobs(); + /* * Everything was ok, so return OK status... */ diff --git a/scheduler/job.c b/scheduler/job.c index 0fb0362a06..4738258d39 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -229,6 +229,7 @@ cupsdCheckJobs(void) *pclass; /* Printer class destination */ ipp_attribute_t *attr; /* Job attribute */ time_t curtime; /* Current time */ + const char *reasons; /* job-state-reasons value */ curtime = time(NULL); @@ -322,6 +323,25 @@ cupsdCheckJobs(void) ((FilterLevel + job->pending_cost) < FilterLimit || FilterLevel == 0)) cupsdContinueJob(job); + /* + * Skip jobs that where held-on-create + */ + + reasons = ippGetString(job->reasons, 0, NULL); + if (reasons && !strcmp(reasons, "job-held-on-create")) + { + /* + * Check whether the printer is still holding new jobs... + */ + + printer = cupsdFindDest(job->dest); + + if (printer->holding_new_jobs) + continue; + + ippSetString(job->attrs, &job->reasons, 0, "none"); + } + /* * Start pending jobs if the destination is available... */ @@ -359,7 +379,7 @@ cupsdCheckJobs(void) "Job aborted because the destination printer/class " "has gone away."); } - else if (printer && !printer->holding_new_jobs) + else if (printer) { /* * See if the printer is available or remote and not printing a job; -- 2.47.2