diff options
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 26 | ||||
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | cupsfilters/ppdgenerator.c | 16 | ||||
-rw-r--r-- | debian/.git-dpm | 14 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | debian/patches/0001-Poppler-0.69-gMemReport-removed-from-API-in-f89446f6.patch | 54 | ||||
-rw-r--r-- | debian/patches/0002-Poppler-0.69-Object-memCheck-removed-from-API-in-c36.patch | 54 | ||||
-rw-r--r-- | debian/patches/series | 3 | ||||
-rw-r--r-- | filter/pdftoijs.cxx | 10 | ||||
-rw-r--r-- | filter/pdftoopvp/pdftoopvp.cxx | 10 | ||||
-rw-r--r-- | filter/pdftopdf/pdftopdf.cc | 24 | ||||
-rw-r--r-- | filter/pdftoraster.cxx | 18 | ||||
-rw-r--r-- | utils/cups-browsed.c | 77 | ||||
-rw-r--r-- | utils/cups-browsed.conf.5 | 12 | ||||
-rw-r--r-- | utils/cups-browsed.conf.in | 7 |
18 files changed, 215 insertions, 142 deletions
@@ -1,4 +1,4 @@ -INSTALL - OpenPrinting CUPS Filters v1.21.3 - 2018-10-03 +INSTALL - OpenPrinting CUPS Filters v1.21.4 - 2018-11-23 -------------------------------------------------------- This file describes how to compile and install OpenPrinting CUPS @@ -1,6 +1,30 @@ -NEWS - OpenPrinting CUPS Filters v1.21.3 - 2018-10-03 +NEWS - OpenPrinting CUPS Filters v1.21.4 - 2018-11-23 ----------------------------------------------------- +CHANGES IN V1.21.4 + + - cups-browsed: cups-browsed: Limit the number of retries for + creating a print queue when it comes to HTTP + timeouts. Number of retries given by HttpMaxRetries + directive in cups-browsed.conf. Thanks to Zdenek Dohnal for + the patch (Pull request #73, Red Hat bug #1648697). + - cups-browsed: Read out current time right before setting the + timeouts. Thanks to Zdenek Dohnal for the patch (Pull + request #71, Red Hat bug #1648697). + - libcupsfilters: In the PPD generator for driverless IPP + printing let "*cupsManualCopies: true" lines get added to + the PPD if printing is done in a raster format as then + pdftopdf needs to generate the copies. + - pdftoraster, pdftoopvp, pdftoijs: Fix build with Poppler >= + 0.70 (Issue #69, Pull request #70). + - pdftopdf: Fixed printing multiple copies on driverless IPP + printers. When printing collated copies the multiple copies + got applied twice, resulting in n*n instead of n copies + (CUPS issue #5433). + - pdftoraster, pdftoopvp, pdftoijs: Poppler removed memCheck + and gMemReport functions, remove appropriate calls (Issue + #62, Pull request #66). + CHANGES IN V1.21.3 - foomatic-rip: Reset stdin after replacing the underlying file @@ -1,4 +1,4 @@ -README - OpenPrinting CUPS Filters v1.21.3 - 2018-10-03 +README - OpenPrinting CUPS Filters v1.21.4 - 2018-11-23 ------------------------------------------------------- Looking for compile instructions? Read the file "INSTALL.txt" @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for cups-filters 1.21.3. +# Generated by GNU Autoconf 2.69 for cups-filters 1.21.4. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='cups-filters' PACKAGE_TARNAME='cups-filters' -PACKAGE_VERSION='1.21.3' -PACKAGE_STRING='cups-filters 1.21.3' +PACKAGE_VERSION='1.21.4' +PACKAGE_STRING='cups-filters 1.21.4' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1500,7 +1500,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures cups-filters 1.21.3 to adapt to many kinds of systems. +\`configure' configures cups-filters 1.21.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1571,7 +1571,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of cups-filters 1.21.3:";; + short | recursive ) echo "Configuration of cups-filters 1.21.4:";; esac cat <<\_ACEOF @@ -1801,7 +1801,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -cups-filters configure 1.21.3 +cups-filters configure 1.21.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2439,7 +2439,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by cups-filters $as_me 1.21.3, which was +It was created by cups-filters $as_me 1.21.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3474,7 +3474,7 @@ fi # Define the identity of the package. PACKAGE='cups-filters' - VERSION='1.21.3' + VERSION='1.21.4' cat >>confdefs.h <<_ACEOF @@ -21808,7 +21808,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by cups-filters $as_me 1.21.3, which was +This file was extended by cups-filters $as_me 1.21.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21874,7 +21874,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -cups-filters config.status 1.21.3 +cups-filters config.status 1.21.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a00929603..4d48db6c6 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREREQ([2.65]) # ==================== m4_define([cups_filters_version_major],[1]) m4_define([cups_filters_version_minor],[21]) -m4_define([cups_filters_version_micro],[3]) +m4_define([cups_filters_version_micro],[4]) m4_define([cups_filters_version],[cups_filters_version_major.cups_filters_version_minor.cups_filters_version_micro]) # ============= diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c index 5b780b136..934b1ce27 100644 --- a/cupsfilters/ppdgenerator.c +++ b/cupsfilters/ppdgenerator.c @@ -1228,6 +1228,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ int outputorderinfofound = 0, faceupdown = 1, firsttolast = 1; + int manual_copies = -1; /* * Range check input... @@ -1438,10 +1439,12 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ https://github.com/apple/cups/issues/5361 */ if (cupsArrayFind(pdl_list, "application/vnd.cups-pdf")) { cupsFilePuts(fp, "*cupsFilter2: \"application/pdf application/pdf 0 -\"\n"); + manual_copies = 0; formatfound = 1; is_pdf = 1; } else if (cupsArrayFind(pdl_list, "application/pdf")) { cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 0 -\"\n"); + manual_copies = 0; formatfound = 1; is_pdf = 1; } @@ -1452,6 +1455,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ joinResolutionArrays(&common_res, ¤t_res, &common_def, ¤t_def)) { cupsFilePuts(fp, "*cupsFilter2: \"image/pwg-raster image/pwg-raster 0 -\"\n"); + if (formatfound == 0) manual_copies = 1; formatfound = 1; is_pwg = 1; } @@ -1487,6 +1491,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ joinResolutionArrays(&common_res, ¤t_res, &common_def, ¤t_def)) { cupsFilePuts(fp, "*cupsFilter2: \"image/urf image/urf 100 -\"\n"); + if (formatfound == 0) manual_copies = 1; formatfound = 1; is_apple = 1; } @@ -1506,6 +1511,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ joinResolutionArrays(&common_res, ¤t_res, &common_def, ¤t_def)) { cupsFilePuts(fp, "*cupsFilter2: \"application/PCLm application/PCLm 200 -\"\n"); + if (formatfound == 0) manual_copies = 1; formatfound = 1; is_pclm = 1; } @@ -1524,6 +1530,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ another format, like PWG or Apple Raster, we prefer it, as some PCL-XL printers have bugs in their PCL-XL interpreters */ cupsFilePrintf(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/vnd.hp-pclxl 300 gstopxl\"\n"); + if (formatfound == 0) manual_copies = 1; formatfound = 1; } } @@ -1532,6 +1539,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ another format, like PWG or Apple Raster, we prefer it, as many PostScript printers have bugs in their PostScript interpreters */ cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-postscript application/postscript 500 -\"\n"); + if (formatfound == 0) manual_copies = 0; formatfound = 1; } if (cupsArrayFind(pdl_list, "application/vnd.hp-pcl")) { @@ -1540,6 +1548,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ are some printers, like HP inkjets which report to accept PCL but do not support PCL 5c/e or PCL-XL */ cupsFilePrintf(fp, "*cupsFilter2: \"application/vnd.cups-raster application/vnd.hp-pcl 700 rastertopclx\"\n"); + if (formatfound == 0) manual_copies = 1; formatfound = 1; } if (cupsArrayFind(pdl_list, "image/jpeg")) @@ -1547,9 +1556,16 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ if (cupsArrayFind(pdl_list, "image/png")) cupsFilePuts(fp, "*cupsFilter2: \"image/png image/png 0 -\"\n"); cupsArrayDelete(pdl_list); + if (manual_copies < 0) manual_copies = 1; if (formatfound == 0) goto bad_ppd; + /* For the case that we will print in a raster format and not in a high-level + format, we need to create multiple copies on the client. We add a line to + the PPD which tells the pdftopdf filter to generate the copies */ + if (manual_copies == 1) + cupsFilePuts(fp, "*cupsManualCopies: true\n"); + /* No resolution requirements by any of the supported PDLs? Use "printer-resolution-supported" attribute */ if (common_res == NULL) { diff --git a/debian/.git-dpm b/debian/.git-dpm index 2e889f141..9a0cfd6ab 100644 --- a/debian/.git-dpm +++ b/debian/.git-dpm @@ -1,8 +1,8 @@ # see git-dpm(1) from git-dpm package -2b1d2abe4aa7e03963f30f9dd707173dda075fea -2b1d2abe4aa7e03963f30f9dd707173dda075fea -2e882fb62da3a4da09d62365e25e7b4282d34683 -2e882fb62da3a4da09d62365e25e7b4282d34683 -cups-filters_1.21.3.orig.tar.xz -5164f21a78a425b19c375f86be4e9159f970ac52 -1474152 +37f19bac74751aec1f737ab0c465b4a554aa93d4 +37f19bac74751aec1f737ab0c465b4a554aa93d4 +37f19bac74751aec1f737ab0c465b4a554aa93d4 +37f19bac74751aec1f737ab0c465b4a554aa93d4 +cups-filters_1.21.4.orig.tar.xz +6f269a5b6f37260a2f80357678215106cb85d340 +1474564 diff --git a/debian/changelog b/debian/changelog index a01b4fb22..2579e9769 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cups-filters (1.21.4-1) unstable; urgency=medium + + * New upstream version 1.21.4 + + -- Didier Raboud <odyx@debian.org> Sun, 25 Nov 2018 12:19:33 +0100 + cups-filters (1.21.3-3) unstable; urgency=medium * Demote imagemagick from Recommends to Suggests (Closes: #913120) diff --git a/debian/patches/0001-Poppler-0.69-gMemReport-removed-from-API-in-f89446f6.patch b/debian/patches/0001-Poppler-0.69-gMemReport-removed-from-API-in-f89446f6.patch deleted file mode 100644 index 5f5b4b846..000000000 --- a/debian/patches/0001-Poppler-0.69-gMemReport-removed-from-API-in-f89446f6.patch +++ /dev/null @@ -1,54 +0,0 @@ -From bb264947c3b7de87a66f6c2433e5eaf77a7c9012 Mon Sep 17 00:00:00 2001 -From: Didier Raboud <odyx@debian.org> -Date: Sat, 20 Oct 2018 18:41:06 +0200 -Subject: =?UTF-8?q?Poppler=200.69:=20gMemReport=20removed=20from=20API?= - =?UTF-8?q?=C2=A0in=20f89446f6917a869b0f1a80fcc8ce81a7213dade4?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - filter/pdftoijs.cxx | 2 -- - filter/pdftoopvp/pdftoopvp.cxx | 2 -- - filter/pdftoraster.cxx | 2 -- - 3 files changed, 6 deletions(-) - -diff --git a/filter/pdftoijs.cxx b/filter/pdftoijs.cxx -index 22bc33f43..edc5743f7 100644 ---- a/filter/pdftoijs.cxx -+++ b/filter/pdftoijs.cxx -@@ -505,8 +505,6 @@ err1: - - // Check for memory leaks - Object::memCheck(stderr); -- gMemReport(stderr); -- - return exitCode; - } - -diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx -index 024941ab0..c5ded6f24 100644 ---- a/filter/pdftoopvp/pdftoopvp.cxx -+++ b/filter/pdftoopvp/pdftoopvp.cxx -@@ -765,8 +765,6 @@ err2: - - // check for memory leaks - Object::memCheck(stderr); -- gMemReport(stderr); -- - } - /* muntrace(); */ - return exitCode; -diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx -index 0c63ab8d5..757d4c752 100644 ---- a/filter/pdftoraster.cxx -+++ b/filter/pdftoraster.cxx -@@ -2164,8 +2164,6 @@ err1: - - // Check for memory leaks - Object::memCheck(stderr); -- gMemReport(stderr); -- - return exitCode; - } - diff --git a/debian/patches/0002-Poppler-0.69-Object-memCheck-removed-from-API-in-c36.patch b/debian/patches/0002-Poppler-0.69-Object-memCheck-removed-from-API-in-c36.patch deleted file mode 100644 index 4bad1c3c1..000000000 --- a/debian/patches/0002-Poppler-0.69-Object-memCheck-removed-from-API-in-c36.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 2b1d2abe4aa7e03963f30f9dd707173dda075fea Mon Sep 17 00:00:00 2001 -From: Didier Raboud <odyx@debian.org> -Date: Sat, 20 Oct 2018 18:43:05 +0200 -Subject: =?UTF-8?q?Poppler=200.69:=20Object::memCheck=20removed=20from=20A?= - =?UTF-8?q?PI=C2=A0in=20c362ab1b97f20c5b73b3bad8d52015f679178748?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - filter/pdftoijs.cxx | 2 -- - filter/pdftoopvp/pdftoopvp.cxx | 2 -- - filter/pdftoraster.cxx | 2 -- - 3 files changed, 6 deletions(-) - -diff --git a/filter/pdftoijs.cxx b/filter/pdftoijs.cxx -index edc5743f7..57fef77ef 100644 ---- a/filter/pdftoijs.cxx -+++ b/filter/pdftoijs.cxx -@@ -503,8 +503,6 @@ err1: - ppdClose(ppd); - free(outputfile); - -- // Check for memory leaks -- Object::memCheck(stderr); - return exitCode; - } - -diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx -index c5ded6f24..f7fe18cc7 100644 ---- a/filter/pdftoopvp/pdftoopvp.cxx -+++ b/filter/pdftoopvp/pdftoopvp.cxx -@@ -763,8 +763,6 @@ err2: - err0: - delete globalParams; - -- // check for memory leaks -- Object::memCheck(stderr); - } - /* muntrace(); */ - return exitCode; -diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx -index 757d4c752..eae8f54ee 100644 ---- a/filter/pdftoraster.cxx -+++ b/filter/pdftoraster.cxx -@@ -2162,8 +2162,6 @@ err1: - cmsDeleteTransform(colorTransform); - } - -- // Check for memory leaks -- Object::memCheck(stderr); - return exitCode; - } - diff --git a/debian/patches/series b/debian/patches/series index e9195e318..a22980abc 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,2 @@ -0001-Poppler-0.69-gMemReport-removed-from-API-in-f89446f6.patch -0002-Poppler-0.69-Object-memCheck-removed-from-API-in-c36.patch + auto-gitignore diff --git a/filter/pdftoijs.cxx b/filter/pdftoijs.cxx index 57fef77ef..e69bd3269 100644 --- a/filter/pdftoijs.cxx +++ b/filter/pdftoijs.cxx @@ -72,7 +72,11 @@ namespace { #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19 #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23 void CDECL myErrorFun(void *data, ErrorCategory category, +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70 + Goffset pos, const char *msg) +#else Goffset pos, char *msg) +#endif /* MAJOR > 0 || MINOR >= 70 */ #else void CDECL myErrorFun(void *data, ErrorCategory category, int pos, char *msg) @@ -503,6 +507,12 @@ err1: ppdClose(ppd); free(outputfile); +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69 + // Check for memory leaks + Object::memCheck(stderr); + gMemReport(stderr); +#endif + return exitCode; } diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx index f7fe18cc7..f0d69fae4 100644 --- a/filter/pdftoopvp/pdftoopvp.cxx +++ b/filter/pdftoopvp/pdftoopvp.cxx @@ -114,7 +114,11 @@ static int outOnePage(PDFDoc *doc, OPVPOutputDev *opvpOut, int pg) #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19 #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23 void CDECL myErrorFun(void *data, ErrorCategory category, +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70 + Goffset pos, const char *msg) +#else Goffset pos, char *msg) +#endif /* MAJOR > 0 || MINOR >= 70 */ #else void CDECL myErrorFun(void *data, ErrorCategory category, int pos, char *msg) @@ -763,6 +767,12 @@ err2: err0: delete globalParams; +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69 + // check for memory leaks + Object::memCheck(stderr); + gMemReport(stderr); +#endif + } /* muntrace(); */ return exitCode; diff --git a/filter/pdftopdf/pdftopdf.cc b/filter/pdftopdf/pdftopdf.cc index f474f08c6..880b664fd 100644 --- a/filter/pdftopdf/pdftopdf.cc +++ b/filter/pdftopdf/pdftopdf.cc @@ -783,11 +783,25 @@ void calculate(ppd_file_t *ppd,ProcessingParameters ¶m) // {{{ } else if ((ppd)&&(!ppd->manual_copies)) { // hw copy generation available param.deviceCopies=param.numCopies; if (param.collate) { // collate requested by user - // check collate device, with current/final(!) ppd settings - param.deviceCollate=printerWillCollate(ppd); - if (!param.deviceCollate) { - // printer can't hw collate -> we must copy collated in sw - param.deviceCopies=1; + // Check output format (FINAL_CONTENT_TYPE env variable) whether it is + // of a driverless IPP printer (PDF, Apple Raster, PWG Raster, PCLm). + // These printers do always hardware collate if they do hardware copies. + // https://github.com/apple/cups/issues/5433 + char *final_content_type = getenv("FINAL_CONTENT_TYPE"); + if (final_content_type && + (strcasestr(final_content_type, "/pdf") || + strcasestr(final_content_type, "/vnd.cups-pdf") || + strcasestr(final_content_type, "/pwg-raster") || + strcasestr(final_content_type, "/urf") || + strcasestr(final_content_type, "/PCLm"))) { + param.deviceCollate = true; + } else { + // check collate device, with current/final(!) ppd settings + param.deviceCollate=printerWillCollate(ppd); + if (!param.deviceCollate) { + // printer can't hw collate -> we must copy collated in sw + param.deviceCopies=1; + } } } // else: printer copies w/o collate and takes care of duplex/evenDuplex } else { // sw copies diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx index eae8f54ee..975cefdf9 100644 --- a/filter/pdftoraster.cxx +++ b/filter/pdftoraster.cxx @@ -283,7 +283,11 @@ cmsHPROFILE sgray_profile() #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19 #if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23 void CDECL myErrorFun(void *data, ErrorCategory category, +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70 + Goffset pos, const char *msg) +#else Goffset pos, char *msg) +#endif /* MAJOR > 0 || MINOR >= 70 */ #else void CDECL myErrorFun(void *data, ErrorCategory category, int pos, char *msg) @@ -1686,7 +1690,7 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo, { SplashBitmap *bitmap; Page *page = catalog->getPage(pageNo); - PDFRectangle *mediaBox = page->getMediaBox(); + PDFRectangle mediaBox = *page->getMediaBox(); int rotate = page->getRotate(); double paperdimensions[2], /* Physical size of the paper */ margins[4]; /* Physical margins of print */ @@ -1696,14 +1700,14 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo, bool landscape = 0; fprintf(stderr, "DEBUG: mediaBox = [ %f %f %f %f ]; rotate = %d\n", - mediaBox->x1, mediaBox->y1, mediaBox->x2, mediaBox->y2, rotate); - l = mediaBox->x2 - mediaBox->x1; + mediaBox.x1, mediaBox.y1, mediaBox.x2, mediaBox.y2, rotate); + l = mediaBox.x2 - mediaBox.x1; if (l < 0) l = -l; if (rotate == 90 || rotate == 270) header.PageSize[1] = (unsigned)l; else header.PageSize[0] = (unsigned)l; - l = mediaBox->y2 - mediaBox->y1; + l = mediaBox.y2 - mediaBox.y1; if (l < 0) l = -l; if (rotate == 90 || rotate == 270) header.PageSize[0] = (unsigned)l; @@ -2162,6 +2166,12 @@ err1: cmsDeleteTransform(colorTransform); } +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69 + // Check for memory leaks + Object::memCheck(stderr); + gMemReport(stderr); +#endif + return exitCode; } diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c index 7c3f5c2bf..392e37b36 100644 --- a/utils/cups-browsed.c +++ b/utils/cups-browsed.c @@ -189,6 +189,7 @@ typedef struct remote_printer_s { int overwritten; int netprinter; int is_legacy; + int timeouted; } remote_printer_t; /* Data structure for network interfaces */ @@ -384,6 +385,7 @@ static char local_server_str[1024]; static char *DomainSocket = NULL; static unsigned int HttpLocalTimeout = 5; static unsigned int HttpRemoteTimeout = 10; +static unsigned int HttpMaxRetries = 5; static ip_based_uris_t IPBasedDeviceURIs = IP_BASED_URIS_NO; static local_queue_naming_t LocalQueueNamingRemoteCUPS=LOCAL_QUEUE_NAMING_DNSSD; static local_queue_naming_t LocalQueueNamingIPPPrinter=LOCAL_QUEUE_NAMING_DNSSD; @@ -423,6 +425,9 @@ static char remote_default_printer_file[1024]; static char save_options_file[1024]; static char debug_log_file[1024]; +/* Static global variable for indicating we have reached the HTTP timeout */ +static int timeout_reached = 0; + static void recheck_timer (void); static void browse_poll_create_subscription (browsepoll_t *context, http_t *conn); @@ -638,6 +643,7 @@ int http_timeout_cb(http_t *http, void *user_data) { debug_printf("HTTP timeout! (consider increasing HttpLocalTimeout/HttpRemoteTimeout value)\n"); + timeout_reached = 1; return 0; } @@ -4000,6 +4006,10 @@ create_remote_printer_entry (const char *queue_name, CUPS broadcast (1) or through DNS-SD (0) */ p->is_legacy = 0; + /* Initialize field for how many timeouts cups-browsed experienced + in a row during creation of this printer's queue */ + p->timeouted = 0; + /* Remote CUPS printer or local queue remaining from previous cups-browsed session */ /* is_cups_queue: -1: Unknown, 0: IPP printer, 1: Remote CUPS queue, @@ -4407,7 +4417,7 @@ gboolean update_cups_queues(gpointer unused) { int num_jobs; cups_job_t *jobs; ipp_t *request; - time_t current_time = time(NULL); + time_t current_time; int i, new_cupsfilter_line_inserted, ap_remote_queue_id_line_inserted, cont_line_read, want_raw; char *disabled_str, *ptr, *prefix; @@ -4461,6 +4471,20 @@ gboolean update_cups_queues(gpointer unused) { for (p = (remote_printer_t *)cupsArrayFirst(remote_printers); p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) { + /* We need to get the current time as precise as possible for retries + and reset the timeout flag */ + current_time = time(NULL); + timeout_reached = 0; + + /* cups-browsed tried to add this print queue unsuccessfully for too + many times due to timeouts - Skip print queue creation for this one */ + if (p->timeouted >= HttpMaxRetries) + { + fprintf(stderr, "Max number of retries (%d) for creating print queue %s reached, skipping it.\n", + HttpMaxRetries, p->queue_name); + continue; + } + /* terminating means we have received a signal and should shut down. in_shutdown means we have exited the main loop. update_cups_queues() is called after having exited the main loop @@ -4502,8 +4526,10 @@ gboolean update_cups_queues(gpointer unused) { if ((q = p->slave_of) == NULL) { if ((http = http_connect_local ()) == NULL) { debug_printf("Unable to connect to CUPS!\n"); - if (in_shutdown == 0) + if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; + } break; } @@ -4537,6 +4563,7 @@ gboolean update_cups_queues(gpointer unused) { "Printer disappeared or cups-browsed shutdown"); /* Schedule the removal of the queue for later */ if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -4556,6 +4583,7 @@ gboolean update_cups_queues(gpointer unused) { if (cups_notifier == NULL && is_cups_default_printer(p->queue_name)) { /* Schedule the removal of the queue for later */ if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -4579,6 +4607,7 @@ gboolean update_cups_queues(gpointer unused) { if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { debug_printf("Unable to remove CUPS queue!\n"); if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -4657,6 +4686,7 @@ gboolean update_cups_queues(gpointer unused) { /* Make sure to have a connection to the local CUPS daemon */ if ((http = http_connect_local ()) == NULL) { debug_printf("Unable to connect to CUPS!\n"); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; break; } @@ -4779,6 +4809,7 @@ gboolean update_cups_queues(gpointer unused) { cupsFreeJobs(num_jobs, jobs); /* Schedule the removal of the queue for later */ if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -4794,6 +4825,7 @@ gboolean update_cups_queues(gpointer unused) { if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { debug_printf("Unable to remove temporary CUPS queue, retrying later\n"); if (in_shutdown == 0) { + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -4817,6 +4849,7 @@ gboolean update_cups_queues(gpointer unused) { debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n", p->queue_name, p->uri); p->status = STATUS_DISAPPEARED; + current_time = time(NULL); p->timeout = current_time + TIMEOUT_IMMEDIATELY; goto cannot_create; } @@ -4834,6 +4867,7 @@ gboolean update_cups_queues(gpointer unused) { else debug_printf("Unable to create PPD file: %s\n", ppdgenerator_msg); p->status = STATUS_DISAPPEARED; + current_time = time(NULL); p->timeout = current_time + TIMEOUT_IMMEDIATELY; goto cannot_create; } else { @@ -4959,6 +4993,7 @@ gboolean update_cups_queues(gpointer unused) { if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0) { debug_printf("Unable to create interface script file\n"); p->status = STATUS_DISAPPEARED; + current_time = time(NULL); p->timeout = current_time + TIMEOUT_IMMEDIATELY; goto cannot_create; } @@ -4986,6 +5021,7 @@ gboolean update_cups_queues(gpointer unused) { if (bytes != strlen(buffer)) { debug_printf("Unable to write interface script into the file\n"); p->status = STATUS_DISAPPEARED; + current_time = time(NULL); p->timeout = current_time + TIMEOUT_IMMEDIATELY; goto cannot_create; } @@ -5061,6 +5097,7 @@ gboolean update_cups_queues(gpointer unused) { == NULL) { debug_printf("Could not connect to the server %s:%d for %s!\n", p->host, p->port, p->queue_name); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -5071,6 +5108,7 @@ gboolean update_cups_queues(gpointer unused) { CreateRemoteRawPrinterQueues == 0) { debug_printf("Unable to load PPD file for %s from the server %s:%d!\n", p->queue_name, p->host, p->port); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; httpClose(remote_http); @@ -5104,6 +5142,7 @@ gboolean update_cups_queues(gpointer unused) { ppd_status_t status = ppdLastError(&linenum); debug_printf("Unable to open PPD \"%s\": %s on line %d.", loadedppd, ppdErrorString(status), linenum); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; unlink(loadedppd); @@ -5113,6 +5152,7 @@ gboolean update_cups_queues(gpointer unused) { cupsMarkOptions(ppd, p->num_options, p->options); if ((out = cupsTempFile2(buf, sizeof(buf))) == NULL) { debug_printf("Unable to create temporary file!\n"); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; ppdClose(ppd); @@ -5121,6 +5161,7 @@ gboolean update_cups_queues(gpointer unused) { } if ((in = cupsFileOpen(loadedppd, "r")) == NULL) { debug_printf("Unable to open the downloaded PPD file!\n"); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; cupsFileClose(out); @@ -5323,6 +5364,7 @@ gboolean update_cups_queues(gpointer unused) { if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) { debug_printf("Unable to create/modify CUPS queue (%s)!\n", cupsLastErrorString()); + current_time = time(NULL); p->timeout = current_time + TIMEOUT_RETRY; p->no_autosave = 0; break; @@ -5442,6 +5484,27 @@ gboolean update_cups_queues(gpointer unused) { break; } + + /* Check if an HTTP timeout happened during the print queue creation + If it does - increment p->timeouted and set status to TO_BE_CREATED + because the creation can fall through the process, have state changed to + STATUS_CONFIRMED and experience the timeout */ + /* If no timeout has happened, clear p->timeouted */ + if (timeout_reached == 1) + { + fprintf(stderr, "Timeout happened during creating the queue %s, turn on DebugLogging for more info.\n", p->queue_name); + p->timeouted ++; + + debug_printf("The queue %s already timeouted %d times in a row.\n", + p->queue_name, p->timeouted); + p->status = STATUS_TO_BE_CREATED; + } + else if (p->timeouted != 0) + { + debug_printf("Creating the queue %s went smoothly after %d timeouts.\n", + p->queue_name, p->timeouted); + p->timeouted = 0; + } } log_all_printers(); @@ -7907,6 +7970,16 @@ read_configuration (const char *filename) } else debug_printf("Invalid %s value: %d\n", line, t); + } else if (!strcasecmp(line, "HttpMaxRetries") && value) { + int t = atoi(value); + if (t > 0) { + HttpMaxRetries = t; + + debug_printf("Set %s to %d retries.\n", + line, t); + } else + debug_printf("Invalid %s value: %d\n", + line, t); } else if (!strcasecmp(line, "IPBasedDeviceURIs") && value) { if (!strcasecmp(value, "IPv4") || !strcasecmp(value, "IPv4Only")) IPBasedDeviceURIs = IP_BASED_URIS_IPV4_ONLY; diff --git a/utils/cups-browsed.conf.5 b/utils/cups-browsed.conf.5 index 721f5249f..c629d1490 100644 --- a/utils/cups-browsed.conf.5 +++ b/utils/cups-browsed.conf.5 @@ -429,6 +429,18 @@ when the server does not respond. .fam T .fi +Set how many retries (N) should cups-browsed do for creating print +queues for remote printers which receive timeouts during print queue +creation. The printers which are not successfuly set up even after N +retries, are skipped until the next restart of the service. Note that +too many retries can cause high CPU load. +.PP +.nf +.fam C + HttpMaxRetries 5 + +.fam T +.fi The interval between browsing/broadcasting cycles, local and/or remote, can be adjusted with the BrowseInterval directive. .PP diff --git a/utils/cups-browsed.conf.in b/utils/cups-browsed.conf.in index 4ab7ee63e..c54ab7e82 100644 --- a/utils/cups-browsed.conf.in +++ b/utils/cups-browsed.conf.in @@ -310,6 +310,13 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@ # HttpLocalTimeout 5 # HttpRemoteTimeout 10 +# Set how many retries (N) should cups-browsed do for creating print +# queues for remote printers which receive timeouts during print queue +# creation. The printers which are not successfuly set up even after +# N retries, are skipped until the next restart of the service. Note +# that too many retries can cause high CPU load. + +# HttpMaxRetries 5 # Set OnlyUnsupportedByCUPS to "Yes" will make cups-browsed not create # local queues for remote printers for which CUPS creates queues by |