Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreserveJobFiles parameter #3425

Closed
michaelrsweet opened this issue Nov 24, 2009 · 11 comments
Closed

PreserveJobFiles parameter #3425

michaelrsweet opened this issue Nov 24, 2009 · 11 comments
Labels
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

@michaelrsweet michaelrsweet commented Nov 24, 2009

Version: 1.4.2
CUPS.org User: aumueller

If You set "PreserveJobFiles Off" job control files are not deleted.
(Even after waiting > 5 min).

See discussion on news group:
"Problem after update from 1.3.10 to 1.4.1 with job queue".

(Also tested with version 1.4.2).

Best regards,

Ralf

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 7, 2009

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 17, 2009

CUPS.org User: jpopelka

Hello Mike,

I have problem with your patch.

Don't know why you've removed cupsdDeleteJob().
I think it's needed there, because without it the job info file is not removed.
I'm adding it back and set job to NULL so we don't finalize already deleted job few lines later.
And I also changed the condition on beginning of cupsdSetJobState() - comment is there.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 17, 2009

CUPS.org User: mike

The IPP spec requires that the job object be preserved long enough for a client to see that the job has completed - at least several seconds.

So instead of deleting the job in cupsdSetJobState(), we delete it in cupsdCheckJobs() which is called from the main loop approximately every 10 seconds.

If the jobs are not disappearing after 10 seconds, please attach an error_log file with debug logging enabled - the jobs did go away for me.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 18, 2009

CUPS.org User: jpopelka

Ok, let me explain how I found my problem. Cups version, we have in Fedora CVS is 1.4.2 with several patches (including str3425.patch and commit r8914) applied. I played around with IPP_CANCEL_JOB(purge_job) in order to purge job and I found that the job info file is not deleted. Moreover it crashed in finalize_job(). Without str3425.patch and r8914 is was all right. I thought that it's str3425.patch's problem and the solution was my str3425-2.patch (I tested it and it fixes my problem).
But now I see that there can be something wrong also with r8914 commit, which changes condition in cupsdSetJobState

  • if (action == CUPSD_JOB_FORCE)
  • finalize_job(job);
  • if (action >= CUPSD_JOB_FORCE)
  • finalize_job(job, 0);
    so the finalize_job() is called even when (action==CUPSD_JOB_PURGE) and it crashes in finalize_job() because job->printer is NULL (that's the reason why I changed this in my patch).
    And I have other note to r8914: finalize_job() has new set_job_state parameter, which is not used (if I see right) in that function.
    Sorry for writing it here, but I don't know where else because I probably can't fill bug for unreleased version, right ?
@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 18, 2009

CUPS.org User: mike

Please test against top-of-tree 1.4.x:

svn co http://svn.easysw.com/public/cups/branches/branch-1.4 cups-1.4.x
cd cups-1.4.x
autoconf
./configure ...
make check

It contains quite a few other patches, including a fix for the crash you are seeing.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 21, 2009

CUPS.org User: jpopelka

make check PASSes all tests.

Yes, the r8927 commit is fixing the condition and therefore the crash.
But my initial problem (the job files are not deleted when I try to purge job(s)) is still there.
I'm trying the top-of-tree 1.4.x and when I create a queue, print test page and delete (which invokes cupsdCancelJobs(purge=true)) the queue, the test page job file is left in /var/spool/cups.
I had thought that it is so because you removed cupsdDeleteJob() from cupsdSetJobState().
You say that instead of deleting the job in cupsdSetJobState(), we delete it in cupsdCheckJobs(), but I can't find where exactly.
Maybe I'm still missing something and wasting your time.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Dec 29, 2009

CUPS.org User: mike

Re-opening while I add a "make check" test for this... Like I said, we can't purge the job immediately since we will no longer be conformant, but we should be purging after a small delay.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Mar 30, 2010

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Mar 30, 2010

"str3425.patch":

Index: scheduler/job.c

--- scheduler/job.c (revision 8900)
+++ scheduler/job.c (working copy)
@@ -433,11 +433,11 @@
cupsd_job_t job; / Current job */

  • if (MaxJobs <= 0)
  • if (MaxJobs <= 0 && JobHistory)
    return;

for (job = (cupsd_job_t *)cupsArrayFirst(Jobs);

  •   job && cupsArrayCount(Jobs) >= MaxJobs;
    
  •   job && (cupsArrayCount(Jobs) >= MaxJobs || !JobHistory);
    job = (cupsd_job_t *)cupsArrayNext(Jobs))
    
    if (job->state_value >= IPP_JOB_CANCELED && !job->printer)
    cupsdDeleteJob(job, CUPSD_JOB_PURGE);
    @@ -2434,8 +2434,6 @@
    job->dirty = 1;
    cupsdMarkDirty(CUPSD_DIRTY_JOBS);
    }
  • else if (!job->printer)
  • cupsdDeleteJob(job, CUPSD_JOB_PURGE);
    
    break;
    }

Index: scheduler/main.c

--- scheduler/main.c (revision 8900)
+++ scheduler/main.c (working copy)
@@ -379,7 +379,7 @@
* parent's file descriptors to be blocking. This is a workaround for a
* limitation of userland libpthread on OpenBSD.

*/

  • _thread_sys_closefrom(0);
    #endif /* OpenBSD */

@@ -807,8 +807,8 @@

 if (timeout == 86400 && Launchd && LaunchdTimeout && !NumPolled &&
     !cupsArrayCount(ActiveJobs) &&
  • (!Browsing ||
  • (!BrowseRemoteProtocols &&
  • (!Browsing ||
  • (!BrowseRemoteProtocols &&
    (!NumBrowsers || !BrowseLocalProtocols ||
    cupsArrayCount(Printers) == 0))))
    {
    @@ -1036,6 +1036,7 @@
    if ((current_time - senddoc_time) >= 10)
    {
    cupsdCheckJobs();
  •  cupsdCleanJobs();
    
    senddoc_time = current_time;
    }

@@ -1194,8 +1195,8 @@
#endif /* HAVE_GSSAPI */

#if defined(APPLE) && defined(HAVE_DLFCN_H)

  • /*

  • * Unload Print Service quota enforcement library (X Server only)

  • /*

    • Unload Print Service quota enforcement library (X Server only)
      */

    PSQUpdateQuotaProc = NULL;
    @@ -1552,13 +1553,13 @@

    if (lis)
    {

  • cupsdLogMessage(CUPSD_LOG_DEBUG, 
    
  • cupsdLogMessage(CUPSD_LOG_DEBUG,
      "launchd_checkin: Matched existing listener %s with fd %d...",
      httpAddrString(&(lis->address), s, sizeof(s)), fd);
    

    }
    else
    {

  • cupsdLogMessage(CUPSD_LOG_DEBUG, 
    
  • cupsdLogMessage(CUPSD_LOG_DEBUG,
      "launchd_checkin: Adding new listener %s with fd %d...",
      httpAddrString(&addr, s, sizeof(s)), fd);
    

@@ -1612,12 +1613,12 @@

/*

  • Create or remove the launchd KeepAlive file based on whether
    • * there are active jobs, polling, browsing for remote printers or
    • * there are active jobs, polling, browsing for remote printers or
  • shared printers to advertise...
    */
  • if ((cupsArrayCount(ActiveJobs) || NumPolled ||
  •   (Browsing && 
    
  • if ((cupsArrayCount(ActiveJobs) || NumPolled ||
  •   (Browsing &&
    
    (BrowseRemoteProtocols ||
    (BrowseLocalProtocols && NumBrowsers && cupsArrayCount(Printers))))))
    {
@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Mar 30, 2010

"str3425-2.patch":

diff -up cups-1.4.2/scheduler/job.c.purge cups-1.4.2/scheduler/job.c
--- cups-1.4.2/scheduler/job.c.purge 2009-12-17 15:01:35.000000000 +0100
+++ cups-1.4.2/scheduler/job.c 2009-12-17 15:03:50.000000000 +0100
@@ -2286,12 +2286,14 @@ cupsdSetJobState(
if (!cupsdLoadJob(job))
return;

  • /*
  • * Don't do anything if the state is unchanged...

- */

  • if (newstate == (oldstate = job->state_value))
  • return;
  • /*
  • * Don't do anything if the state is unchanged...
  • * (unless we want to cancel(purge) already canceled job)
  • */
  • oldstate = job->state_value;

  • if ((newstate == oldstate) && (action != CUPSD_JOB_PURGE))

  • return;
    

    /*

    • Stop any processes that are working on the current job...
      @@ -2498,6 +2500,10 @@ cupsdSetJobState(
      job->dirty = 1;
      cupsdMarkDirty(CUPSD_DIRTY_JOBS);
      }
  • else if (!job->printer) {

  • cupsdDeleteJob(job, CUPSD_JOB_PURGE);
    
  • job = NULL;
    
  • }
    break;
    }

@@ -2505,7 +2511,7 @@ cupsdSetJobState(

  • Finalize the job immediately if we forced things...
    */
  • if (action >= CUPSD_JOB_FORCE)
  • if (job && (action >= CUPSD_JOB_FORCE))
    finalize_job(job, 0);

/*

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Mar 30, 2010

"str3425p2.patch":

Index: test/run-stp-tests.sh

--- test/run-stp-tests.sh (revision 9033)
+++ test/run-stp-tests.sh (working copy)
@@ -612,6 +612,18 @@
echo ""
echo "

Summary

" >>$strfile

+# Job control files
+count=ls -1 /tmp/cups-$user/spool | wc -l
+count=expr $count - 1
+if test $count != 0; then

  • echo "FAIL: $count job control files were not purged."
  • echo "

    FAIL: $count job control files were not purged.

    " >>$strfile
  • fail=expr $fail + 1
    +else
  • echo "PASS: All job control files purged."
  • echo "

    PASS: All job control files purged.

    " >>$strfile
    +fi

Pages printed on Test1 (within 1 page for timing-dependent cancel issues)

count=grep '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'
expected=expr $pjobs \* 2 + 34

Index: scheduler/job.c

--- scheduler/job.c (revision 9033)
+++ scheduler/job.c (working copy)
@@ -2222,12 +2222,14 @@
if (!cupsdLoadJob(job))
return;

  • /*

  • * Don't do anything if the state is unchanged...

  • */

  • /*

  • * Don't do anything if the state is unchanged and we aren't purging the

  • * job...

  • */

  • if (newstate == (oldstate = job->state_value))

  • return;

  • oldstate = job->state_value;

  • if (newstate == oldstate && action != CUPSD_JOB_PURGE)

  • return;
    

    /*

    • Stop any processes that are working on the current job...
      @@ -2434,6 +2436,15 @@
      job->dirty = 1;
      cupsdMarkDirty(CUPSD_DIRTY_JOBS);
      }
  • else if (!job->printer)

  • {

  • /*

  • \* Delete the job immediately if not actively printing...
    
  • */
    
  • cupsdDeleteJob(job, CUPSD_JOB_PURGE);
    
  • job = NULL;
    
  • }
    break;
    }

@@ -2441,7 +2452,7 @@

  • Finalize the job immediately if we forced things...
    */
  • if (action >= CUPSD_JOB_FORCE && job->printer)
  • if (action >= CUPSD_JOB_FORCE && job && job->printer)
    finalize_job(job, 0);

/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.