]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix stuck multi-file jobs (Issue #5359, Issue #5413)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Nov 2018 16:33:00 +0000 (11:33 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Nov 2018 16:33:00 +0000 (11:33 -0500)
CHANGES.md
backend/socket.c
scheduler/main.c

index 472d9a331034271b7708d5dd2e5fe17005231afa..8d9a5561227e1584a6263b5565ce6dfe2a4309f7 100644 (file)
@@ -21,6 +21,8 @@ Changes in CUPS v2.3b6
 - The IPP Everywhere "driver" now properly supports face-up printers
   (Issue #5345)
 - Fixed some typos in the label printer drivers (Issue #5350)
+- Multi-file jobs could get stuck if the backend failed (Issue #5359,
+  Issue #5413)
 - The IPP Everywhere "driver" no longer does local filtering when printing to
   a shared CUPS printer (Issue #5361)
 - The lpadmin command now correctly reports IPP errors when configuring an
index 675061dd9a3fd8c50eb724284c0b0eea9fe00c6a..68379e95b7b47639561c5637205718813ff2e1bc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * AppSocket backend for CUPS.
  *
- * Copyright © 2007-2016 by Apple Inc.
+ * Copyright © 2007-2018 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
@@ -397,8 +397,10 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
       lseek(print_fd, 0, SEEK_SET);
     }
 
-    tbytes = backendRunLoop(print_fd, device_fd, snmp_fd, &(addrlist->addr), 1,
-                            0, backendNetworkSideCB);
+    if ((bytes = backendRunLoop(print_fd, device_fd, snmp_fd, &(addrlist->addr), 1, 0, backendNetworkSideCB)) < 0)
+      tbytes = -1;
+    else
+      tbytes = bytes;
 
     if (print_fd != 0 && tbytes >= 0)
       _cupsLangPrintFilter(stderr, "INFO", _("Print file sent."));
@@ -406,7 +408,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
   fputs("STATE: +cups-waiting-for-job-completed\n", stderr);
 
-  if (waiteof)
+  if (waiteof && tbytes >= 0)
   {
    /*
     * Shutdown the socket and wait for the other end to finish...
@@ -443,7 +445,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   if (print_fd != 0)
     close(print_fd);
 
-  return (CUPS_BACKEND_OK);
+  return (tbytes >= 0 ? CUPS_BACKEND_OK : CUPS_BACKEND_FAILED);
 }
 
 
index 4b3914ade50409b38a1cd40819cd08850cc98085..472b9946dd6ba9442567ba1a0cd984b1acd8756a 100644 (file)
@@ -1472,9 +1472,16 @@ process_children(void)
               (!job->filters[i] && WIFEXITED(old_status)))
           {                            /* Backend and filter didn't crash */
            if (job->filters[i])
+           {
              job->status = status;     /* Filter failed */
+           }
            else
+           {
              job->status = -status;    /* Backend failed */
+
+             if (job->current_file < job->num_files)
+               cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_FORCE, "Canceling multi-file job due to backend failure.");
+           }
           }
 
          if (job->state_value == IPP_JOB_PROCESSING &&