summaryrefslogtreecommitdiff
path: root/poll
diff options
context:
space:
mode:
authorbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2002-08-11 20:53:43 +0000
committerbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2002-08-11 20:53:43 +0000
commitfeff4e60c7f4590fb6aa889789974deebe41e221 (patch)
tree3f269ca2b2aaf872073525d470ecfc3b07f1fcb1 /poll
parent402c90f97548053a0e00fb6aa4fa2887668e0a01 (diff)
downloadlibapr-feff4e60c7f4590fb6aa889789974deebe41e221.tar.gz
Cleaned up the code for handling invalid descriptor types in apr_poll
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63805 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll')
-rw-r--r--poll/unix/poll.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index da79e4b95..82b049902 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -117,7 +117,7 @@ static apr_int16_t get_revent(apr_int16_t event)
APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
apr_int32_t *nsds, apr_interval_time_t timeout)
{
- int i;
+ int i, num_to_poll;
#ifdef HAVE_VLA
/* XXX: I trust that this is a segv when insufficient stack exists? */
struct pollfd pollset[num];
@@ -151,18 +151,18 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
else if (aprset[i].desc_type == APR_POLL_FILE) {
pollset[i].fd = aprset[i].desc.f->filedes;
}
- else if (aprset[i].desc_type == APR_NO_DESC) {
- num = i + 1;
+ else {
break;
}
pollset[i].events = get_event(aprset[i].reqevents);
}
+ num_to_poll = i;
if (timeout > 0) {
timeout /= 1000; /* convert microseconds to milliseconds */
}
- i = poll(pollset, num, timeout);
+ i = poll(pollset, num_to_poll, timeout);
(*nsds) = i;
for (i = 0; i < num; i++) {
@@ -241,8 +241,7 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, apr_int32_t *n
#endif /* APR_FILES_AS_SOCKETS */
}
- else if (aprset[i].desc_type == APR_NO_DESC) {
- num = i + 1;
+ else {
break;
}
if (aprset[i].reqevents & APR_POLLIN) {
@@ -287,13 +286,16 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, apr_int32_t *n
if (aprset[i].desc_type == APR_POLL_SOCKET) {
fd = aprset[i].desc.s->socketdes;
}
- else {
+ else if (aprset[i].desc_type == APR_POLL_FILE) {
#if !APR_FILES_AS_SOCKETS
return APR_EBADF;
#else
fd = aprset[i].desc.f->filedes;
#endif
}
+ else {
+ break;
+ }
aprset[i].rtnevents = 0;
if (FD_ISSET(fd, &readset)) {
aprset[i].rtnevents |= APR_POLLIN;