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