Changelog
+Daniel (13 January 2005)
+- Inspired by Martijn Koster's patch and example source at
+ http://www.greenhills.co.uk/mak/gentoo/curl-eintr-bug.c, I now made the
+ select() and poll() calls properly loop if they return -1 and errno is
+ EINTR. glibc docs for this is found here:
+ http://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html
+
+ This last link says BSD doesn't have this "effect". Will there be a problem
+ if we do this unconditionally?
+
Daniel (11 January 2005)
- Dan Torop cleaned up a few no longer used variables from David Phillips'
select() overhaul fix.
This release includes the following bugfixes:
+ o re-invoke some system calls on EINTR
o duplicate Host: when failed connection re-use
o SOCKS5 version check
o memory problem with cleaning up multi interface
Dan Fandrich, Peter Pentchev, Marcin Konicki, Rune Kleveland, David Shaw,
Werner Koch, Gisle Vanem, Alex Neblett, Kai Sommerfeld, Marty Kuhrt,
- Hzhijun, Pavel Orehov, Bruce Mitchener, Cyrill Osterwalder, Dan Torop
+ Hzhijun, Pavel Orehov, Bruce Mitchener, Cyrill Osterwalder, Dan Torop,
+ Martijn Koster
Thanks! (and sorry if I forgot to mention someone)
#include "setup.h"
+#include <errno.h>
+
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
num++;
}
- r = poll(pfd, num, timeout_ms);
+ do {
+ r = poll(pfd, num, timeout_ms);
+ } while((r == -1) && (errno == EINTR));
if (r < 0)
return -1;
maxfd = writefd;
}
- r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
+ do {
+ r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
+ } while((r == -1) && (errno == EINTR));
if (r < 0)
return -1;
*/
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
{
+ int r;
#ifdef HAVE_POLL_FINE
- return poll(ufds, nfds, timeout_ms);
+ do {
+ r = poll(ufds, nfds, timeout_ms);
+ } while((r == -1) && (errno == EINTR));
#else
struct timeval timeout;
struct timeval *ptimeout;
fd_set fds_write;
fd_set fds_err;
curl_socket_t maxfd;
- int r;
unsigned int i;
FD_ZERO(&fds_read);
ptimeout = &timeout;
}
- r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
+ do {
+ r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
+ } while((r == -1) && (errno == EINTR));
if (r < 0)
return -1;
if (ufds[i].revents != 0)
r++;
}
-
- return r;
#endif
+ return r;
}