Index: cups/util.c =================================================================== --- cups/util.c (revision 8924) +++ cups/util.c (working copy) @@ -1456,6 +1456,9 @@ char buffer[8192]; /* Copy buffer */ ssize_t bytes; /* Bytes in buffer */ http_status_t status; /* Status of write */ + _cups_globals_t *cg = _cupsGlobals(); /* Global data */ + ipp_status_t cancel_status; /* Status code to preserve */ + char *cancel_message; /* Error message to preserve */ DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, " @@ -1507,8 +1510,8 @@ * Unable to open print file, cancel the job and return... */ - cupsCancelJob2(http, name, job_id, 0); - return (0); + _cupsSetError(IPP_DOCUMENT_ACCESS_ERROR, NULL, 0); + goto cancel_job; } do @@ -1550,12 +1553,30 @@ * Unable to queue, cancel the job and return... */ - cupsCancelJob2(http, name, job_id, 0); - return (0); + goto cancel_job; } } return (job_id); + + /* + * If we get here, something happened while sending the print job so we need + * to cancel the job without setting the last error (since we need to preserve + * the current error... + */ + + cancel_job: + + cancel_status = cg->last_error; + cancel_message = cg->last_status_message ? + _cupsStrRetain(cg->last_status_message) : NULL; + + cupsCancelJob2(http, name, job_id, 0); + + cg->last_error = cancel_status; + cg->last_status_message = cancel_message; + + return (0); }