From 8a58f035283bdf287be5e57c6f2e4ebe82123eb0 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Mon, 27 Nov 2023 12:59:18 +0100 Subject: [PATCH] scheduler: Set reasons in cupsdSetJobState only if we call finalize_job later Before the fix, every successfully printed jobs ended up with 'processing-to-stop-point' as the last reasons message. Final fix for #828 . --- CHANGES.md | 1 + scheduler/job.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f494a075a6..15977239ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Changes in CUPS v2.4.8 (TBA) - Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831) - Fixed memory leak when creating color profiles (Issue #815) - Fixed memory leak when unloading a job (Issue #813) +- Fixed setting job state reasons for successful jobs (Issue #832) - Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751) - Really backport fix for Issue #742 diff --git a/scheduler/job.c b/scheduler/job.c index 768b099651..093272329b 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -2608,8 +2608,16 @@ cupsdSetJobState( case IPP_JOB_CANCELED : case IPP_JOB_COMPLETED : set_time(job, "time-at-completed"); - ippSetString(job->attrs, &job->reasons, 0, "processing-to-stop-point"); - break; + + /* + * Set the reasons here only if we call finalize_job() + * at the end of this function, so finished jobs can get proper + * reasons message there... + */ + + if (action >= CUPSD_JOB_FORCE && job && job->printer) + ippSetString(job->attrs, &job->reasons, 0, "processing-to-stop-point"); + break; } /* -- 2.47.2