]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/quotas.c
Merge changes from CUPS 1.4svn-r8305.
[thirdparty/cups.git] / scheduler / quotas.c
index 4286f0e22d13c36b69604490356615360d7d50be..6d45b300d26c82ad5c2199119b7ec4cf83ee3cda 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Quota routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -155,10 +155,22 @@ cupsdUpdateQuota(
        job;
        job = (cupsd_job_t *)cupsArrayNext(Jobs))
   {
+   /*
+    * We only care about the current printer/class and user...
+    */
+
     if (strcasecmp(job->dest, p->name) != 0 ||
         strcasecmp(job->username, q->username) != 0)
       continue;
 
+   /*
+    * Make sure attributes are loaded; we always call cupsdLoadJob() to ensure
+    * the access_time member is updated so the job isn't unloaded right away...
+    */
+
+    if (!cupsdLoadJob(job))
+      continue;
+
     if ((attr = ippFindAttribute(job->attrs, "time-at-completion",
                                  IPP_TAG_INTEGER)) == NULL)
       if ((attr = ippFindAttribute(job->attrs, "time-at-processing",
@@ -166,11 +178,22 @@ cupsdUpdateQuota(
         attr = ippFindAttribute(job->attrs, "time-at-creation",
                                 IPP_TAG_INTEGER);
 
-    if (attr == NULL)
-      break;
+    if (!attr)
+    {
+     /*
+      * This should never happen since cupsdLoadJob() checks for
+      * time-at-creation, but if it does just ignore this job...
+      */
+
+      continue;
+    }
 
     if (attr->values[0].integer < curtime)
     {
+     /*
+      * This job is too old to count towards the quota, ignore it...
+      */
+
       if (JobAutoPurge)
         cupsdCancelJob(job, 1, IPP_JOB_CANCELED);