You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2016/03/25 02:19:34 UTC

svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Author: minfrin
Date: Fri Mar 25 01:19:34 2016
New Revision: 1736521

URL: http://svn.apache.org/viewvc?rev=1736521&view=rev
Log:
Add apr_pollcb_wakeup(), with similar behavior to
apr_pollset_wakeup(). Add apr_pollcb_method_name(), with similar
behavior to apr_pollset_method_name().

Added:
    apr/apr/branches/1.6.x/poll/unix/wakeup.c
      - copied, changed from r899905, apr/apr/trunk/poll/unix/wakeup.c
Modified:
    apr/apr/branches/1.6.x/   (props changed)
    apr/apr/branches/1.6.x/CHANGES
    apr/apr/branches/1.6.x/include/apr_poll.h
    apr/apr/branches/1.6.x/include/arch/unix/apr_arch_poll_private.h
    apr/apr/branches/1.6.x/poll/unix/epoll.c
    apr/apr/branches/1.6.x/poll/unix/kqueue.c
    apr/apr/branches/1.6.x/poll/unix/poll.c
    apr/apr/branches/1.6.x/poll/unix/pollcb.c
    apr/apr/branches/1.6.x/poll/unix/pollset.c
    apr/apr/branches/1.6.x/poll/unix/port.c
    apr/apr/branches/1.6.x/poll/unix/select.c
    apr/apr/branches/1.6.x/test/testpoll.c

Propchange: apr/apr/branches/1.6.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 25 01:19:34 2016
@@ -1,4 +1,4 @@
 /apr/apr/branches/1.4.x:1003369,1101301
-/apr/apr/trunk:733052,739635,741862,741866-741867,741869,741871,745763-745764,746310,747990,748080,748361,748371,748565,748888,748902,748988,749810,760443,767895,775683,782838,783398,783958,784633,784773,788588,789050,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,832904,835607,888669,892028,892159,892435,892909,896382,896653,908427,910419,910597,917819,917837-917838,925965,929796,930508,931973,951771,960665,960671,979891,983618,989450,990435,1003338,1044440,1044447,1055657,1072165,1078845,1081462,1081495,1083038,1083242,1084662,1086695,1088023,1089031,1089129,1089438,1099348,1103310,1183683,1183685-1183686,1183688,1183693,1183698,1213382,1235047,1236970,1237078,1237507,1240472,1340286,1340288,1340470,1341193,1341196,1343233,1343243,1367050,1368819,1370494,1372018,1372022,1372093,1372849,1376957,1384764,1389077,1400200,1402868,1405985,1406690,1420106,1420109,1425356,1428809,1438940,1438957-1438959,1442903,1449568,1456418,1459
 994,1460179-1460180,1460241,1460399,1460405,1462738,1462813,1470186,1470348,1475509,1478905,1480067,1481262,1481265,1484271,1487796,1489517,1496407,1502804,1510354,1516261,1523384,1523479,1523484,1523505,1523521,1523604,1523613,1523615,1523844-1523845,1523853,1524014,1524031,1528797,1528809,1529488,1529495,1529515,1529521,1529668,1530786,1530800,1530988,1531554,1531768,1531884,1532022,1533104,1533111,1533979,1535027,1535157,1536744,1538171,1539374,1539389,1539455,1539603,1541054,1541061,1541486,1541655,1541666,1541744,1542601,1542779,1543033,1543056,1548575,1550907,1551650,1551659,1558905,1559382,1559873,1559975,1561040,1561260,1561265,1561321,1561347,1561356,1561361,1561394,1561555,1571894,1575509,1578420,1587045,1587063,1587543,1587545,1588878,1588937,1593611,1593614-1593615,1593680,1594684,1594708,1595549,1597797,1597803,1604590,1604596,1604598,1605104,1610854,1611023,1611107,1611110,1611117,1611120,1611125,1611184,1611193,1611466,1611515,1611517,1625173,1626564,1634615,1642159,1
 648830,1664406,1664447,1664451,1664471,1664769-1664770,1664775,1664904,1664911,1664958,1666341,1666411,1666458,1666611,1667420-1667421,1667423,1667900-1667901,1667903,1667914-1667916,1667962,1669077,1671292,1671329,1671356,1671389,1671513-1671514,1671957,1672354,1672366,1672495,1672575,1675644,1675656,1675668,1676013,1685929,1696140,1696767,1722547,1722557,1726928,1727020,1727160,1727175,1727199,1728957,1732582,1733451,1733594
+/apr/apr/trunk:733052,739635,741862,741866-741867,741869,741871,745763-745764,746310,747990,748080,748361,748371,748565,748888,748902,748988,749810,760443,767895,775683,782838,783398,783958,784633,784773,788588,789050,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,832904,835607,888669,892028,892159,892435,892909,896382,896653,899905,902090,908427,910419,910597,917819,917837-917838,925965,929796,930508,931973,951771,960665,960671,979891,983618,989450,990435,1003338,1044440,1044447,1055657,1072165,1078845,1081462,1081495,1083038,1083242,1084662,1086695,1088023,1089031,1089129,1089438,1099348,1103310,1183683,1183685-1183686,1183688,1183693,1183698,1213382,1235047,1236970,1237078,1237507,1240472,1340286,1340288,1340470,1341193,1341196,1343233,1343243,1367050,1368819,1370494,1372018,1372022,1372093,1372849,1376957,1384764,1389077,1400200,1402868,1405985,1406690,1420106,1420109,1425356,1428809,1438940,1438957-1438959,1442903,144956
 8,1456418,1459994,1460179-1460180,1460241,1460399,1460405,1462738,1462813,1470186,1470348,1475509,1478905,1480067,1481262,1481265,1484271,1487796,1489517,1496407,1502804,1510354,1516261,1523384,1523479,1523484,1523505,1523521,1523604,1523613,1523615,1523844-1523845,1523853,1524014,1524031,1528797,1528809,1529488,1529495,1529515,1529521,1529668,1530786,1530800,1530988,1531554,1531768,1531884,1532022,1533104,1533111,1533979,1535027,1535157,1536744,1538171,1539374,1539389,1539455,1539603,1541054,1541061,1541486,1541655,1541666,1541744,1542601,1542779,1543033,1543056,1548575,1550907,1551650,1551659,1558905,1559382,1559873,1559975,1561040,1561260,1561265,1561321,1561347,1561356,1561361,1561394,1561555,1571894,1575509,1578420,1587045,1587063,1587543,1587545,1588878,1588937,1593611,1593614-1593615,1593680,1594684,1594708,1595549,1597797,1597803,1604590,1604596,1604598,1605104,1610854,1611023,1611107,1611110,1611117,1611120,1611125,1611184,1611193,1611466,1611515,1611517,1625173,1626564,163
 4615,1642159,1648830,1664406,1664447,1664451,1664471,1664769-1664770,1664775,1664904,1664911,1664958,1666341,1666411,1666458,1666611,1667420-1667421,1667423,1667900-1667901,1667903,1667914-1667916,1667962,1669077,1671292,1671329,1671356,1671389,1671513-1671514,1671957,1672354,1672366,1672495,1672575,1675644,1675656,1675668,1676013,1685929,1696140,1696767,1722547,1722557,1726928,1727020,1727160,1727175,1727199,1728957,1732582,1733451,1733594
 /apr/apr/trunk/test/testnames.c:1460405
 /httpd/httpd/trunk:1604590

Modified: apr/apr/branches/1.6.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/CHANGES?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.6.x/CHANGES [utf-8] Fri Mar 25 01:19:34 2016
@@ -1,6 +1,11 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.6.0
 
+  *) Add apr_pollcb_wakeup(), with similar behavior to
+     apr_pollset_wakeup(). Add apr_pollcb_method_name(), with similar 
+     behavior to apr_pollset_method_name().
+     [Neil Conway <nrc cs berkeley edu>, Jeff Trawick]
+
   *) apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when
      overlapping tables. [Graham Leggett]
 

Modified: apr/apr/branches/1.6.x/include/apr_poll.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/include/apr_poll.h?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/include/apr_poll.h (original)
+++ apr/apr/branches/1.6.x/include/apr_poll.h Fri Mar 25 01:19:34 2016
@@ -66,7 +66,7 @@ extern "C" {
                                       * are not copied
                                       */
 #define APR_POLLSET_WAKEABLE   0x004 /**< Poll operations are interruptable by
-                                      * apr_pollset_wakeup()
+                                      * apr_pollset_wakeup() or apr_pollcb_wakeup()
                                       */
 #define APR_POLLSET_NODEFAULT  0x010 /**< Do not try to use the default method if
                                       * the specified non-default method cannot be
@@ -323,8 +323,12 @@ typedef struct apr_pollcb_t apr_pollcb_t
  * @param p The pool from which to allocate the pollcb
  * @param flags Optional flags to modify the operation of the pollcb.
  *
+ * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollcb is
+ *         created with an additional internal pipe object used for the
+ *         apr_pollcb_wakeup() call. The actual size of pollcb is
+ *         in that case @a size + 1.
  * @remark Pollcb is only supported on some platforms; the apr_pollcb_create()
- * call will fail with APR_ENOTIMPL on platforms where it is not supported.
+ *         call will fail with APR_ENOTIMPL on platforms where it is not supported.
  */
 APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb,
                                             apr_uint32_t size,
@@ -341,8 +345,12 @@ APR_DECLARE(apr_status_t) apr_pollcb_cre
  *         method cannot be used, the default method will be used unless the
  *         APR_POLLSET_NODEFAULT flag has been specified.
  *
+ * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollcb is
+ *         created with an additional internal pipe object used for the
+ *         apr_pollcb_wakeup() call. The actual size of pollcb is
+ *         in that case @a size + 1.
  * @remark Pollcb is only supported on some platforms; the apr_pollcb_create_ex()
- * call will fail with APR_ENOTIMPL on platforms where it is not supported.
+ *         call will fail with APR_ENOTIMPL on platforms where it is not supported.
  */
 APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **pollcb,
                                                apr_uint32_t size,
@@ -373,6 +381,7 @@ APR_DECLARE(apr_status_t) apr_pollcb_add
  * Remove a descriptor from a pollcb
  * @param pollcb The pollcb from which to remove the descriptor
  * @param descriptor The descriptor to remove
+ * @remark If the descriptor is not found, APR_NOTFOUND is returned.
  * @remark apr_pollcb_remove() cannot be used to remove a subset of requested
  *         events for a descriptor.  The reqevents field in the apr_pollfd_t
  *         parameter must contain the same value when removing as when adding.
@@ -380,11 +389,14 @@ APR_DECLARE(apr_status_t) apr_pollcb_add
 APR_DECLARE(apr_status_t) apr_pollcb_remove(apr_pollcb_t *pollcb,
                                             apr_pollfd_t *descriptor);
 
-/** Function prototype for pollcb handlers 
+/**
+ * Function prototype for pollcb handlers 
  * @param baton Opaque baton passed into apr_pollcb_poll()
- * @param descriptor Contains the notification for an active descriptor, 
- *                   the rtnevents member contains what events were triggered
+ * @param descriptor Contains the notification for an active descriptor. 
+ *                   The @a rtnevents member describes which events were triggered
  *                   for this descriptor.
+ * @remark If the pollcb handler does not return APR_SUCCESS, the apr_pollcb_poll()
+ *         call returns with the handler's return value.
  */
 typedef apr_status_t (*apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor);
 
@@ -395,17 +407,34 @@ typedef apr_status_t (*apr_pollcb_cb_t)(
  *                maximum, not a minimum.  If a descriptor is signalled, the
  *                function will return before this time.  If timeout is
  *                negative, the function will block until a descriptor is
- *                signalled.
+ *                signalled or until apr_pollcb_wakeup() has been called.
  * @param func Callback function to call for each active descriptor.
  * @param baton Opaque baton passed to the callback function.
  * @remark Multiple signalled conditions for the same descriptor may be reported
  *         in one or more calls to the callback function, depending on the
  *         implementation.
+ * @remark APR_EINTR will be returned if the pollset has been created with
+ *         APR_POLLSET_WAKEABLE and apr_pollcb_wakeup() has been called while
+ *         waiting for activity.
  */
 APR_DECLARE(apr_status_t) apr_pollcb_poll(apr_pollcb_t *pollcb,
                                           apr_interval_time_t timeout,
                                           apr_pollcb_cb_t func,
-                                          void *baton); 
+                                          void *baton);
+
+/**
+ * Interrupt the blocked apr_pollcb_poll() call.
+ * @param pollcb The pollcb to use
+ * @remark If the pollcb was not created with APR_POLLSET_WAKEABLE the
+ *         return value is APR_EINIT.
+ */
+APR_DECLARE(apr_status_t) apr_pollcb_wakeup(apr_pollcb_t *pollcb);
+
+/**
+ * Return a printable representation of the pollcb method.
+ * @param pollcb The pollcb to use
+ */
+APR_DECLARE(const char *) apr_pollcb_method_name(apr_pollcb_t *pollcb);
 
 /** @} */
 

Modified: apr/apr/branches/1.6.x/include/arch/unix/apr_arch_poll_private.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/include/arch/unix/apr_arch_poll_private.h?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/include/arch/unix/apr_arch_poll_private.h (original)
+++ apr/apr/branches/1.6.x/include/arch/unix/apr_arch_poll_private.h Fri Mar 25 01:19:34 2016
@@ -149,6 +149,10 @@ struct apr_pollcb_t {
     apr_pool_t *pool;
     apr_uint32_t nelts;
     apr_uint32_t nalloc;
+    apr_uint32_t flags;
+    /* Pipe descriptors used for wakeup */
+    apr_file_t *wakeup_pipe[2];
+    apr_pollfd_t wakeup_pfd;
     int fd;
     apr_pollcb_pset pollset;
     apr_pollfd_t **copyset;
@@ -169,10 +173,17 @@ struct apr_pollcb_provider_t {
     apr_status_t (*add)(apr_pollcb_t *, apr_pollfd_t *);
     apr_status_t (*remove)(apr_pollcb_t *, apr_pollfd_t *);
     apr_status_t (*poll)(apr_pollcb_t *, apr_interval_time_t, apr_pollcb_cb_t, void *);
+    apr_status_t (*cleanup)(apr_pollcb_t *);
     const char *name;
 };
 
-/* Private functions */
-void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset);
+/* 
+ * Private functions used for the implementation of both apr_pollcb_* and 
+ * apr_pollset_*
+ */
+apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd, 
+                                         apr_file_t **wakeup_pipe);
+apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe);
+void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe);
 
 #endif /* APR_ARCH_POLL_PRIVATE_H */

Modified: apr/apr/branches/1.6.x/poll/unix/epoll.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/epoll.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/epoll.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/epoll.c Fri Mar 25 01:19:34 2016
@@ -157,7 +157,7 @@ static apr_status_t impl_pollset_add(apr
                                      const apr_pollfd_t *descriptor)
 {
     struct epoll_event ev = {0};
-    int ret = -1;
+    int ret;
     pfd_elem_t *elem = NULL;
     apr_status_t rv = APR_SUCCESS;
 
@@ -214,7 +214,7 @@ static apr_status_t impl_pollset_remove(
     struct epoll_event ev = {0}; /* ignored, but must be passed with
                                   * kernel < 2.6.9
                                   */
-    int ret = -1;
+    int ret;
 
     if (descriptor->desc_type == APR_POLL_SOCKET) {
         ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_DEL,
@@ -255,9 +255,8 @@ static apr_status_t impl_pollset_poll(ap
                                            apr_int32_t *num,
                                            const apr_pollfd_t **descriptors)
 {
-    int ret, i, j;
+    int ret;
     apr_status_t rv = APR_SUCCESS;
-    apr_pollfd_t *fdptr;
 
     if (timeout > 0) {
         timeout /= 1000;
@@ -274,6 +273,9 @@ static apr_status_t impl_pollset_poll(ap
         rv = APR_TIMEUP;
     }
     else {
+        int i, j;
+        apr_pollfd_t *fdptr;
+
         for (i = 0, j = 0; i < ret; i++) {
             if (pollset->flags & APR_POLLSET_NOCOPY) {
                 fdptr = (apr_pollfd_t *)(pollset->p->pollset[i].data.ptr);
@@ -287,7 +289,7 @@ static apr_status_t impl_pollset_poll(ap
             if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
                 fdptr->desc_type == APR_POLL_FILE &&
                 fdptr->desc.f == pollset->wakeup_pipe[0]) {
-                apr_pollset_drain_wakeup_pipe(pollset);
+                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
                 rv = APR_EINTR;
             }
             else {
@@ -329,9 +331,8 @@ static apr_pollset_provider_t impl = {
 
 apr_pollset_provider_t *apr_pollset_provider_epoll = &impl;
 
-static apr_status_t cb_cleanup(void *p_)
+static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
-    apr_pollcb_t *pollcb = (apr_pollcb_t *) p_;
     close(pollcb->fd);
     return APR_SUCCESS;
 }
@@ -377,7 +378,6 @@ static apr_status_t impl_pollcb_create(a
     
     pollcb->fd = fd;
     pollcb->pollset.epoll = apr_palloc(p, size * sizeof(struct epoll_event));
-    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
 
     return APR_SUCCESS;
 }
@@ -389,7 +389,7 @@ static apr_status_t impl_pollcb_add(apr_
     int ret;
     
     ev.events = get_epoll_event(descriptor->reqevents);
-    ev.data.ptr = (void *)descriptor;
+    ev.data.ptr = (void *) descriptor;
 
     if (descriptor->desc_type == APR_POLL_SOCKET) {
         ret = epoll_ctl(pollcb->fd, EPOLL_CTL_ADD,
@@ -414,7 +414,7 @@ static apr_status_t impl_pollcb_remove(a
     struct epoll_event ev = {0}; /* ignored, but must be passed with
                                   * kernel < 2.6.9
                                   */
-    int ret = -1;
+    int ret;
     
     if (descriptor->desc_type == APR_POLL_SOCKET) {
         ret = epoll_ctl(pollcb->fd, EPOLL_CTL_DEL,
@@ -456,6 +456,14 @@ static apr_status_t impl_pollcb_poll(apr
     else {
         for (i = 0; i < ret; i++) {
             apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.epoll[i].data.ptr);
+
+            if ((pollcb->flags & APR_POLLSET_WAKEABLE) &&
+                pollfd->desc_type == APR_POLL_FILE &&
+                pollfd->desc.f == pollcb->wakeup_pipe[0]) {
+                apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
+                return APR_EINTR;
+            }
+
             pollfd->rtnevents = get_epoll_revent(pollcb->pollset.epoll[i].events);
 
             rv = func(baton, pollfd);
@@ -473,6 +481,7 @@ static apr_pollcb_provider_t impl_cb = {
     impl_pollcb_add,
     impl_pollcb_remove,
     impl_pollcb_poll,
+    impl_pollcb_cleanup,
     "epoll"
 };
 

Modified: apr/apr/branches/1.6.x/poll/unix/kqueue.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/kqueue.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/kqueue.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/kqueue.c Fri Mar 25 01:19:34 2016
@@ -254,7 +254,7 @@ static apr_status_t impl_pollset_poll(ap
                                       apr_int32_t *num,
                                       const apr_pollfd_t **descriptors)
 {
-    int ret, i, j;
+    int ret;
     struct timespec tv, *tvptr;
     apr_status_t rv = APR_SUCCESS;
     apr_pollfd_t fd;
@@ -278,12 +278,14 @@ static apr_status_t impl_pollset_poll(ap
         rv = APR_TIMEUP;
     }
     else {
+        int i, j;
+
         for (i = 0, j = 0; i < ret; i++) {
-            fd = (((pfd_elem_t*)(pollset->p->ke_set[i].udata))->pfd);
+            fd = (((pfd_elem_t *)(pollset->p->ke_set[i].udata))->pfd);
             if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
                 fd.desc_type == APR_POLL_FILE &&
                 fd.desc.f == pollset->wakeup_pipe[0]) {
-                apr_pollset_drain_wakeup_pipe(pollset);
+                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
                 rv = APR_EINTR;
             }
             else {
@@ -302,7 +304,6 @@ static apr_status_t impl_pollset_poll(ap
         }
     }
 
-
     pollset_lock_rings();
 
     /* Shift all PFDs in the Dead Ring to the Free Ring */
@@ -325,9 +326,8 @@ static apr_pollset_provider_t impl = {
 
 apr_pollset_provider_t *apr_pollset_provider_kqueue = &impl;
 
-static apr_status_t cb_cleanup(void *b_)
+static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
-    apr_pollcb_t *pollcb = (apr_pollcb_t *) b_;
     close(pollcb->fd);
     return APR_SUCCESS;
 }
@@ -365,8 +365,7 @@ static apr_status_t impl_pollcb_create(a
     }
  
     pollcb->fd = fd;
-    pollcb->pollset.ke = (struct kevent *)apr_pcalloc(p, 2 * size * sizeof(struct kevent));
-    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
+    pollcb->pollset.ke = (struct kevent *) apr_pcalloc(p, 2 * size * sizeof(struct kevent));
     
     return APR_SUCCESS;
 }
@@ -469,7 +468,14 @@ static apr_status_t impl_pollcb_poll(apr
     else {
         for (i = 0; i < ret; i++) {
             apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.ke[i].udata);
-            
+
+            if ((pollcb->flags & APR_POLLSET_WAKEABLE) &&
+                pollfd->desc_type == APR_POLL_FILE &&
+                pollfd->desc.f == pollcb->wakeup_pipe[0]) {
+                apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
+                return APR_EINTR;
+            }
+
             pollfd->rtnevents = get_kqueue_revent(pollcb->pollset.ke[i].filter,
                                                   pollcb->pollset.ke[i].flags);
             
@@ -489,6 +495,7 @@ static apr_pollcb_provider_t impl_cb = {
     impl_pollcb_add,
     impl_pollcb_remove,
     impl_pollcb_poll,
+    impl_pollcb_cleanup,
     "kqueue"
 };
 

Modified: apr/apr/branches/1.6.x/poll/unix/poll.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/poll.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/poll.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/poll.c Fri Mar 25 01:19:34 2016
@@ -279,8 +279,8 @@ static apr_status_t impl_pollset_poll(ap
                 if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
                     pollset->p->query_set[i].desc_type == APR_POLL_FILE &&
                     pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) {
-                        apr_pollset_drain_wakeup_pipe(pollset);
-                        rv = APR_EINTR;
+                    apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
+                    rv = APR_EINTR;
                 }
                 else {
                     pollset->p->result_set[j] = pollset->p->query_set[i];
@@ -427,6 +427,14 @@ static apr_status_t impl_pollcb_poll(apr
         for (i = 0; i < pollcb->nelts; i++) {
             if (pollcb->pollset.ps[i].revents != 0) {
                 apr_pollfd_t *pollfd = pollcb->copyset[i];
+
+                if ((pollcb->flags & APR_POLLSET_WAKEABLE) &&
+                    pollfd->desc_type == APR_POLL_FILE &&
+                    pollfd->desc.f == pollcb->wakeup_pipe[0]) {
+                    apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
+                    return APR_EINTR;
+                }
+
                 pollfd->rtnevents = get_revent(pollcb->pollset.ps[i].revents);                    
                 rv = func(baton, pollfd);
                 if (rv) {
@@ -443,6 +451,7 @@ static apr_pollcb_provider_t impl_cb = {
     impl_pollcb_add,
     impl_pollcb_remove,
     impl_pollcb_poll,
+    NULL,
     "poll"
 };
 

Modified: apr/apr/branches/1.6.x/poll/unix/pollcb.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/pollcb.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/pollcb.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/pollcb.c Fri Mar 25 01:19:34 2016
@@ -73,6 +73,20 @@ static apr_pollcb_provider_t *pollcb_pro
     return provider;
 }
 
+static apr_status_t pollcb_cleanup(void *p)
+{
+    apr_pollcb_t *pollcb = (apr_pollcb_t *) p;
+
+    if (pollcb->provider->cleanup) {
+        (*pollcb->provider->cleanup)(pollcb);
+    }
+    if (pollcb->flags & APR_POLLSET_WAKEABLE) {
+        apr_poll_close_wakeup_pipe(pollcb->wakeup_pipe);
+    }
+
+    return APR_SUCCESS;
+}
+
 APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb,
                                                apr_uint32_t size,
                                                apr_pool_t *p,
@@ -109,9 +123,15 @@ APR_DECLARE(apr_status_t) apr_pollcb_cre
         }
     }
 
+    if (flags & APR_POLLSET_WAKEABLE) {
+        /* Add room for wakeup descriptor */
+        size++;
+    }
+
     pollcb = apr_palloc(p, sizeof(*pollcb));
     pollcb->nelts = 0;
     pollcb->nalloc = size;
+    pollcb->flags = flags;
     pollcb->pool = p;
     pollcb->provider = provider;
 
@@ -140,6 +160,22 @@ APR_DECLARE(apr_status_t) apr_pollcb_cre
         return rv;
     }
 
+    if (flags & APR_POLLSET_WAKEABLE) {
+        /* Create wakeup pipe */
+        if ((rv = apr_poll_create_wakeup_pipe(pollcb->pool, &pollcb->wakeup_pfd,
+                                              pollcb->wakeup_pipe)) 
+                != APR_SUCCESS) {
+            return rv;
+        }
+
+        if ((rv = apr_pollcb_add(pollcb, &pollcb->wakeup_pfd)) != APR_SUCCESS) {
+            return rv;
+        }
+    }
+    if ((flags & APR_POLLSET_WAKEABLE) || provider->cleanup)
+        apr_pool_cleanup_register(p, pollcb, pollcb_cleanup,
+                                  apr_pool_cleanup_null);
+
     *ret_pollcb = pollcb;
     return APR_SUCCESS;
 }
@@ -173,3 +209,16 @@ APR_DECLARE(apr_status_t) apr_pollcb_pol
 {
     return (*pollcb->provider->poll)(pollcb, timeout, func, baton);
 }
+
+APR_DECLARE(apr_status_t) apr_pollcb_wakeup(apr_pollcb_t *pollcb)
+{
+    if (pollcb->flags & APR_POLLSET_WAKEABLE)
+        return apr_file_putc(1, pollcb->wakeup_pipe[1]);
+    else
+        return APR_EINIT;
+}
+
+APR_DECLARE(const char *) apr_pollcb_method_name(apr_pollcb_t *pollcb)
+{
+    return pollcb->provider->name;
+}

Modified: apr/apr/branches/1.6.x/poll/unix/pollset.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/pollset.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/pollset.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/pollset.c Fri Mar 25 01:19:34 2016
@@ -30,101 +30,6 @@
 
 static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD;
 
-#if !APR_FILES_AS_SOCKETS
-#if defined (WIN32)
-
-/* Create a dummy wakeup socket pipe for interrupting the poller
- */
-static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
-{
-    apr_status_t rv;
-
-    if ((rv = apr_file_socket_pipe_create(&pollset->wakeup_pipe[0],
-                                          &pollset->wakeup_pipe[1],
-                                          pollset->pool)) != APR_SUCCESS)
-        return rv;
-
-    pollset->wakeup_pfd.p = pollset->pool;
-    pollset->wakeup_pfd.reqevents = APR_POLLIN;
-    pollset->wakeup_pfd.desc_type = APR_POLL_FILE;
-    pollset->wakeup_pfd.desc.f = pollset->wakeup_pipe[0];
-
-    return apr_pollset_add(pollset, &pollset->wakeup_pfd);
-}
-
-#else  /* !WIN32 */
-static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
-{
-    return APR_ENOTIMPL;
-}
-
-static apr_status_t apr_file_socket_pipe_close(apr_file_t *file)
-{
-    return APR_ENOTIMPL;
-}
-
-#endif /* WIN32 */
-#else  /* APR_FILES_AS_SOCKETS */
-
-/* Create a dummy wakeup pipe for interrupting the poller
- */
-static apr_status_t create_wakeup_pipe(apr_pollset_t *pollset)
-{
-    apr_status_t rv;
-
-    if ((rv = apr_file_pipe_create(&pollset->wakeup_pipe[0],
-                                   &pollset->wakeup_pipe[1],
-                                   pollset->pool)) != APR_SUCCESS)
-        return rv;
-
-    pollset->wakeup_pfd.p = pollset->pool;
-    pollset->wakeup_pfd.reqevents = APR_POLLIN;
-    pollset->wakeup_pfd.desc_type = APR_POLL_FILE;
-    pollset->wakeup_pfd.desc.f = pollset->wakeup_pipe[0];
-
-    {
-        int flags;
-
-        if ((flags = fcntl(pollset->wakeup_pipe[0]->filedes, F_GETFD)) == -1)
-            return errno;
-
-        flags |= FD_CLOEXEC;
-        if (fcntl(pollset->wakeup_pipe[0]->filedes, F_SETFD, flags) == -1)
-            return errno;
-    }
-    {
-        int flags;
-
-        if ((flags = fcntl(pollset->wakeup_pipe[1]->filedes, F_GETFD)) == -1)
-            return errno;
-
-        flags |= FD_CLOEXEC;
-        if (fcntl(pollset->wakeup_pipe[1]->filedes, F_SETFD, flags) == -1)
-            return errno;
-    }
-
-    return apr_pollset_add(pollset, &pollset->wakeup_pfd);
-}
-#endif /* !APR_FILES_AS_SOCKETS */
-
-/* Read and discard what's ever in the wakeup pipe.
- */
-void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset)
-{
-    char rb[512];
-    apr_size_t nr = sizeof(rb);
-
-    while (apr_file_read(pollset->wakeup_pipe[0], rb, &nr) == APR_SUCCESS) {
-        /* Although we write just one byte to the other end of the pipe
-         * during wakeup, multiple threads could call the wakeup.
-         * So simply drain out from the input side of the pipe all
-         * the data.
-         */
-        if (nr != sizeof(rb))
-            break;
-    }
-}
-
 static apr_status_t pollset_cleanup(void *p)
 {
     apr_pollset_t *pollset = (apr_pollset_t *) p;
@@ -132,23 +37,7 @@ static apr_status_t pollset_cleanup(void
         (*pollset->provider->cleanup)(pollset);
     }
     if (pollset->flags & APR_POLLSET_WAKEABLE) {
-        /* Close both sides of the wakeup pipe */
-        if (pollset->wakeup_pipe[0]) {
-#if APR_FILES_AS_SOCKETS
-            apr_file_close(pollset->wakeup_pipe[0]);
-#else
-            apr_file_socket_pipe_close(pollset->wakeup_pipe[0]);
-#endif
-            pollset->wakeup_pipe[0] = NULL;
-        }
-        if (pollset->wakeup_pipe[1]) {
-#if APR_FILES_AS_SOCKETS
-            apr_file_close(pollset->wakeup_pipe[1]);
-#else
-            apr_file_socket_pipe_close(pollset->wakeup_pipe[1]);
-#endif
-            pollset->wakeup_pipe[1] = NULL;
-        }
+        apr_poll_close_wakeup_pipe(pollset->wakeup_pipe);
     }
 
     return APR_SUCCESS;
@@ -275,8 +164,16 @@ APR_DECLARE(apr_status_t) apr_pollset_cr
         return rv;
     }
     if (flags & APR_POLLSET_WAKEABLE) {
+        apr_pollfd_t pfd;
+
         /* Create wakeup pipe */
-        if ((rv = create_wakeup_pipe(pollset)) != APR_SUCCESS) {
+        if ((rv = apr_poll_create_wakeup_pipe(pollset->pool, &pfd,
+                                              pollset->wakeup_pipe))
+                != APR_SUCCESS) {
+            return rv;
+        }
+
+        if ((rv = apr_pollset_add(pollset, &pfd)) != APR_SUCCESS) {
             return rv;
         }
     }

Modified: apr/apr/branches/1.6.x/poll/unix/port.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/port.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/port.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/port.c Fri Mar 25 01:19:34 2016
@@ -413,7 +413,7 @@ static apr_status_t impl_pollset_poll(ap
             if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
                 fp.desc_type == APR_POLL_FILE &&
                 fp.desc.f == pollset->wakeup_pipe[0]) {
-                apr_pollset_drain_wakeup_pipe(pollset);
+                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
                 rv = APR_EINTR;
             }
             else {
@@ -466,9 +466,8 @@ static apr_pollset_provider_t impl = {
 
 apr_pollset_provider_t *apr_pollset_provider_port = &impl;
 
-static apr_status_t cb_cleanup(void *p_)
+static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
-    apr_pollcb_t *pollcb = (apr_pollcb_t *) p_;
     close(pollcb->fd);
     return APR_SUCCESS;
 }
@@ -505,7 +504,6 @@ static apr_status_t impl_pollcb_create(a
     }
 
     pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
-    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
 
     return APR_SUCCESS;
 }
@@ -558,16 +556,25 @@ static apr_status_t impl_pollcb_poll(apr
                                      apr_pollcb_cb_t func,
                                      void *baton)
 {
-    apr_pollfd_t *pollfd;
     apr_status_t rv;
-    unsigned int i, nget = 1;
+    unsigned int nget = 1;
 
     rv = call_port_getn(pollcb->fd, pollcb->pollset.port, pollcb->nalloc,
                         &nget, timeout);
 
     if (nget) {
+        unsigned int i;
+
         for (i = 0; i < nget; i++) {
-            pollfd = (apr_pollfd_t *)(pollcb->pollset.port[i].portev_user);
+            apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.port[i].portev_user);
+
+            if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
+                pollfd->desc_type == APR_POLL_FILE &&
+                pollfd->desc.f == pollcb->wakeup_pipe[0]) {
+                apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
+                return APR_EINTR;
+            }
+
             pollfd->rtnevents = get_revent(pollcb->pollset.port[i].portev_events);
 
             rv = func(baton, pollfd);
@@ -586,6 +593,7 @@ static apr_pollcb_provider_t impl_cb = {
     impl_pollcb_add,
     impl_pollcb_remove,
     impl_pollcb_poll,
+    impl_pollcb_cleanup,
     "port"
 };
 

Modified: apr/apr/branches/1.6.x/poll/unix/select.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/select.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/poll/unix/select.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/select.c Fri Mar 25 01:19:34 2016
@@ -401,7 +401,7 @@ static apr_status_t impl_pollset_poll(ap
         else {
             if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
                 pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) {
-                apr_pollset_drain_wakeup_pipe(pollset);
+                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
                 rv = APR_EINTR;
                 continue;
             }

Copied: apr/apr/branches/1.6.x/poll/unix/wakeup.c (from r899905, apr/apr/trunk/poll/unix/wakeup.c)
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/wakeup.c?p2=apr/apr/branches/1.6.x/poll/unix/wakeup.c&p1=apr/apr/trunk/poll/unix/wakeup.c&r1=899905&r2=1736521&rev=1736521&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/wakeup.c (original)
+++ apr/apr/branches/1.6.x/poll/unix/wakeup.c Fri Mar 25 01:19:34 2016
@@ -27,8 +27,8 @@
 
 #ifdef WIN32
 
-apr_status_t create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
-                                apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
+                                         apr_file_t **wakeup_pipe)
 {
     apr_status_t rv;
 
@@ -42,7 +42,7 @@ apr_status_t create_wakeup_pipe(apr_pool
     return APR_SUCCESS;
 }
 
-apr_status_t close_wakeup_pipe(apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
 {
     apr_status_t rv0 = APR_SUCCESS;
     apr_status_t rv1 = APR_SUCCESS;
@@ -61,12 +61,12 @@ apr_status_t close_wakeup_pipe(apr_file_
 
 #else /* !WIN32 */
 
-apr_status_t create_wakeup_pipe(apr_pollfd_t *pfd, apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_create_wakeup_pipe(apr_pollfd_t *pfd, apr_file_t **wakeup_pipe)
 {
     return APR_ENOTIMPL;
 }
 
-apr_status_t close_wakeup_pipe(apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
 {
     return APR_ENOTIMPL;
 }
@@ -75,8 +75,8 @@ apr_status_t close_wakeup_pipe(apr_file_
 
 #else  /* APR_FILES_AS_SOCKETS */
 
-apr_status_t create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
-                                apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
+                                         apr_file_t **wakeup_pipe)
 {
     apr_status_t rv;
 
@@ -113,7 +113,7 @@ apr_status_t create_wakeup_pipe(apr_pool
     return APR_SUCCESS;
 }
 
-apr_status_t close_wakeup_pipe(apr_file_t **wakeup_pipe)
+apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
 {
     apr_status_t rv0 = APR_SUCCESS;
     apr_status_t rv1 = APR_SUCCESS;
@@ -134,7 +134,7 @@ apr_status_t close_wakeup_pipe(apr_file_
 
 /* Read and discard whatever is in the wakeup pipe.
  */
-void drain_wakeup_pipe(apr_file_t **wakeup_pipe)
+void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe)
 {
     char rb[512];
     apr_size_t nr = sizeof(rb);

Modified: apr/apr/branches/1.6.x/test/testpoll.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/test/testpoll.c?rev=1736521&r1=1736520&r2=1736521&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/test/testpoll.c (original)
+++ apr/apr/branches/1.6.x/test/testpoll.c Fri Mar 25 01:19:34 2016
@@ -593,9 +593,9 @@ typedef struct pollcb_baton_t {
     int count;
 } pollcb_baton_t;
 
-static apr_status_t trigger_pollcb_cb(void* baton, apr_pollfd_t *descriptor)
+static apr_status_t trigger_pollcb_cb(void *baton, apr_pollfd_t *descriptor)
 {
-    pollcb_baton_t* pcb = (pollcb_baton_t*) baton;
+    pollcb_baton_t *pcb = (pollcb_baton_t *) baton;
     ABTS_PTR_EQUAL(pcb->tc, s[0], descriptor->desc.s);
     ABTS_PTR_EQUAL(pcb->tc, s[0], descriptor->client_data);
     pcb->count++;
@@ -817,6 +817,36 @@ static void pollset_wakeup(abts_case *tc
     ABTS_INT_EQUAL(tc, 1, num);
 }
 
+/* Should never be invoked */
+static apr_status_t wakeup_pollcb_cb(void *baton, apr_pollfd_t *descriptor)
+{
+    abts_case *tc = (abts_case *) baton;
+
+    ABTS_FAIL(tc, "pollcb callback invoked on apr_pollcb_wakeup()");
+    return APR_SUCCESS;
+}
+
+static void pollcb_wakeup(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_pollcb_t *pcb;
+
+    rv = apr_pollcb_create(&pcb, 1, p, APR_POLLSET_WAKEABLE);
+    if (rv == APR_ENOTIMPL) {
+        ABTS_NOT_IMPL(tc, "pollcb interface not supported");
+        return;
+    }
+    else {
+        ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    }
+
+    rv = apr_pollcb_wakeup(pcb);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    rv = apr_pollcb_poll(pcb, -1, wakeup_pollcb_cb, tc);
+    ABTS_INT_EQUAL(tc, APR_EINTR, rv);
+}
+
 static void justsleep(abts_case *tc, void *data)
 {
     apr_int32_t nsds;
@@ -917,10 +947,12 @@ abts_suite *testpoll(abts_suite *suite)
     abts_run_test(suite, timeout_pollcb, NULL);
     abts_run_test(suite, timeout_pollin_pollcb, NULL);
     abts_run_test(suite, pollset_wakeup, NULL);
+    abts_run_test(suite, pollcb_wakeup, NULL);
     abts_run_test(suite, close_all_sockets, NULL);
     abts_run_test(suite, pollset_default, NULL);
     abts_run_test(suite, pollcb_default, NULL);
     abts_run_test(suite, justsleep, NULL);
+
     return suite;
 }
 




Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by olli hauer <oh...@gmx.de>.
On 2016-08-10 14:01, Rainer Jung wrote:
> Hi Olli,
> 
> Am 10.08.2016 um 13:46 schrieb olli hauer:
>> On 2016-08-10 12:41, Rainer Jung wrote:
>>> I found some more differences between trunk and r1736521 in 1.6.x which are all due to incomplete backports of changes applied to trunk after r899905. I backported all of those because they seemed applicable for 1.6.x. At least the poll directory, testpoll.c, apr_poll.h and arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.
>>>
>>> Regards,
>>>
>>> Rainer
>>>
>>
>> Hi Rainer,
>>
>> since you are looking at the moment to apr poll, perhaps you can also take a look int Bug ID 59914?
> 
> I'm sorry: the changes I applied to poll this morning were all of very formal nature and simple to verify. I don't know enough about the code to efficiently decide on the patch that you have provided for that bug.
> 
> Regards,
> 
> Rainer
> 

Hi Rainer,

OK, thanks for the honest reply!


-- 
Regards,
olli

Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Olli,

Am 10.08.2016 um 13:46 schrieb olli hauer:
> On 2016-08-10 12:41, Rainer Jung wrote:
>> I found some more differences between trunk and r1736521 in 1.6.x which are all due to incomplete backports of changes applied to trunk after r899905. I backported all of those because they seemed applicable for 1.6.x. At least the poll directory, testpoll.c, apr_poll.h and arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.
>>
>> Regards,
>>
>> Rainer
>>
>
> Hi Rainer,
>
> since you are looking at the moment to apr poll, perhaps you can also take a look int Bug ID 59914?

I'm sorry: the changes I applied to poll this morning were all of very 
formal nature and simple to verify. I don't know enough about the code 
to efficiently decide on the patch that you have provided for that bug.

Regards,

Rainer

Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by olli hauer <oh...@gmx.de>.
On 2016-08-10 12:41, Rainer Jung wrote:
> I found some more differences between trunk and r1736521 in 1.6.x which are all due to incomplete backports of changes applied to trunk after r899905. I backported all of those because they seemed applicable for 1.6.x. At least the poll directory, testpoll.c, apr_poll.h and arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.
> 
> Regards,
> 
> Rainer
> 

Hi Rainer,

since you are looking at the moment to apr poll, perhaps you can also take a look int Bug ID 59914?

-- 
Regards,

olli

Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Yann,

Am 10.08.2016 um 12:50 schrieb Yann Ylavic:
> Hi Rainer,
>
> On Wed, Aug 10, 2016 at 12:41 PM, Rainer Jung <ra...@kippdata.de> wrote:
>> I found some more differences between trunk and r1736521 in 1.6.x which are
>> all due to incomplete backports of changes applied to trunk after r899905. I
>> backported all of those because they seemed applicable for 1.6.x. At least
>> the poll directory, testpoll.c, apr_poll.h and
>> arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.
>
> Is 1.5.x already fine with these backports/fixes?
> APR_POLLSET_WAKEABLE is available there too...

I *think* all those changes were followups to the change that introduced 
apr_pollcb_wakeup() and apr_pollcb_method_name() to trunk. That was only 
backported to 1.6, not 1.5. The older apr_pollset_wakeup() and 
apr_pollset_method_name() shouldn't have been touched, so 1.5 should be 
still fine.

Regards,

Rainer




Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by Yann Ylavic <yl...@gmail.com>.
Hi Rainer,

On Wed, Aug 10, 2016 at 12:41 PM, Rainer Jung <ra...@kippdata.de> wrote:
> I found some more differences between trunk and r1736521 in 1.6.x which are
> all due to incomplete backports of changes applied to trunk after r899905. I
> backported all of those because they seemed applicable for 1.6.x. At least
> the poll directory, testpoll.c, apr_poll.h and
> arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.

Is 1.5.x already fine with these backports/fixes?
APR_POLLSET_WAKEABLE is available there too...

Regards,
Yann.

Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by Rainer Jung <ra...@kippdata.de>.
I found some more differences between trunk and r1736521 in 1.6.x which 
are all due to incomplete backports of changes applied to trunk after 
r899905. I backported all of those because they seemed applicable for 
1.6.x. At least the poll directory, testpoll.c, apr_poll.h and 
arch/unix/apr_arch_poll_private.h are now in sync between trunk and 1.6.x.

Regards,

Rainer

Am 09.08.2016 um 23:31 schrieb Rainer Jung:
> Am 25.03.2016 um 02:19 schrieb minfrin@apache.org:
>> Author: minfrin
>> Date: Fri Mar 25 01:19:34 2016
>> New Revision: 1736521
>>
>> URL: http://svn.apache.org/viewvc?rev=1736521&view=rev
>> Log:
>> Add apr_pollcb_wakeup(), with similar behavior to
>> apr_pollset_wakeup(). Add apr_pollcb_method_name(), with similar
>> behavior to apr_pollset_method_name().
>>
>
> ...
>
>> Modified: apr/apr/branches/1.6.x/poll/unix/port.c
>> URL:
>> http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/port.c?rev=1736521&r1=1736520&r2=1736521&view=diff
>>
>> ==============================================================================
>>
>> --- apr/apr/branches/1.6.x/poll/unix/port.c (original)
>> +++ apr/apr/branches/1.6.x/poll/unix/port.c Fri Mar 25 01:19:34 2016
>> @@ -413,7 +413,7 @@ static apr_status_t impl_pollset_poll(ap
>>              if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
>>                  fp.desc_type == APR_POLL_FILE &&
>>                  fp.desc.f == pollset->wakeup_pipe[0]) {
>> -                apr_pollset_drain_wakeup_pipe(pollset);
>> +                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
>>                  rv = APR_EINTR;
>>              }
>>              else {
>> @@ -466,9 +466,8 @@ static apr_pollset_provider_t impl = {
>>
>>  apr_pollset_provider_t *apr_pollset_provider_port = &impl;
>>
>> -static apr_status_t cb_cleanup(void *p_)
>> +static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
>>  {
>> -    apr_pollcb_t *pollcb = (apr_pollcb_t *) p_;
>>      close(pollcb->fd);
>>      return APR_SUCCESS;
>>  }
>> @@ -505,7 +504,6 @@ static apr_status_t impl_pollcb_create(a
>>      }
>>
>>      pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
>> -    apr_pool_cleanup_register(p, pollcb, cb_cleanup,
>> apr_pool_cleanup_null);
>>
>>      return APR_SUCCESS;
>>  }
>> @@ -558,16 +556,25 @@ static apr_status_t impl_pollcb_poll(apr
>>                                       apr_pollcb_cb_t func,
>>                                       void *baton)
>>  {
>> -    apr_pollfd_t *pollfd;
>>      apr_status_t rv;
>> -    unsigned int i, nget = 1;
>> +    unsigned int nget = 1;
>>
>>      rv = call_port_getn(pollcb->fd, pollcb->pollset.port,
>> pollcb->nalloc,
>>                          &nget, timeout);
>>
>>      if (nget) {
>> +        unsigned int i;
>> +
>>          for (i = 0; i < nget; i++) {
>> -            pollfd = (apr_pollfd_t
>> *)(pollcb->pollset.port[i].portev_user);
>> +            apr_pollfd_t *pollfd = (apr_pollfd_t
>> *)(pollcb->pollset.port[i].portev_user);
>> +
>> +            if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
>> +                pollfd->desc_type == APR_POLL_FILE &&
>> +                pollfd->desc.f == pollcb->wakeup_pipe[0]) {
>> +                apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
>> +                return APR_EINTR;
>> +            }
>> +
>>              pollfd->rtnevents =
>> get_revent(pollcb->pollset.port[i].portev_events);
>>
>>              rv = func(baton, pollfd);
>> @@ -586,6 +593,7 @@ static apr_pollcb_provider_t impl_cb = {
>>      impl_pollcb_add,
>>      impl_pollcb_remove,
>>      impl_pollcb_poll,
>> +    impl_pollcb_cleanup,
>>      "port"
>>  };
>
> I get a compilation error (ggc on Solaris):
>
> .../poll/unix/port.c: In function 'impl_pollcb_poll':
> .../poll/unix/port.c:571:24: error: 'apr_pollfd_t' has no member named
> 'flags'
>              if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
>                         ^
>
> Maybe the following patch is appropriate?
>
> --- poll/unix/port.c (revision 1755647)
> +++ poll/unix/port.c (working copy)
> @@ -568,7 +568,7 @@
>          for (i = 0; i < nget; i++) {
>              apr_pollfd_t *pollfd = (apr_pollfd_t
> *)(pollcb->pollset.port[i].portev_user);
>
> -            if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
> +            if ((pollcb->flags & APR_POLLSET_WAKEABLE) &&
>                  pollfd->desc_type == APR_POLL_FILE &&
>                  pollfd->desc.f == pollcb->wakeup_pipe[0]) {
>                  apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
>
> At least it builds and "make check" runs fine.
>
> Regards,
>
> Rainer

Re: svn commit: r1736521 - in /apr/apr/branches/1.6.x: ./ include/ include/arch/unix/ poll/unix/ test/

Posted by Rainer Jung <ra...@kippdata.de>.
Am 25.03.2016 um 02:19 schrieb minfrin@apache.org:
> Author: minfrin
> Date: Fri Mar 25 01:19:34 2016
> New Revision: 1736521
>
> URL: http://svn.apache.org/viewvc?rev=1736521&view=rev
> Log:
> Add apr_pollcb_wakeup(), with similar behavior to
> apr_pollset_wakeup(). Add apr_pollcb_method_name(), with similar
> behavior to apr_pollset_method_name().
>

...

> Modified: apr/apr/branches/1.6.x/poll/unix/port.c
> URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/poll/unix/port.c?rev=1736521&r1=1736520&r2=1736521&view=diff
> ==============================================================================
> --- apr/apr/branches/1.6.x/poll/unix/port.c (original)
> +++ apr/apr/branches/1.6.x/poll/unix/port.c Fri Mar 25 01:19:34 2016
> @@ -413,7 +413,7 @@ static apr_status_t impl_pollset_poll(ap
>              if ((pollset->flags & APR_POLLSET_WAKEABLE) &&
>                  fp.desc_type == APR_POLL_FILE &&
>                  fp.desc.f == pollset->wakeup_pipe[0]) {
> -                apr_pollset_drain_wakeup_pipe(pollset);
> +                apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe);
>                  rv = APR_EINTR;
>              }
>              else {
> @@ -466,9 +466,8 @@ static apr_pollset_provider_t impl = {
>
>  apr_pollset_provider_t *apr_pollset_provider_port = &impl;
>
> -static apr_status_t cb_cleanup(void *p_)
> +static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
>  {
> -    apr_pollcb_t *pollcb = (apr_pollcb_t *) p_;
>      close(pollcb->fd);
>      return APR_SUCCESS;
>  }
> @@ -505,7 +504,6 @@ static apr_status_t impl_pollcb_create(a
>      }
>
>      pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
> -    apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
>
>      return APR_SUCCESS;
>  }
> @@ -558,16 +556,25 @@ static apr_status_t impl_pollcb_poll(apr
>                                       apr_pollcb_cb_t func,
>                                       void *baton)
>  {
> -    apr_pollfd_t *pollfd;
>      apr_status_t rv;
> -    unsigned int i, nget = 1;
> +    unsigned int nget = 1;
>
>      rv = call_port_getn(pollcb->fd, pollcb->pollset.port, pollcb->nalloc,
>                          &nget, timeout);
>
>      if (nget) {
> +        unsigned int i;
> +
>          for (i = 0; i < nget; i++) {
> -            pollfd = (apr_pollfd_t *)(pollcb->pollset.port[i].portev_user);
> +            apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.port[i].portev_user);
> +
> +            if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
> +                pollfd->desc_type == APR_POLL_FILE &&
> +                pollfd->desc.f == pollcb->wakeup_pipe[0]) {
> +                apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);
> +                return APR_EINTR;
> +            }
> +
>              pollfd->rtnevents = get_revent(pollcb->pollset.port[i].portev_events);
>
>              rv = func(baton, pollfd);
> @@ -586,6 +593,7 @@ static apr_pollcb_provider_t impl_cb = {
>      impl_pollcb_add,
>      impl_pollcb_remove,
>      impl_pollcb_poll,
> +    impl_pollcb_cleanup,
>      "port"
>  };

I get a compilation error (ggc on Solaris):

.../poll/unix/port.c: In function 'impl_pollcb_poll':
.../poll/unix/port.c:571:24: error: 'apr_pollfd_t' has no member named 
'flags'
              if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
                         ^

Maybe the following patch is appropriate?

--- poll/unix/port.c (revision 1755647)
+++ poll/unix/port.c (working copy)
@@ -568,7 +568,7 @@
          for (i = 0; i < nget; i++) {
              apr_pollfd_t *pollfd = (apr_pollfd_t 
*)(pollcb->pollset.port[i].portev_user);

-            if ((pollfd->flags & APR_POLLSET_WAKEABLE) &&
+            if ((pollcb->flags & APR_POLLSET_WAKEABLE) &&
                  pollfd->desc_type == APR_POLL_FILE &&
                  pollfd->desc.f == pollcb->wakeup_pipe[0]) {
                  apr_poll_drain_wakeup_pipe(pollcb->wakeup_pipe);

At least it builds and "make check" runs fine.

Regards,

Rainer