]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix Hold-New-Jobs implementation (Issue #4767)
authorMichael Sweet <michael.r.sweet@gmail.com>
Wed, 11 May 2016 14:35:53 +0000 (10:35 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Wed, 11 May 2016 14:35:53 +0000 (10:35 -0400)
CHANGES-2.1.txt
scheduler/ipp.c
scheduler/job.c

index 7da5150ff38b541eba94e964ee57a5084aa389e9..b06b10097230784e454162f8a68df3f821ba40c4 100644 (file)
@@ -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)
index cc6e70eabb8ffc312da9329af43ac3eec60e7211..c0c2222f003a57ba32b918edb69102ba08bbb983 100644 (file)
@@ -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...
   */
index 784490e089c934aa320a77c73cf37d2c4181e5d3..53af0031984a761b8cdfed1996444464aab88b4a 100644 (file)
@@ -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;