aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-03-28 18:59:42 +0000
committerYang Tse <yangsita@gmail.com>2007-03-28 18:59:42 +0000
commit869d192ffc6b47ebc9fec75ace8fbbe2d50c5d0f (patch)
treefe9e6230f01d3d06534be51aafd5fc1c9afbd57f
parent60bc103a786be434dfe06bcbfe28fa9a4b289842 (diff)
Improve detection of socket events which allow a further recv() call
to complete with no delay and actually find out what happened with the socket. As well as detection of socket send()able condition. This also allows removal of a Cygwin specific block of code.
-rw-r--r--lib/select.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/select.c b/lib/select.c
index 2e25adede..a2e80e21c 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -206,13 +206,13 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd, int timeout_m
num = 0;
if (readfd != CURL_SOCKET_BAD) {
pfd[num].fd = readfd;
- pfd[num].events = POLLIN;
+ pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
pfd[num].revents = 0;
num++;
}
if (writefd != CURL_SOCKET_BAD) {
pfd[num].fd = writefd;
- pfd[num].events = POLLOUT;
+ pfd[num].events = POLLWRNORM|POLLOUT;
pfd[num].revents = 0;
num++;
}
@@ -233,23 +233,15 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd, int timeout_m
ret = 0;
num = 0;
if (readfd != CURL_SOCKET_BAD) {
- if (pfd[num].revents & (POLLIN|POLLHUP))
+ if (pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
ret |= CSELECT_IN;
- if (pfd[num].revents & POLLERR) {
-#ifdef __CYGWIN__
- /* Cygwin 1.5.21 needs this hack to pass test 160 */
- if (ERRNO == EINPROGRESS)
- ret |= CSELECT_IN;
- else
-#endif
- ret |= CSELECT_ERR;
- }
- num++;
+ if (pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
+ ret |= CSELECT_ERR;
}
if (writefd != CURL_SOCKET_BAD) {
- if (pfd[num].revents & POLLOUT)
+ if (pfd[num].revents & (POLLWRNORM|POLLOUT))
ret |= CSELECT_OUT;
- if (pfd[num].revents & (POLLERR|POLLHUP))
+ if (pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
ret |= CSELECT_ERR;
}
@@ -385,14 +377,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
if (ufds[i].fd == CURL_SOCKET_BAD)
continue;
VERIFY_SOCK(ufds[i].fd);
- if (ufds[i].events & (POLLIN|POLLOUT|POLLERR)) {
+ if (ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
+ POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
if (ufds[i].fd > maxfd)
maxfd = ufds[i].fd;
- if (ufds[i].events & POLLIN)
+ if (ufds[i].events & (POLLRDNORM|POLLIN))
FD_SET(ufds[i].fd, &fds_read);
- if (ufds[i].events & POLLOUT)
+ if (ufds[i].events & (POLLWRNORM|POLLOUT))
FD_SET(ufds[i].fd, &fds_write);
- if (ufds[i].events & POLLERR)
+ if (ufds[i].events & (POLLRDBAND|POLLPRI))
FD_SET(ufds[i].fd, &fds_err);
}
}
@@ -424,7 +417,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
if (FD_ISSET(ufds[i].fd, &fds_write))
ufds[i].revents |= POLLOUT;
if (FD_ISSET(ufds[i].fd, &fds_err))
- ufds[i].revents |= POLLERR;
+ ufds[i].revents |= POLLPRI;
if (ufds[i].revents != 0)
r++;
}