- Use upstream patch to fix interrupt handling in the side-channel APIs

(rev 8896).
This commit is contained in:
Tim Waugh 2009-12-08 11:13:07 +00:00
parent 11315e1acc
commit fd5ad73b36
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,68 @@
diff -up cups-1.4.2/cups/sidechannel.c.sidechannel-intrs cups-1.4.2/cups/sidechannel.c
--- cups-1.4.2/cups/sidechannel.c.sidechannel-intrs 2009-09-23 00:20:35.000000000 +0100
+++ cups-1.4.2/cups/sidechannel.c 2009-12-08 11:08:15.297539377 +0000
@@ -116,6 +116,7 @@ cupsSideChannelRead(
char buffer[16388]; /* Message buffer */
int bytes; /* Bytes read */
int templen; /* Data length from message */
+ int nfds; /* Number of file descriptors */
#ifdef HAVE_POLL
struct pollfd pfd; /* Poll structure for poll() */
#else /* select() */
@@ -143,39 +144,31 @@ cupsSideChannelRead(
pfd.fd = CUPS_SC_FD;
pfd.events = POLLIN;
- if (timeout < 0.0)
- {
- if (poll(&pfd, 1, -1) < 1)
- return (-1);
- }
- else if (poll(&pfd, 1, (long)(timeout * 1000)) < 1)
- return (-1);
+ while ((nfds = poll(&pfd, 1,
+ timeout < 0.0 ? -1 : (long)(timeout * 1000))) < 0 &&
+ (errno == EINTR || errno == EAGAIN))
+ ;
#else /* select() */
FD_ZERO(&input_set);
FD_SET(CUPS_SC_FD, &input_set);
- if (timeout < 0.0)
- {
- if (select(CUPS_SC_FD + 1, &input_set, NULL, NULL, NULL) < 1)
- {
- DEBUG_printf(("1cupsSideChannelRead: Select error: %s", strerror(errno)));
- return (-1);
- }
- }
- else
- {
- stimeout.tv_sec = (int)timeout;
- stimeout.tv_usec = (int)(timeout * 1000000) % 1000000;
+ stimeout.tv_sec = (int)timeout;
+ stimeout.tv_usec = (int)(timeout * 1000000) % 1000000;
+
+ while ((nfds = select(CUPS_SC_FD + 1, &input_set, NULL, NULL,
+ timeout < 0.0 ? NULL : &stimeout)) < 0 &&
+ (errno == EINTR || errno == EAGAIN))
+ ;
- if (select(CUPS_SC_FD + 1, &input_set, NULL, NULL, &stimeout) < 1)
- {
- DEBUG_puts("1cupsSideChannelRead: Select timeout");
- return (-1);
- }
- }
#endif /* HAVE_POLL */
+ if (nfds < 1)
+ {
+ *status = nfds==0 ? CUPS_SC_STATUS_TIMEOUT : CUPS_SC_STATUS_IO_ERROR;
+ return (-1);
+ }
+
/*
* Read a side-channel message for the format:
*

View File

@ -63,6 +63,7 @@ Patch38: cups-str3439.patch
Patch39: cups-str3440.patch
Patch40: cups-str3442.patch
Patch41: cups-negative-snmp-string-length.patch
Patch42: cups-sidechannel-intrs.patch
Patch100: cups-lspp.patch
@ -233,6 +234,7 @@ module.
%patch39 -p1 -b .str3440
%patch40 -p1 -b .str3442
%patch41 -p1 -b .negative-snmp-string-length
%patch42 -p1 -b .sidechannel-intrs
%if %lspp
%patch100 -p1 -b .lspp
@ -524,6 +526,8 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Tue Dec 8 2009 Tim Waugh <twaugh@redhat.com> - 1:1.4.2-14
- Use upstream patch to fix interrupt handling in the side-channel
APIs (rev 8896).
- Use upstream patch to handle negative SNMP string lengths (rev 8896).
- Use upstream fix for SNMP detection (bug #542857, STR #3413).
- Use the text filter for text/css files (bug #545026, STR #3442).