Fixed Timeouts array comparison function (Ubuntu #860691).

This commit is contained in:
Tim Waugh 2011-10-07 12:51:17 +01:00
parent 778fcc75ef
commit 3d32f50550
2 changed files with 60 additions and 17 deletions

View File

@ -1,6 +1,6 @@
diff -up cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.0/scheduler/cupsd.h
--- cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts 2011-05-11 23:17:34.000000000 +0100
+++ cups-1.5.0/scheduler/cupsd.h 2011-08-05 15:06:13.570811440 +0100
+++ cups-1.5.0/scheduler/cupsd.h 2011-10-07 13:20:41.522867324 +0100
@@ -140,6 +140,15 @@ extern const char *cups_hstrerror(int);
typedef void (*cupsd_selfunc_t)(void *data);
@ -51,8 +51,8 @@ diff -up cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.0/scheduler/cups
/*
* End of "$Id: cupsd.h 9766 2011-05-11 22:17:34Z mike $".
diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.c
--- cups-1.5.0/scheduler/main.c.avahi-3-timeouts 2011-08-05 15:05:45.590700888 +0100
+++ cups-1.5.0/scheduler/main.c 2011-08-05 15:06:13.572811372 +0100
--- cups-1.5.0/scheduler/main.c.avahi-3-timeouts 2011-10-07 13:20:36.875954675 +0100
+++ cups-1.5.0/scheduler/main.c 2011-10-07 13:20:41.524867282 +0100
@@ -146,6 +146,10 @@ main(int argc, /* I - Number of comm
int launchd_idle_exit;
/* Idle exit on select timeout? */
@ -96,7 +96,7 @@ diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.
#ifndef __APPLE__
/*
* Update the network interfaces once a minute...
@@ -1787,6 +1809,10 @@ select_timeout(int fds) /* I - Number
@@ -1787,6 +1809,10 @@ select_timeout(int fds) /* I - Number
cupsd_job_t *job; /* Job information */
cupsd_subscription_t *sub; /* Subscription information */
const char *why; /* Debugging aid */
@ -107,7 +107,7 @@ diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.
/*
@@ -1829,6 +1855,19 @@ select_timeout(int fds) /* I - Number
@@ -1829,6 +1855,19 @@ select_timeout(int fds) /* I - Number
}
#endif /* __APPLE__ */
@ -128,8 +128,8 @@ diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.
* Check whether we are accepting new connections...
*/
diff -up cups-1.5.0/scheduler/Makefile.avahi-3-timeouts cups-1.5.0/scheduler/Makefile
--- cups-1.5.0/scheduler/Makefile.avahi-3-timeouts 2011-08-05 15:05:45.673698248 +0100
+++ cups-1.5.0/scheduler/Makefile 2011-08-05 15:06:13.569811476 +0100
--- cups-1.5.0/scheduler/Makefile.avahi-3-timeouts 2011-10-07 13:20:36.955953170 +0100
+++ cups-1.5.0/scheduler/Makefile 2011-10-07 13:20:41.521867343 +0100
@@ -39,7 +39,8 @@ CUPSDOBJS = \
server.o \
statbuf.o \
@ -141,21 +141,41 @@ diff -up cups-1.5.0/scheduler/Makefile.avahi-3-timeouts cups-1.5.0/scheduler/Mak
filter.o \
mime.o \
diff -up cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts cups-1.5.0/scheduler/timeout.c
--- cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts 2011-08-05 15:06:13.573811341 +0100
+++ cups-1.5.0/scheduler/timeout.c 2011-08-05 15:06:13.573811341 +0100
@@ -0,0 +1,195 @@
--- cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts 2011-10-07 13:20:41.525867259 +0100
+++ cups-1.5.0/scheduler/timeout.c 2011-10-07 13:20:41.525867259 +0100
@@ -0,0 +1,235 @@
+/*
+ * "$Id$"
+ *
+ * Timeout functions for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010, 2011 Red Hat, Inc.
+ * Authors:
+ * Tim Waugh <twaugh@redhat.com>
+ *
+ * Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contents:
+ *
@ -203,17 +223,37 @@ diff -up cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts cups-1.5.0/scheduler/ti
+ */
+
+static int
+compare_addrs (void *p0, void *p1)
+{
+ if (p0 == p1)
+ return (0);
+ if (p0 < p1)
+ return (-1);
+ return (1);
+}
+
+static int
+compare_timeouts (cupsd_timeout_t *p0, cupsd_timeout_t *p1)
+{
+ int addrsdiff = compare_addrs (p0, p1);
+ int tvdiff;
+
+ if (addrsdiff == 0)
+ return (0);
+
+ if (!p0->enabled || !p1->enabled)
+ {
+ if (!p0->enabled && !p1->enabled)
+ return (0);
+ return (addrsdiff);
+
+ return (p0->enabled ? -1 : 1);
+ }
+
+ return (avahi_timeval_compare (&p0->when, &p1->when));
+ tvdiff = avahi_timeval_compare (&p0->when, &p1->when);
+ if (tvdiff != 0)
+ return (tvdiff);
+
+ return (addrsdiff);
+}
+
+

View File

@ -13,7 +13,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.5.0
Release: 14%{?dist}
Release: 15%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@ -651,6 +651,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/ipptool.1.gz
%changelog
* Fri Oct 7 2011 Tim Waugh <twaugh@redhat.com> 1:1.5.0-15
- Fixed Timeouts array comparison function (Ubuntu #860691).
* Wed Oct 5 2011 Tim Waugh <twaugh@redhat.com> 1:1.5.0-14
- Handle "localhost" resolving to 127.0.0.1 on IPv6-addressed systems
(bug #737230).