From: Michael Sweet Date: Wed, 11 May 2016 14:35:53 +0000 (-0400) Subject: Fix Hold-New-Jobs implementation (Issue #4767) X-Git-Tag: v2.2b1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0f489cd21441b7b45543a31ba6cbeb0bf85cd4f;p=thirdparty%2Fcups.git Fix Hold-New-Jobs implementation (Issue #4767) --- diff --git a/CHANGES-2.1.txt b/CHANGES-2.1.txt index 7da5150ff3..b06b100972 100644 --- a/CHANGES-2.1.txt +++ b/CHANGES-2.1.txt @@ -3,6 +3,8 @@ CHANGES-2.1.txt 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 cc6e70eabb..c0c2222f00 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1694,7 +1694,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... @@ -8888,6 +8905,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 784490e089..53af003198 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -227,6 +227,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); @@ -320,6 +321,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... */ @@ -357,7 +377,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;