apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r349169 - in /apr/apr/branches/1.2.x: CHANGES poll/unix/select.c test/testpoll.c
Date Sun, 27 Nov 2005 02:11:45 GMT
Author: brianp
Date: Sat Nov 26 18:11:42 2005
New Revision: 349169

URL: http://svn.apache.org/viewcvs?rev=349169&view=rev
Log:
Properly compute number of signalled descriptors in apr_poll()
and apr_pollset_poll() if one or more of them are both readable
and writable.  [Backport of svn revisions 348499 and 349070
from APR development trunk]

Modified:
    apr/apr/branches/1.2.x/CHANGES
    apr/apr/branches/1.2.x/poll/unix/select.c
    apr/apr/branches/1.2.x/test/testpoll.c

Modified: apr/apr/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/CHANGES?rev=349169&r1=349168&r2=349169&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/CHANGES (original)
+++ apr/apr/branches/1.2.x/CHANGES Sat Nov 26 18:11:42 2005
@@ -1,5 +1,10 @@
 Changes for APR 1.2.3-dev
 
+  *) Bugfix for apr_pollset_poll() on systems that implement pollsets
+     using select(2): properly compute the number of signalled desciptors
+     when one or more of them are both readable and writable.
+     [Dror Shilo <Dror.Shilo ericom.com>, Gerry <gerry everythingsucks.co.uk>]
+
   *) Fix apr_file_seek() to catch write failures when flushing
      pending writes for a buffered file.  [Joe Orton]
 

Modified: apr/apr/branches/1.2.x/poll/unix/select.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/poll/unix/select.c?rev=349169&r1=349168&r2=349169&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/poll/unix/select.c (original)
+++ apr/apr/branches/1.2.x/poll/unix/select.c Sat Nov 26 18:11:42 2005
@@ -131,6 +131,7 @@
         return apr_get_netos_error();
     }
 
+    (*nsds) = 0;
     for (i = 0; i < num; i++) {
         apr_os_sock_t fd;
 
@@ -156,6 +157,9 @@
         if (FD_ISSET(fd, &exceptset)) {
             aprset[i].rtnevents |= APR_POLLERR;
         }
+        if (aprset[i].rtnevents) {
+            (*nsds)++;
+        }
     }
 
     return APR_SUCCESS;
@@ -395,6 +399,7 @@
             j++;
         }
     }
+    (*num) = j;
 
     if (descriptors)
         *descriptors = pollset->result_set;

Modified: apr/apr/branches/1.2.x/test/testpoll.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/test/testpoll.c?rev=349169&r1=349168&r2=349169&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/testpoll.c (original)
+++ apr/apr/branches/1.2.x/test/testpoll.c Sat Nov 26 18:11:42 2005
@@ -290,6 +290,43 @@
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
 }
 
+static void multi_event_pollset(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_pollfd_t socket_pollfd;
+    int lrv;
+    const apr_pollfd_t *descs = NULL;
+
+    ABTS_PTR_NOTNULL(tc, s[0]);
+    socket_pollfd.desc_type = APR_POLL_SOCKET;
+    socket_pollfd.reqevents = APR_POLLIN | APR_POLLOUT;
+    socket_pollfd.desc.s = s[0];
+    socket_pollfd.client_data = s[0];
+    rv = apr_pollset_add(pollset, &socket_pollfd);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    send_msg(s, sa, 0, tc);
+
+    rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
+    ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv));
+    ABTS_INT_EQUAL(tc, 1, lrv);
+    ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s);
+    ABTS_INT_EQUAL(tc, APR_POLLIN | APR_POLLOUT, descs[0].rtnevents);
+    ABTS_PTR_EQUAL(tc, s[0],  descs[0].client_data);
+
+    recv_msg(s, 0, p, tc);
+
+    rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
+    ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv));
+    ABTS_INT_EQUAL(tc, 1, lrv);
+    ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s);
+    ABTS_INT_EQUAL(tc, APR_POLLOUT, descs[0].rtnevents);
+    ABTS_PTR_EQUAL(tc, s[0],  descs[0].client_data);
+
+    rv = apr_pollset_remove(pollset, &socket_pollfd);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+}
+                         
 static void add_sockets_pollset(abts_case *tc, void *data)
 {
     apr_status_t rv;
@@ -520,6 +557,7 @@
 #endif
 
     abts_run_test(suite, setup_pollset, NULL);
+    abts_run_test(suite, multi_event_pollset, NULL);
     abts_run_test(suite, add_sockets_pollset, NULL);
     abts_run_test(suite, nomessage_pollset, NULL);
     abts_run_test(suite, send0_pollset, NULL);



Mime
View raw message