]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The scheduler no longer logs pages as they are printed, instead just logging
authorMichael R Sweet <michaelrsweet@gmail.com>
Wed, 8 Nov 2017 23:00:44 +0000 (18:00 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Wed, 8 Nov 2017 23:00:44 +0000 (18:00 -0500)
a total of the pages printed at job completion (Issue #4991)

- man/cupsd-logs.man: Update page_log information.
- scheduler/job.c: Move cupsdLogPage to finalize_job, make update_job only
  accept a "PAGE: total NNN" message if the count is greater than the total
  cupsd already has. Also track sheets.
- test/run-stp-tests.sh: Fix page log verification for Test3 since we now just
  have the total lines.

CHANGES.md
man/cupsd-logs.man
scheduler/job.c
test/run-stp-tests.sh

index 9180ab32ce0053404087c287b4996f09293334a9..de7aa5f7d647a2d1934c5f71077d0a043a5fb37a 100644 (file)
@@ -15,6 +15,8 @@ Changes in CUPS v2.3b1
 - The scheduler now supports the "printer-id" attribute (Issue #4868)
 - No longer support backslash, question mark, or quotes in printer names
   (Issue #4966)
+- The scheduler no longer logs pages as they are printed, instead just logging
+  a total of the pages printed at job completion (Issue #4991)
 - Dropped RSS subscription management from the web interface (Issue #5012)
 - Bonjour printer sharing now uses the DNS-SD hostname (or ServerName value if
   none is defined) when registering shared printers on the network (Issue #5071)
index 915b2050d7e496af6c1536db39553bd7c6c5a98e..27eb766a4937dcf7f36f5e04ac4c8b7054901ecd 100644 (file)
@@ -1,12 +1,13 @@
 .\"
 .\" cupsd-logs man page for CUPS.
 .\"
-.\" Copyright 2007-2014 by Apple Inc.
+.\" Copyright 2007-2017 by Apple Inc.
 .\" Copyright 1997-2006 by Easy Software Products.
 .\"
-.\" Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
+.\" Licensed under Apache License v2.0.  See the file "LICENSE" for more
+.\" information.
 .\"
-.TH cupsd-logs 5 "CUPS" "11 June 2014" "Apple Inc."
+.TH cupsd-logs 5 "CUPS" "8 November 2017" "Apple Inc."
 .SH NAME
 cupsd\-logs \- cupsd log files (access_log, error_log, and page_log)
 .SH DESCRIPTION
@@ -172,25 +173,17 @@ The \fIdate-time\fR field contains the date and time of when the page started pr
 The \fImessage\fR field contains a free-form textual message.
 Messages from job filters are prefixed with "[Job NNN]" where "NNN" is the job ID.
 .SS PAGE LOG FILE FORMAT
-The \fIpage_log\fR file lists each page or group of pages that are sent to a printer.
+The \fIpage_log\fR file lists the total number of pages (sheets) that are printed.
 By default, each line contains the following information:
 .nf
 
-    \fIprinter user job-id date-time page-number num-copies job-billing
-      job-originating-host-name job-name media sides\fR
-
-    \fIprinter user job-id date-time \fBtotal \fInum-impressions job-billing
+    \fIprinter user job-id date-time \fBtotal \fInum-sheets job-billing
       job-originating-host-name job-name media sides\fR
 
 .fi
-For example the entries for a two page job called "myjob" might look like:
+For example the entry for a two page job called "myjob" might look like:
 .nf
 
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 1 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 2 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-
     DeskJet root 1 [20/May/1999:19:21:06 +0000] total 2 acme-123
       localhost myjob na_letter_8.5x11in one-sided
 
@@ -209,10 +202,7 @@ The \fIjob-id\fR field contains the job number of the page being printed.
 The \fIdate-time\fR field contains the date and time of when the page started printing.
 The format of this field is identical to the data-time field in the \fIaccess_log\fR file.
 .LP
-The \fIpage-number\fR and \fInum-copies\fR fields contain the page number and number of copies being printed of that page.
-For printers that cannot produce copies on their own, the num-copies field will always be 1.
-.LP
-Lines containing the keyword "total" have a \fInum-impressions\fR field instead which provides the total number of impressions (sides) that have been printed on for the job.
+The \fInum-sheets\fR field provides the total number of pages (sheets) that have been printed on for the job.
 .LP
 The \fIjob-billing\fR field contains a copy of the job-billing or job-account-id attributes provided with the IPP Create-Job or Print-Job requests or "-" if neither was provided.
 .LP
index b2d8afd2feaf3a82e9c5e02bac167d9420009261..61cda44e2fea198e32f4d097d0a0ecdb525d6ade 100644 (file)
@@ -1846,6 +1846,8 @@ cupsdLoadJob(cupsd_job_t *job)            /* I - Job */
 
   if (!job->impressions)
     job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-impressions-completed", 0);
+  if (!job->sheets)
+    job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-media-sheets-completed", 0);
 
   if (!job->priority)
   {
@@ -3150,6 +3152,13 @@ finalize_job(cupsd_job_t *job,           /* I - Job */
   cupsdStatBufDelete(job->status_buffer);
   job->status_buffer = NULL;
 
+ /*
+  * Log the final impression (page) count...
+  */
+
+  snprintf(buffer, sizeof(buffer), "total %d", ippGetInteger(job->impressions, 0));
+  cupsdLogPage(job, buffer);
+
  /*
   * Process the exit status...
   */
@@ -4949,7 +4958,6 @@ void
 update_job(cupsd_job_t *job)           /* I - Job to check */
 {
   int          i;                      /* Looping var */
-  int          copies;                 /* Number of copies printed */
   char         message[CUPSD_SB_BUFFER_SIZE],
                                        /* Message text */
                *ptr;                   /* Pointer update... */
@@ -4987,6 +4995,10 @@ update_job(cupsd_job_t *job)             /* I - Job to check */
 
     if (loglevel == CUPSD_LOG_PAGE)
     {
+      int      impressions = ippGetInteger(job->impressions, 0);
+                               /* Number of impressions printed */
+      int      delta;          /* Number of impressions added */
+
      /*
       * Page message; send the message to the page_log file and update the
       * job sheet count...
@@ -4994,51 +5006,57 @@ update_job(cupsd_job_t *job)            /* I - Job to check */
 
       cupsdLogJob(job, CUPSD_LOG_DEBUG, "PAGE: %s", message);
 
-      if (job->impressions)
+      if (!_cups_strncasecmp(message, "total ", 6))
       {
-        if (!_cups_strncasecmp(message, "total ", 6))
-       {
-        /*
-         * Got a total count of pages from a backend or filter...
-         */
+       /*
+       * Got a total count of pages from a backend or filter...
+       */
+
+       int total = atoi(message + 6);  /* Total impressions */
 
-         copies = atoi(message + 6);
-         copies -= ippGetInteger(job->impressions, 0); /* Just track the delta */
+       if (total > impressions)
+       {
+         delta       = total - impressions;
+         impressions = total;
        }
-       else if (!sscanf(message, "%*d%d", &copies))
+       else
+         delta = 0;
+      }
+      else
+      {
+       /*
+        * Add the number of copies to the impression count...
+        */
+
+       int copies;                     /* Number of copies */
+
+       if (!sscanf(message, "%*d%d", &copies) || copies <= 0)
          copies = 1;
 
-        ippSetInteger(job->attrs, &job->impressions, 0, ippGetInteger(job->impressions, 0) + copies);
-        job->dirty = 1;
-       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
+        delta = copies;
+       impressions += copies;
       }
 
+      if (job->impressions)
+        ippSetInteger(job->attrs, &job->impressions, 0, impressions);
+
       if (job->sheets)
       {
-        if (!_cups_strncasecmp(message, "total ", 6))
-       {
-        /*
-         * Got a total count of pages from a backend or filter...
-         */
-
-         copies = atoi(message + 6);
-         copies -= ippGetInteger(job->sheets, 0); /* Just track the delta */
-       }
-       else if (!sscanf(message, "%*d%d", &copies))
-         copies = 1;
+       const char *sides = ippGetString(ippFindAttribute(job->attrs, "sides", IPP_TAG_KEYWORD), 0, NULL);
 
-        ippSetInteger(job->attrs, &job->sheets, 0, ippGetInteger(job->sheets, 0) + copies);
-        job->dirty = 1;
-       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
+        if (sides && strcmp(sides, "one-sided"))
+          ippSetInteger(job->attrs, &job->sheets, 0, impressions / 2);
+       else
+          ippSetInteger(job->attrs, &job->sheets, 0, impressions);
 
-       if (job->printer->page_limit)
-         cupsdUpdateQuota(job->printer, job->username, copies, 0);
+       cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", ippGetInteger(job->sheets, 0));
       }
 
-      cupsdLogPage(job, message);
+      job->dirty = 1;
+      cupsdMarkDirty(CUPSD_DIRTY_JOBS);
 
-      if (job->sheets)
-       cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", ippGetInteger(job->sheets, 0));
+      if (job->printer->page_limit)
+       cupsdUpdateQuota(job->printer, job->username, delta, 0);
     }
     else if (loglevel == CUPSD_LOG_JOBSTATE)
     {
index 45b05cb94d4d3b7fdc04edfa1363a4edc13d91c8..6924ef1e94eb7c9544193fe408e2e3579ab63e40 100755 (executable)
@@ -915,7 +915,7 @@ else
 fi
 
 # Paged printed on Test3
-count=`$GREP '^Test3 ' $BASE/log/page_log | grep -v total | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
+count=`$GREP '^Test3 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
 expected=2
 if test $count != $expected; then
        echo "FAIL: Printer 'Test3' produced $count page(s), expected $expected."