Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 47778 invoked by uid 500); 11 Aug 2002 20:53:44 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 47767 invoked from network); 11 Aug 2002 20:53:44 -0000 Date: 11 Aug 2002 20:53:43 -0000 Message-ID: <20020811205343.17320.qmail@icarus.apache.org> From: brianp@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/poll/unix poll.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N brianp 2002/08/11 13:53:43 Modified: poll/unix poll.c Log: Cleaned up the code for handling invalid descriptor types in apr_poll Revision Changes Path 1.29 +9 -7 apr/poll/unix/poll.c Index: poll.c =================================================================== RCS file: /home/cvs/apr/poll/unix/poll.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- poll.c 7 Aug 2002 00:06:12 -0000 1.28 +++ poll.c 11 Aug 2002 20:53:43 -0000 1.29 @@ -117,7 +117,7 @@ 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 @@ 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 @@ #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,12 +286,15 @@ 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)) {