- Avoid write printcap unnecessarily (bug #290831).

This commit is contained in:
Tim Waugh 2007-09-18 08:32:42 +00:00
parent e99052e344
commit c958724e80
2 changed files with 175 additions and 1 deletions

169
cups-str2512.patch Normal file
View File

@ -0,0 +1,169 @@
diff -up cups-1.3.1/scheduler/dirsvc.c.str2512 cups-1.3.1/scheduler/dirsvc.c
--- cups-1.3.1/scheduler/dirsvc.c.str2512 2007-09-08 01:28:06.000000000 +0100
+++ cups-1.3.1/scheduler/dirsvc.c 2007-09-18 09:31:23.000000000 +0100
@@ -91,7 +91,7 @@ static void process_browse_data(const ch
ipp_pstate_t state, const char *location,
const char *info, const char *make_model,
int num_attrs, cups_option_t *attrs);
-static void process_implicit_classes(void);
+static void process_implicit_classes(int *write_printcap);
static void send_cups_browse(cupsd_printer_t *p);
#ifdef HAVE_LDAP
static void send_ldap_browse(cupsd_printer_t *p);
@@ -609,7 +609,7 @@ cupsdLoadRemoteCache(void)
* Do auto-classing if needed...
*/
- process_implicit_classes();
+ process_implicit_classes(NULL);
}
@@ -1685,7 +1685,8 @@ process_browse_data(
cups_option_t *attrs) /* I - Attributes */
{
int i; /* Looping var */
- int update; /* Update printer attributes? */
+ int update, /* Update printer attributes? */
+ write_printcap; /* Write the printcap file? */
char finaluri[HTTP_MAX_URI], /* Final URI for printer */
name[IPP_MAX_NAME], /* Name of printer */
newname[IPP_MAX_NAME], /* New name of printer */
@@ -1772,11 +1773,12 @@ process_browse_data(
* See if we already have it listed in the Printers list, and add it if not...
*/
- type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED;
- type &= ~CUPS_PRINTER_IMPLICIT;
- update = 0;
- hptr = strchr(host, '.');
- sptr = strchr(ServerName, '.');
+ type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED;
+ type &= ~CUPS_PRINTER_IMPLICIT;
+ update = 0;
+ write_printcap = 0;
+ hptr = strchr(host, '.');
+ sptr = strchr(ServerName, '.');
if (!ServerNameIsIP && sptr != NULL && hptr != NULL)
{
@@ -1899,7 +1901,8 @@ process_browse_data(
cupsdSetString(&p->device_uri, uri);
cupsdSetString(&p->hostname, host);
- update = 1;
+ update = 1;
+ write_printcap = 1;
}
}
else
@@ -2005,7 +2008,8 @@ process_browse_data(
cupsdSetString(&p->uri, uri);
cupsdSetString(&p->device_uri, uri);
- update = 1;
+ write_printcap = 1;
+ update = 1;
}
}
@@ -2064,7 +2068,8 @@ process_browse_data(
if (info && (!p->info || strcmp(p->info, info)))
{
cupsdSetString(&p->info, info);
- update = 1;
+ update = 1;
+ write_printcap = 1;
}
if (!make_model || !make_model[0])
@@ -2153,6 +2158,7 @@ process_browse_data(
if (p->type & CUPS_PRINTER_DEFAULT)
{
DefaultPrinter = p;
+ write_printcap = 1;
break;
}
}
@@ -2161,13 +2167,14 @@ process_browse_data(
* Do auto-classing if needed...
*/
- process_implicit_classes();
+ process_implicit_classes(&write_printcap);
/*
* Update the printcap file...
*/
- cupsdWritePrintcap();
+ if (write_printcap)
+ cupsdWritePrintcap();
}
@@ -2657,7 +2664,8 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
*/
static void
-process_implicit_classes(void)
+process_implicit_classes(
+ int *write_printcap) /* O - Write printcap file? */
{
int i; /* Looping var */
int update; /* Update printer attributes? */
@@ -2738,6 +2746,9 @@ process_implicit_classes(void)
update = 1;
+ if (write_printcap)
+ *write_printcap = 1;
+
cupsdLogMessage(CUPSD_LOG_DEBUG, "Added implicit class \"%s\"...",
name);
cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
diff -up cups-1.3.1/scheduler/printers.c.str2512 cups-1.3.1/scheduler/printers.c
--- cups-1.3.1/scheduler/printers.c.str2512 2007-09-17 17:06:26.000000000 +0100
+++ cups-1.3.1/scheduler/printers.c 2007-09-18 09:31:23.000000000 +0100
@@ -3045,7 +3045,8 @@ cupsdWritePrintcap(void)
* data has come from...
*/
- cupsFilePuts(fp, "# This file was automatically generated by cupsd(8) from the\n");
+ cupsFilePuts(fp,
+ "# This file was automatically generated by cupsd(8) from the\n");
cupsFilePrintf(fp, "# %s/printers.conf file. All changes to this file\n",
ServerRoot);
cupsFilePuts(fp, "# will be lost.\n");
@@ -3071,14 +3072,15 @@ cupsdWritePrintcap(void)
if (DefaultPrinter)
cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name,
- DefaultPrinter->info, ServerName, DefaultPrinter->name);
+ DefaultPrinter->info, ServerName,
+ DefaultPrinter->name);
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
if (p != DefaultPrinter)
cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info,
- ServerName, p->name);
+ ServerName, p->name);
break;
case PRINTCAP_SOLARIS:
@@ -3116,9 +3118,10 @@ cupsdWritePrintcap(void)
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
cupsFilePrintf(fp, "%s:\\\n"
- "\t:bsdaddr=%s,%s:\\\n"
- "\t:description=%s:\n",
- p->name, ServerName, p->name, p->info ? p->info : "");
+ "\t:bsdaddr=%s,%s:\\\n"
+ "\t:description=%s:\n",
+ p->name, ServerName, p->name,
+ p->info ? p->info : "");
break;
}
}

View File

@ -6,7 +6,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.3.1
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: ftp://ftp.easysw.com/pub/cups/test//cups-%{version}-source.tar.bz2
@ -37,6 +37,7 @@ Patch11: cups-paps.patch
Patch12: cups-wbuffer.patch
Patch13: cups-direct-usb.patch
Patch14: cups-lpr-help.patch
Patch15: cups-str2512.patch
Patch16: cups-pid.patch
Patch19: cups-eggcups.patch
Patch20: cups-getpass.patch
@ -146,6 +147,7 @@ lpd emulation.
%patch12 -p1 -b .wbuffer
%patch13 -p1 -b .direct-usb
%patch14 -p1 -b .lpr-help
%patch15 -p1 -b .str2512
%patch16 -p1 -b .pid
%patch19 -p1 -b .eggcups
%patch20 -p1 -b .getpass
@ -439,6 +441,9 @@ rm -rf $RPM_BUILD_ROOT
%{cups_serverbin}/daemon/cups-lpd
%changelog
* Tue Sep 18 2007 Tim Waugh <twaugh@redhat.com> 1:1.3.1-2
- Avoid write printcap unnecessarily (bug #290831).
* Mon Sep 17 2007 Tim Waugh <twaugh@redhat.com> 1:1.3.1-1
- 1.3.1.