apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r348499 - in /apr/apr/trunk: CHANGES poll/unix/select.c test/testpoll.c
Date Wed, 23 Nov 2005 17:38:58 GMT
Author: brianp
Date: Wed Nov 23 09:38:47 2005
New Revision: 348499

URL: http://svn.apache.org/viewcvs?rev=348499&view=rev
Log:
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.
Submitted by: Dror Shilo <Dror.Shilo@ericom.com>, Gerry <gerry@everythingsucks.co.uk>
Reviewed by: Brian Pane

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/poll/unix/select.c
    apr/apr/trunk/test/testpoll.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?rev=348499&r1=348498&r2=348499&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Wed Nov 23 09:38:47 2005
@@ -1,5 +1,10 @@
 Changes for APR 1.3.0
 
+  *) 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>]
+
   *) Add APR_POLLSET_NOCOPY option to apr_pollset API to eliminate
      O(n)-time lookup in apr_pollset_remove() (currently implemented
      only for epoll).  [Brian Pane]

Modified: apr/apr/trunk/poll/unix/select.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/poll/unix/select.c?rev=348499&r1=348498&r2=348499&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/select.c (original)
+++ apr/apr/trunk/poll/unix/select.c Wed Nov 23 09:38:47 2005
@@ -395,6 +395,7 @@
             j++;
         }
     }
+    (*num) = j;
 
     if (descriptors)
         *descriptors = pollset->result_set;

Modified: apr/apr/trunk/test/testpoll.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/test/testpoll.c?rev=348499&r1=348498&r2=348499&view=diff
==============================================================================
--- apr/apr/trunk/test/testpoll.c (original)
+++ apr/apr/trunk/test/testpoll.c Wed Nov 23 09:38:47 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