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? S: ----------------------------------------------------------------------
This commit is contained in:
parent
246ea56eab
commit
0e26355348
10
CHANGES
10
CHANGES
@ -7,6 +7,16 @@
|
|||||||
Changelog
|
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)
|
Daniel (11 January 2005)
|
||||||
- Dan Torop cleaned up a few no longer used variables from David Phillips'
|
- Dan Torop cleaned up a few no longer used variables from David Phillips'
|
||||||
select() overhaul fix.
|
select() overhaul fix.
|
||||||
|
@ -16,6 +16,7 @@ This release includes the following changes:
|
|||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
o re-invoke some system calls on EINTR
|
||||||
o duplicate Host: when failed connection re-use
|
o duplicate Host: when failed connection re-use
|
||||||
o SOCKS5 version check
|
o SOCKS5 version check
|
||||||
o memory problem with cleaning up multi interface
|
o memory problem with cleaning up multi interface
|
||||||
@ -36,6 +37,7 @@ advice from friends like these:
|
|||||||
|
|
||||||
Dan Fandrich, Peter Pentchev, Marcin Konicki, Rune Kleveland, David Shaw,
|
Dan Fandrich, Peter Pentchev, Marcin Konicki, Rune Kleveland, David Shaw,
|
||||||
Werner Koch, Gisle Vanem, Alex Neblett, Kai Sommerfeld, Marty Kuhrt,
|
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)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
17
lib/select.c
17
lib/select.c
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -80,7 +82,9 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
r = poll(pfd, num, timeout_ms);
|
r = poll(pfd, num, timeout_ms);
|
||||||
|
} while((r == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -142,7 +146,9 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
|
|||||||
maxfd = writefd;
|
maxfd = writefd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
|
r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout);
|
||||||
|
} while((r == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -179,8 +185,11 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
|
|||||||
*/
|
*/
|
||||||
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
||||||
{
|
{
|
||||||
|
int r;
|
||||||
#ifdef HAVE_POLL_FINE
|
#ifdef HAVE_POLL_FINE
|
||||||
return poll(ufds, nfds, timeout_ms);
|
do {
|
||||||
|
r = poll(ufds, nfds, timeout_ms);
|
||||||
|
} while((r == -1) && (errno == EINTR));
|
||||||
#else
|
#else
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
struct timeval *ptimeout;
|
struct timeval *ptimeout;
|
||||||
@ -188,7 +197,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
fd_set fds_write;
|
fd_set fds_write;
|
||||||
fd_set fds_err;
|
fd_set fds_err;
|
||||||
curl_socket_t maxfd;
|
curl_socket_t maxfd;
|
||||||
int r;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
FD_ZERO(&fds_read);
|
FD_ZERO(&fds_read);
|
||||||
@ -223,7 +231,9 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
ptimeout = &timeout;
|
ptimeout = &timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
||||||
|
} while((r == -1) && (errno == EINTR));
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -244,7 +254,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
if (ufds[i].revents != 0)
|
if (ufds[i].revents != 0)
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
|
||||||
#endif
|
#endif
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user