apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1755758 - in /apr/apr/trunk/poll/unix: epoll.c kqueue.c poll.c port.c select.c
Date Wed, 10 Aug 2016 14:41:08 GMT
Author: ylavic
Date: Wed Aug 10 14:41:08 2016
New Revision: 1755758

URL: http://svn.apache.org/viewvc?rev=1755758&view=rev
Log:
apr_pollset_poll(): don't return a positive (nay negative in case of error)
number of descriptors/events, before the returned descriptors are actually
initialized.


Modified:
    apr/apr/trunk/poll/unix/epoll.c
    apr/apr/trunk/poll/unix/kqueue.c
    apr/apr/trunk/poll/unix/poll.c
    apr/apr/trunk/poll/unix/port.c
    apr/apr/trunk/poll/unix/select.c

Modified: apr/apr/trunk/poll/unix/epoll.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/epoll.c?rev=1755758&r1=1755757&r2=1755758&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/epoll.c (original)
+++ apr/apr/trunk/poll/unix/epoll.c Wed Aug 10 14:41:08 2016
@@ -258,14 +258,14 @@ static apr_status_t impl_pollset_poll(ap
     int ret;
     apr_status_t rv = APR_SUCCESS;
 
+    *num = 0;
+
     if (timeout > 0) {
         timeout /= 1000;
     }
 
     ret = epoll_wait(pollset->p->epoll_fd, pollset->p->pollset, pollset->nalloc,
                      timeout);
-    (*num) = ret;
-
     if (ret < 0) {
         rv = apr_get_netos_error();
     }

Modified: apr/apr/trunk/poll/unix/kqueue.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/kqueue.c?rev=1755758&r1=1755757&r2=1755758&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/kqueue.c (original)
+++ apr/apr/trunk/poll/unix/kqueue.c Wed Aug 10 14:41:08 2016
@@ -259,6 +259,8 @@ static apr_status_t impl_pollset_poll(ap
     apr_status_t rv = APR_SUCCESS;
     apr_pollfd_t fd;
 
+    *num = 0;
+
     if (timeout < 0) {
         tvptr = NULL;
     }
@@ -270,7 +272,6 @@ static apr_status_t impl_pollset_poll(ap
 
     ret = kevent(pollset->p->kqueue_fd, NULL, 0, pollset->p->ke_set,
                  pollset->p->setsize, tvptr);
-    (*num) = ret;
     if (ret < 0) {
         rv = apr_get_netos_error();
     }

Modified: apr/apr/trunk/poll/unix/poll.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/poll.c?rev=1755758&r1=1755757&r2=1755758&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/poll.c (original)
+++ apr/apr/trunk/poll/unix/poll.c Wed Aug 10 14:41:08 2016
@@ -241,10 +241,11 @@ static apr_status_t impl_pollset_poll(ap
     int ret;
     apr_status_t rv = APR_SUCCESS;
 
+    *num = 0;
+
 #ifdef WIN32
     /* WSAPoll() requires at least one socket. */
     if (pollset->nelts == 0) {
-        *num = 0;
         if (timeout > 0) {
             apr_sleep(timeout);
             return APR_TIMEUP;
@@ -261,7 +262,6 @@ static apr_status_t impl_pollset_poll(ap
     }
     ret = poll(pollset->p->pollset, pollset->nelts, timeout);
 #endif
-    *num = 0;
     if (ret < 0) {
         return apr_get_netos_error();
     }

Modified: apr/apr/trunk/poll/unix/port.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/port.c?rev=1755758&r1=1755757&r2=1755758&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/port.c (original)
+++ apr/apr/trunk/poll/unix/port.c Wed Aug 10 14:41:08 2016
@@ -360,6 +360,7 @@ static apr_status_t impl_pollset_poll(ap
     apr_status_t rv = APR_SUCCESS;
     apr_pollfd_t fp;
 
+    *num = 0;
     nget = 1;
 
     pollset_lock_rings();
@@ -403,7 +404,6 @@ static apr_status_t impl_pollset_poll(ap
        port_associate within apr_pollset_add() */
     apr_atomic_dec32(&pollset->p->waiting);
 
-    (*num) = nget;
     if (nget) {
 
         pollset_lock_rings();

Modified: apr/apr/trunk/poll/unix/select.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/select.c?rev=1755758&r1=1755757&r2=1755758&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/select.c (original)
+++ apr/apr/trunk/poll/unix/select.c Wed Aug 10 14:41:08 2016
@@ -347,13 +347,14 @@ static apr_status_t impl_pollset_poll(ap
     fd_set readset, writeset, exceptset;
     apr_status_t rv = APR_SUCCESS;
 
+    *num = 0;
+
 #ifdef WIN32
     /* On Win32, select() must be presented with at least one socket to
      * poll on, or select() will return WSAEINVAL.  So, we'll just
      * short-circuit and bail now.
      */
     if (pollset->nelts == 0) {
-        (*num) = 0;
         if (timeout > 0) {
             apr_sleep(timeout);
             return APR_TIMEUP;
@@ -385,7 +386,6 @@ static apr_status_t impl_pollset_poll(ap
         rs = select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset,
                     tvptr);
 
-    (*num) = rs;
     if (rs < 0) {
         return apr_get_netos_error();
     }



Mime
View raw message