]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler: Fix cleaning jobs by loading times when needed 2.4.x
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 15 Jul 2025 11:16:52 +0000 (13:16 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 15 Jul 2025 11:16:52 +0000 (13:16 +0200)
Currently if we load jobs from job.cache, we don't set correct times
for `history_time` and `file_time`, resulting them in being 0 and the
jobs avoids the cleanup by cupsd when needed, leading into eating up
memory space.

It happens because none of the functions which set those job members are
not called - `cupsdSetJobState()` is used when changing job states,
`cupsdUpdateJobs()` during partial reload and `cupsdLoadJob()` is
guarded by condition in `load_job_cache()`.

The fix is to change conditional in `load_job_cache()` which will cause
loading of the job if cupsd is set to clean up job history, or if cupsd
should clean up job files and the job still has some.

CHANGES.md
scheduler/job.c

index c21e7f27eb39748947758ba53be3a77da4b549a9..a8dee9ef58cc5f9af5b6cb9c9985b6114b0d6891 100644 (file)
@@ -22,6 +22,7 @@ Changes in CUPS v2.4.13 (YYYY-MM-DD)
 - Fixed parsing of real numbers in PPD compiler source files (Issue #1263)
 - Fixed scheduler freezing with zombie clients (Issue #1264)
 - Fixed support for the server name in the ErrorLog filename (Issue #1277)
+- Fixed job cleanup after daemon restart (Issue #1315)
 
 
 Changes in CUPS v2.4.12 (2025-04-08)
index 58c7df462a79418e82630d5c7ab64408bcb3b957..620a2dd42c2c85d5fa13c5e5d29cf9fe6e040431 100644 (file)
@@ -4409,7 +4409,8 @@ load_job_cache(const char *filename)      /* I - job.cache filename */
        cupsArrayAdd(ActiveJobs, job);
       else if (job->state_value > IPP_JOB_STOPPED)
       {
-        if (!job->completed_time || !job->creation_time || !job->name || !job->koctets)
+       if (!job->completed_time || !job->creation_time || !job->name || !job->koctets ||
+           JobHistory < INT_MAX || (JobFiles < INT_MAX && job->num_files))
        {
          cupsdLoadJob(job);
          unload_job(job);