case IPP_JOB_ABORTED :
case IPP_JOB_CANCELED :
case IPP_JOB_COMPLETED :
- /*
- * Expire job subscriptions since the job is now "completed"...
- */
+ if (newstate == IPP_JOB_CANCELED)
+ {
+ /*
+ * Remove the job from the active list if there are no processes still
+ * running for it...
+ */
- cupsdExpireSubscriptions(NULL, job);
+ for (i = 0; job->filters[i] < 0; i++);
+
+ if (!job->filters[i] && job->backend <= 0)
+ cupsArrayRemove(ActiveJobs, job);
+ }
+ else
+ {
+ /*
+ * Otherwise just remove the job from the active list immediately...
+ */
+
+ cupsArrayRemove(ActiveJobs, job);
+ }
/*
- * Remove the job from the active list...
+ * Expire job subscriptions since the job is now "completed"...
*/
- cupsArrayRemove(ActiveJobs, job);
+ cupsdExpireSubscriptions(NULL, job);
#ifdef __APPLE__
/*
cupsdLogMessage(CUPSD_LOG_DEBUG2, "finalize_job(job=%p(%d))", job, job->id);
/*
- * Clear the "connecting-to-device" reason, which is only valid when a
- * printer is processing...
+ * Clear the "connecting-to-device" reason, which is only valid when a printer
+ * is processing...
*/
cupsdSetPrinterReasons(job->printer, "-connecting-to-device");
attr->value_tag == IPP_TAG_BEGIN_COLLECTION) /* Not yet supported */
continue;
- if (!strncmp(attr->name, "time-", 5))
+ if (!strncmp(attr->name, "time-", 5) ||
+ !strcmp(attr->name, "job-hold-until"))
continue;
if (!strncmp(attr->name, "job-", 4) &&
{
cupsArrayAdd(Jobs, job);
- if (job->state_value <= IPP_JOB_STOPPED)
- {
- cupsArrayAdd(ActiveJobs, job);
- cupsdLoadJob(job);
- }
+ if (job->state_value <= IPP_JOB_STOPPED && cupsdLoadJob(job))
+ cupsArrayAdd(ActiveJobs, job);
job = NULL;
}
* Load the job...
*/
- cupsdLoadJob(job);
+ if (cupsdLoadJob(job))
+ {
+ /*
+ * Insert the job into the array, sorting by job priority and ID...
+ */
- /*
- * Insert the job into the array, sorting by job priority and ID...
- */
+ cupsArrayAdd(Jobs, job);
- cupsArrayAdd(Jobs, job);
-
- if (job->state_value <= IPP_JOB_STOPPED)
- cupsArrayAdd(ActiveJobs, job);
- else
- unload_job(job);
+ if (job->state_value <= IPP_JOB_STOPPED)
+ cupsArrayAdd(ActiveJobs, job);
+ else
+ unload_job(job);
+ }
}
cupsDirClose(dir);
fcntl(job->side_pipes[1], F_SETFL,
fcntl(job->side_pipes[1], F_GETFL) | O_NONBLOCK);
+ fcntl(job->side_pipes[0], F_SETFD,
+ fcntl(job->side_pipes[0], F_GETFD) | FD_CLOEXEC);
+ fcntl(job->side_pipes[1], F_SETFD,
+ fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC);
+
/*
* Now start the first file in the job...
*/
cupsdStopPrinter(job->printer, 1);
return;
}
- else
+ else if (cupsdSetPrinterReasons(job->printer, message))
{
- cupsdSetPrinterReasons(job->printer, message);
cupsdAddPrinterHistory(job->printer);
event |= CUPSD_EVENT_PRINTER_STATE;
}
cupsFreeOptions(num_keywords, keywords);
}
-#ifdef __APPLE__
- else if (!strncmp(message, "recoverable:", 12))
+ else
{
- ptr = message + 12;
- while (isspace(*ptr & 255))
- ptr ++;
+ /*
+ * Strip legacy message prefix...
+ */
- if (*ptr)
+ if (!strncmp(message, "recoverable:", 12))
{
- cupsdSetPrinterReasons(job->printer,
- "+com.apple.print.recoverable-warning");
- cupsdSetString(&(job->printer->recoverable), ptr);
- cupsdAddPrinterHistory(job->printer);
- event |= CUPSD_EVENT_PRINTER_STATE;
+ ptr = message + 12;
+ while (isspace(*ptr & 255))
+ ptr ++;
}
- }
- else if (!strncmp(message, "recovered:", 10))
- {
- cupsdSetPrinterReasons(job->printer,
- "-com.apple.print.recoverable-warning");
-
- ptr = message + 10;
- while (isspace(*ptr & 255))
- ptr ++;
+ else if (!strncmp(message, "recovered:", 10))
+ {
+ ptr = message + 10;
+ while (isspace(*ptr & 255))
+ ptr ++;
+ }
+ else
+ ptr = message;
- cupsdSetString(&(job->printer->recoverable), ptr);
- cupsdAddPrinterHistory(job->printer);
- event |= CUPSD_EVENT_PRINTER_STATE;
- }
-#endif /* __APPLE__ */
- else
- {
- cupsdLogJob(job, loglevel, "%s", message);
+ cupsdLogJob(job, loglevel, "%s", ptr);
if (loglevel < CUPSD_LOG_DEBUG)
{
- strlcpy(job->printer->state_message, message,
+ strlcpy(job->printer->state_message, ptr,
sizeof(job->printer->state_message));
cupsdAddPrinterHistory(job->printer);