From 746dd9cf56e9522ca51c4cc669fc65b46e2d4866 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mar 16 2015 17:24:51 +0000 Subject: Avoid busy loop in cupsd (bug #1179596). Resolves: rhbz#1179596 --- diff --git a/cups-busy-loop.patch b/cups-busy-loop.patch new file mode 100644 index 0000000..8c95546 --- /dev/null +++ b/cups-busy-loop.patch @@ -0,0 +1,34 @@ +diff -up cups-2.0.2/scheduler/client.c.busy-loop cups-2.0.2/scheduler/client.c +--- cups-2.0.2/scheduler/client.c.busy-loop 2014-08-28 16:37:22.000000000 +0100 ++++ cups-2.0.2/scheduler/client.c 2015-03-16 17:24:32.506232983 +0000 +@@ -585,6 +585,17 @@ cupsdReadClient(cupsd_client_t *con) /* + * connection and we need to shut it down... + */ + ++ if (!httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1) ++ { ++ /* ++ * Connection closed... ++ */ ++ ++ cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on EOF."); ++ cupsdCloseClient(con); ++ return; ++ } ++ + cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on unexpected HTTP read state %s.", + httpStateString(httpGetState(con->http))); + cupsdCloseClient(con); +@@ -1979,12 +1990,6 @@ cupsdReadClient(cupsd_client_t *con) /* + + if (httpGetState(con->http) == HTTP_STATE_POST_SEND) + { +- /* +- * Don't listen for activity until we decide to do something with this... +- */ +- +- cupsdAddSelect(httpGetFd(con->http), NULL, NULL, con); +- + if (con->file >= 0) + { + fstat(con->file, &filestats); diff --git a/cups.spec b/cups.spec index 5a59c31..e6bd208 100644 --- a/cups.spec +++ b/cups.spec @@ -11,7 +11,7 @@ Summary: CUPS printing system Name: cups Epoch: 1 Version: 2.0.2 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Url: http://www.cups.org/ Source0: http://www.cups.org/software/%{version}/cups-%{version}-source.tar.bz2 @@ -26,6 +26,7 @@ Source8: macros.cups Patch1: cups-no-gzip-man.patch Patch2: cups-system-auth.patch Patch3: cups-multilib.patch +Patch4: cups-busy-loop.patch Patch5: cups-banners.patch Patch6: cups-serverbin-compat.patch Patch7: cups-no-export-ssllibs.patch @@ -189,6 +190,9 @@ Sends IPP requests to the specified URI and tests and/or displays the results. %patch2 -p1 -b .system-auth # Prevent multilib conflict in cups-config script. %patch3 -p1 -b .multilib +# Avoid busy loop in cupsd when connection is closed after request +# sent (bug #1179596). +%patch4 -p1 -b .busy-loop # Ignore rpm save/new files in the banners directory. %patch5 -p1 -b .banners # Use compatibility fallback path for ServerBin. @@ -296,9 +300,6 @@ export CFLAGS="$RPM_OPT_FLAGS -fstack-protector-all -DLDAP_DEPRECATED=1" --with-xinetd=no \ localedir=%{_datadir}/locale -# Avoid epoll for the moment (bug #1179596). -sed -i -e 's,\(define HAVE_EPOLL 1\),undef HAVE_EPOLL,' config.h - # If we got this far, all prerequisite libraries must be here. make %{?_smp_mflags} @@ -608,8 +609,9 @@ rm -f %{cups_serverbin}/backend/smb %{_mandir}/man5/ipptoolfile.5.gz %changelog -* Sun Mar 15 2015 Tim Waugh - 1:2.0.2-4 -- Avoid epoll for the moment (bug #1179596). +* Mon Mar 16 2015 Tim Waugh - 1:2.0.2-5 +- Avoid busy loop in cupsd when connection is closed after request + sent (bug #1179596). * Mon Feb 16 2015 Jiri Popelka - 1:2.0.2-2 - Fixed multilib.patch to check for gnutls instead of openssl.