httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ic...@apache.org
Subject svn commit: r1735227 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h include/ap_mpm.h include/mpm_common.h modules/proxy/mod_proxy_wstunnel.c server/mpm/event/event.c server/mpm/event/fdqueue.h server/mpm_common.c
Date Wed, 16 Mar 2016 13:09:47 GMT
Author: icing
Date: Wed Mar 16 13:09:47 2016
New Revision: 1735227

URL: http://svn.apache.org/viewvc?rev=1735227&view=rev
Log:
reverting the reverting of r1735174, r1735176 was the culprit

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/ap_mpm.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/event/fdqueue.h
    httpd/httpd/trunk/server/mpm_common.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Wed Mar 16 13:09:47 2016
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mpm: Generalise the ap_mpm_register_socket functions to accept pipes
+     or sockets. [Graham Leggett]
+
   *) mod_rewrite: Don't implicitly URL-escape the original query string
      when no substitution has changed it (like PR50447 but server context)
      [Evgeny Kotkov <evgeny.kotkov visualsvn.com>]

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Wed Mar 16 13:09:47 2016
@@ -510,12 +510,19 @@
  * 20160312.0 (2.5.0-dev)  Rename complete_connection to output_pending,
  *                         add ap_filter_input_pending(),
  *                         ap_filter_prepare_brigade(), ap_filter_direction_e
+ * 20160315.0 (2.5.0-dev)  Rename ap_mpm_register_socket_callback,
+ *                         ap_mpm_register_socket_callback_timeout and
+ *                         ap_mpm_unregister_socket_callback to
+ *                         ap_mpm_register_poll_callback,
+ *                         ap_mpm_register_poll_callback_timeout and
+ *                         ap_mpm_unregister_poll_callback. Add
+ *                         AP_MPMQ_CAN_POLL.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20160312
+#define MODULE_MAGIC_NUMBER_MAJOR 20160315
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                 /* 0...n */
 

Modified: httpd/httpd/trunk/include/ap_mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mpm.h?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mpm.h (original)
+++ httpd/httpd/trunk/include/ap_mpm.h Wed Mar 16 13:09:47 2016
@@ -180,6 +180,8 @@ AP_DECLARE(apr_status_t) ap_os_create_pr
 #define AP_MPMQ_HAS_SERF             16
 /** MPM supports suspending/resuming connections */
 #define AP_MPMQ_CAN_SUSPEND          17
+/** MPM supports additional pollfds */
+#define AP_MPMQ_CAN_POLL             18
 /** @} */
 
 /**
@@ -202,55 +204,56 @@ typedef void (ap_mpm_callback_fn_t)(void
 /* only added support in the Event MPM....  check for APR_ENOTIMPL */
 AP_DECLARE(apr_status_t) ap_mpm_resume_suspended(conn_rec *c);
 /* only added support in the Event MPM....  check for APR_ENOTIMPL */
-AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t,
-                                                       ap_mpm_callback_fn_t *cbfn,
-                                                       void *baton);
+AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(
+        apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton);
 
 /**
- * Register a callback on the readability or writability on a group of sockets
- * @param s Null-terminated list of sockets
+ * Register a callback on the readability or writability on a group of
+ * sockets/pipes.
+ * @param pfds Array of apr_pollfd_t
  * @param p pool for use between registration and callback
- * @param for_read Whether the sockets are monitored for read or writability
  * @param cbfn The callback function
  * @param baton userdata for the callback function
- * @return APR_SUCCESS if all sockets could be added to a pollset, 
+ * @return APR_SUCCESS if all sockets/pipes could be added to a pollset,
  * APR_ENOTIMPL if no asynch support, or an apr_pollset_add error.
- * @remark When activity is found on any 1 socket in the list, all are removed 
+ * @remark When activity is found on any 1 socket/pipe in the list, all are removed
  * from the pollset and only 1 callback is issued.
  */
 
-AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback(apr_socket_t **s,
-                                                         apr_pool_t *p,
-                                                         int for_read, 
-                                                         ap_mpm_callback_fn_t *cbfn,
-                                                         void *baton);
- /**
- * Register a callback on the readability or writability on a group of sockets, with a timeout
- * @param s Null-terminated list of sockets
+AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback(apr_array_header_t *pds,
+        ap_mpm_callback_fn_t *cbfn, void *baton);
+
+/**
+ * Register a callback on the readability or writability on a group of sockets/pipes,
+ * with a timeout.
+ * @param pfds Array of apr_pollfd_t
  * @param p pool for use between registration and callback
- * @param for_read Whether the sockets are monitored for read or writability
  * @param cbfn The callback function
  * @param tofn The callback function if the timeout expires
  * @param baton userdata for the callback function
  * @param timeout timeout for I/O in microseconds, unlimited if <= 0
- * @return APR_SUCCESS if all sockets could be added to a pollset, 
+ * @return APR_SUCCESS if all sockets/pipes could be added to a pollset,
  * APR_ENOTIMPL if no asynch support, or an apr_pollset_add error.
- * @remark When activity is found on any 1 socket in the list, all are removed 
+ * @remark When activity is found on any 1 socket/pipe in the list, all are removed
  * from the pollset and only 1 callback is issued. 
  * @remark For each call, only one of tofn or cbfn will be called, never both.
  */
 
-AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback_timeout(apr_socket_t **s,
-                                                         apr_pool_t *p,
-                                                         int for_read, 
-                                                         ap_mpm_callback_fn_t *cbfn,
-                                                         ap_mpm_callback_fn_t *tofn,
-                                                         void *baton,
-                                                         apr_time_t timeout);
+AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback_timeout(
+        apr_array_header_t *pfds, ap_mpm_callback_fn_t *cbfn,
+        ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout);
 
 
-AP_DECLARE(apr_status_t) ap_mpm_unregister_socket_callback(apr_socket_t **s, 
-                                                           apr_pool_t *p);
+/**
+* Unregister a previously registered callback.
+* @param pfds Array of apr_pollfd_t
+* @param p pool for use between registration and callback
+* @return APR_SUCCESS if all sockets/pipes could be removed from the pollset,
+* APR_ENOTIMPL if no asynch support, or an apr_pollset_remove error.
+* @remark This function triggers the cleanup registered on the pool p during
+* callback registration.
+*/
+AP_DECLARE(apr_status_t) ap_mpm_unregister_poll_callback(apr_array_header_t *pfds);
 
 typedef enum mpm_child_status {
     MPM_CHILD_STARTED,

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Wed Mar 16 13:09:47 2016
@@ -426,25 +426,26 @@ AP_DECLARE_HOOK(apr_status_t, mpm_regist
  * register the specified callback
  * @ingroup hooks
  */
-AP_DECLARE_HOOK(apr_status_t, mpm_register_socket_callback,
-                (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_callback_fn_t *cbfn,
void *baton))
+AP_DECLARE_HOOK(apr_status_t, mpm_register_poll_callback,
+                (apr_array_header_t *pds, ap_mpm_callback_fn_t *cbfn, void *baton))
 
 /* register the specified callback, with timeout 
  * @ingroup hooks
  *
  */
-AP_DECLARE_HOOK(apr_status_t, mpm_register_socket_callback_timeout,
-                (apr_socket_t **s, apr_pool_t *p, int for_read, 
-                 ap_mpm_callback_fn_t *cbfn,  
-                 ap_mpm_callback_fn_t *tofn, 
-                 void *baton, 
-                 apr_time_t timeout))
+AP_DECLARE_HOOK(apr_status_t, mpm_register_poll_callback_timeout,
+        (apr_array_header_t *pds,
+                ap_mpm_callback_fn_t *cbfn,
+                ap_mpm_callback_fn_t *tofn,
+                void *baton,
+                apr_time_t timeout))
+
 /**
  * Unregister the specified callback
  * @ingroup hooks
  */
-AP_DECLARE_HOOK(apr_status_t, mpm_unregister_socket_callback,
-                (apr_socket_t **s, apr_pool_t *p))
+AP_DECLARE_HOOK(apr_status_t, mpm_unregister_poll_callback,
+                (apr_array_header_t *pds))
 
 /** Resume the suspended connection 
  * @ingroup hooks

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c Wed Mar 16 13:09:47 2016
@@ -20,7 +20,7 @@
 module AP_MODULE_DECLARE_DATA proxy_wstunnel_module;
 
 typedef struct {
-    signed char is_async;
+    int mpm_can_poll;
     apr_time_t idle_timeout;
     apr_time_t async_delay;
 } proxyws_dir_conf;
@@ -39,7 +39,7 @@ typedef struct ws_baton_t {
 
 static void proxy_wstunnel_callback(void *b);
 
-static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_async) {
+static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_poll) {
     request_rec *r = baton->r;
     conn_rec *c = r->connection;
     proxy_conn_rec *conn = baton->proxy_connrec;
@@ -62,7 +62,7 @@ static int proxy_wstunnel_pump(ws_baton_
                 continue;
             }
             else if (APR_STATUS_IS_TIMEUP(rv)) { 
-                if (try_async) { 
+                if (try_poll) {
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02542) "Attempting
to go async");
                     return SUSPENDED;
                 }
@@ -182,15 +182,28 @@ static void proxy_wstunnel_cancel_callba
  */
 static void proxy_wstunnel_callback(void *b) { 
     int status;
-    apr_socket_t *sockets[3] = {NULL, NULL, NULL};
     ws_baton_t *baton = (ws_baton_t*)b;
     proxyws_dir_conf *dconf = ap_get_module_config(baton->r->per_dir_config, &proxy_wstunnel_module);
     apr_pool_clear(baton->subpool);
-    status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->is_async);
+    status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->mpm_can_poll);
     if (status == SUSPENDED) {
-        sockets[0] = baton->client_soc;
-        sockets[1] = baton->server_soc;
-        ap_mpm_register_socket_callback_timeout(sockets, baton->subpool, 1, 
+        apr_pollfd_t *pfd;
+
+        apr_array_header_t *pfds = apr_array_make(baton->subpool, 2, sizeof(apr_pollfd_t));
+
+        pfd = apr_array_push(pfds);
+        pfd->desc_type = APR_POLL_SOCKET;
+        pfd->reqevents = APR_POLLIN | APR_POLLERR | APR_POLLHUP;
+        pfd->desc.s = baton->client_soc;
+        pfd->p = baton->subpool;
+
+        pfd = apr_array_push(pfds);
+        pfd->desc_type = APR_POLL_SOCKET;
+        pfd->reqevents = APR_POLLIN | APR_POLLERR | APR_POLLHUP;
+        pfd->desc.s = baton->server_soc;
+        pfd->p = baton->subpool;
+
+        ap_mpm_register_poll_callback_timeout(pfds,
             proxy_wstunnel_callback, 
             proxy_wstunnel_cancel_callback, 
             baton, 
@@ -298,7 +311,6 @@ static int proxy_wstunnel_request(apr_po
     apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
     apr_socket_t *client_socket = ap_get_conn_socket(c);
     ws_baton_t *baton = apr_pcalloc(r->pool, sizeof(ws_baton_t));
-    apr_socket_t *sockets[3] = {NULL, NULL, NULL};
     int status;
     proxyws_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &proxy_wstunnel_module);
 
@@ -370,16 +382,30 @@ static int proxy_wstunnel_request(apr_po
     baton->scheme = scheme;
     apr_pool_create(&baton->subpool, r->pool);
 
-    if (!dconf->is_async) { 
-        status = proxy_wstunnel_pump(baton, dconf->idle_timeout, dconf->is_async);
+    if (!dconf->mpm_can_poll) {
+        status = proxy_wstunnel_pump(baton, dconf->idle_timeout, dconf->mpm_can_poll);
     }  
     else { 
-        status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->is_async); 
+        status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->mpm_can_poll);
         apr_pool_clear(baton->subpool);
         if (status == SUSPENDED) {
-            sockets[0] = baton->client_soc;
-            sockets[1] = baton->server_soc;
-            rv = ap_mpm_register_socket_callback_timeout(sockets, baton->subpool, 1, 
+            apr_pollfd_t *pfd;
+
+            apr_array_header_t *pfds = apr_array_make(baton->subpool, 2, sizeof(apr_pollfd_t));
+
+            pfd = apr_array_push(pfds);
+            pfd->desc_type = APR_POLL_SOCKET;
+            pfd->reqevents = APR_POLLIN | APR_POLLERR | APR_POLLHUP;
+            pfd->desc.s = baton->client_soc;
+            pfd->p = baton->subpool;
+
+            pfd = apr_array_push(pfds);
+            pfd->desc_type = APR_POLL_SOCKET;
+            pfd->reqevents = APR_POLLIN | APR_POLLERR | APR_POLLHUP;
+            pfd->desc.s = baton->server_soc;
+            pfd->p = baton->subpool;
+
+            rv = ap_mpm_register_poll_callback_timeout(pfds,
                          proxy_wstunnel_callback, 
                          proxy_wstunnel_cancel_callback, 
                          baton, 
@@ -504,6 +530,8 @@ static void *create_proxyws_dir_config(a
 
     new->idle_timeout = -1; /* no timeout */
 
+    ap_mpm_query(AP_MPMQ_CAN_POLL, &new->mpm_can_poll);
+
     return (void *) new;
 }
 
@@ -524,15 +552,11 @@ static const char * proxyws_set_aysnch_d
 
 static const command_rec ws_proxy_cmds[] =
 {
-    AP_INIT_FLAG("ProxyWebsocketAsync", ap_set_flag_slot_char, (void*)APR_OFFSETOF(proxyws_dir_conf,
is_async), 
-                 RSRC_CONF|ACCESS_CONF,
-                 "on if idle websockets connections should be monitored asyncronously"),
-
     AP_INIT_TAKE1("ProxyWebsocketIdleTimeout", proxyws_set_idle, NULL, RSRC_CONF|ACCESS_CONF,
                  "timeout for activity in either direction, unlimited by default"),
 
     AP_INIT_TAKE1("ProxyWebsocketAsyncDelay", proxyws_set_aysnch_delay, NULL, RSRC_CONF|ACCESS_CONF,
-                 "amount of time to poll before going asyncronous"),
+                 "amount of time to poll before going asynchronous"),
     {NULL}
 };
 

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Wed Mar 16 13:09:47 2016
@@ -337,12 +337,11 @@ typedef struct
 
 typedef struct
 {
- ap_mpm_callback_fn_t *cbfunc;
- void *user_baton; 
- apr_pollfd_t **pfds;
- int nsock;
- timer_event_t *cancel_event;    /* If a timeout was requested, a pointer to the timer event
*/
- unsigned int signaled:1;
+    ap_mpm_callback_fn_t *cbfunc;
+    void *user_baton;
+    apr_array_header_t *pfds;
+    timer_event_t *cancel_event; /* If a timeout was requested, a pointer to the timer event
*/
+    unsigned int signaled :1;
 } socket_callback_baton_t;
 
 /* data retained by event across load/unload of the module
@@ -591,6 +590,9 @@ static int event_query(int query_code, i
     case AP_MPMQ_CAN_SUSPEND:
         *result = 1;
         break;
+    case AP_MPMQ_CAN_POLL:
+        *result = 1;
+        break;
     default:
         *rv = APR_ENOTIMPL;
         break;
@@ -1480,7 +1482,7 @@ static timer_event_t * event_get_timer_e
                                              ap_mpm_callback_fn_t *cbfn,
                                              void *baton,
                                              int insert, 
-                                             apr_pollfd_t **remove)
+                                             apr_array_header_t *remove)
 {
     timer_event_t *te;
     /* oh yeah, and make locking smarter/fine grained. */
@@ -1514,7 +1516,7 @@ static timer_event_t * event_get_timer_e
 static apr_status_t event_register_timed_callback_ex(apr_time_t t,
                                                   ap_mpm_callback_fn_t *cbfn,
                                                   void *baton, 
-                                                  apr_pollfd_t **remove)
+                                                  apr_array_header_t *remove)
 {
     event_get_timer_event(t + apr_time_now(), cbfn, baton, 1, remove);
     return APR_SUCCESS;
@@ -1528,95 +1530,79 @@ static apr_status_t event_register_timed
     return APR_SUCCESS;
 }
 
-static apr_status_t event_register_socket_callback_ex(apr_socket_t **s, 
-                                                  apr_pool_t *p, 
-                                                  int for_read,
+static apr_status_t event_cleanup_poll_callback(void *data)
+{
+    apr_status_t final_rc = APR_SUCCESS;
+    apr_array_header_t *pfds = data;
+    int i;
+
+    for (i = 0; i < pfds->nelts; i++) {
+        apr_pollfd_t *pfd = (apr_pollfd_t *)pfds->elts + i;
+        if (pfd->client_data) {
+            apr_status_t rc;
+            rc = apr_pollset_remove(event_pollset, pfd);
+            if (rc != APR_SUCCESS && !APR_STATUS_IS_NOTFOUND(rc)) {
+                final_rc = rc;
+            }
+        }
+    }
+
+    return final_rc;
+}
+
+static apr_status_t event_register_poll_callback_ex(apr_array_header_t *pfds,
                                                   ap_mpm_callback_fn_t *cbfn,
                                                   ap_mpm_callback_fn_t *tofn,
-                                                  void *baton, 
+                                                  void *baton,
                                                   apr_time_t timeout)
 {
+    socket_callback_baton_t *scb = apr_pcalloc(pfds->pool, sizeof(*scb));
+    listener_poll_type *pt = apr_palloc(pfds->pool, sizeof(*pt));
     apr_status_t rc, final_rc= APR_SUCCESS;
-    int i = 0, nsock;
-    socket_callback_baton_t *scb = apr_pcalloc(p, sizeof(*scb));
-    listener_poll_type *pt = apr_palloc(p, sizeof(*pt));
-    apr_pollfd_t **pfds = NULL;
-
-    while(s[i] != NULL) { 
-        i++; 
-    }
-    nsock = i;
-
-    pfds = apr_pcalloc(p, (nsock+1) * sizeof(apr_pollfd_t*));
+    int i;
 
     pt->type = PT_USER;
     pt->baton = scb;
 
     scb->cbfunc = cbfn;
     scb->user_baton = baton;
-    scb->nsock = nsock;
     scb->pfds = pfds;
 
-    for (i = 0; i<nsock; i++) { 
-        pfds[i] = apr_pcalloc(p, sizeof(apr_pollfd_t));
-        pfds[i]->desc_type = APR_POLL_SOCKET;
-        pfds[i]->reqevents = (for_read ? APR_POLLIN : APR_POLLOUT) | APR_POLLERR | APR_POLLHUP;
-        pfds[i]->desc.s = s[i];
-        pfds[i]->p = p;
-        pfds[i]->client_data = pt;
+    apr_pool_pre_cleanup_register(pfds->pool, pfds, event_cleanup_poll_callback);
+
+    for (i = 0; i < pfds->nelts; i++) {
+        apr_pollfd_t *pfd = (apr_pollfd_t *)pfds->elts + i;
+        pfd->reqevents = (pfd->reqevents) | APR_POLLERR | APR_POLLHUP;
+        pfd->client_data = pt;
     }
 
     if (timeout > 0) { 
         /* XXX:  This cancel timer event count fire before the pollset is updated */
         scb->cancel_event = event_get_timer_event(timeout + apr_time_now(), tofn, baton,
1, pfds);
     }
-    for (i = 0; i<nsock; i++) { 
-        rc = apr_pollset_add(event_pollset, pfds[i]);
+    for (i = 0; i < pfds->nelts; i++) {
+        apr_pollfd_t *pfd = (apr_pollfd_t *)pfds->elts + i;
+        rc = apr_pollset_add(event_pollset, pfd);
         if (rc != APR_SUCCESS) {
             final_rc = rc;
         }
     }
     return final_rc;
 }
-static apr_status_t event_register_socket_callback(apr_socket_t **s, 
-                                                  apr_pool_t *p, 
-                                                  int for_read,
-                                                  ap_mpm_callback_fn_t *cbfn,
-                                                  void *baton)
-{
-    return event_register_socket_callback_ex(s, p, for_read, 
-                                             cbfn, 
-                                             NULL, /* no timeout function */
-                                             baton, 
-                                             0     /* no timeout */);
+
+static apr_status_t event_register_poll_callback(apr_array_header_t *pfds,
+                                                 ap_mpm_callback_fn_t *cbfn,
+                                                 void *baton)
+{
+    return event_register_poll_callback_ex(pfds,
+                                           cbfn,
+                                           NULL, /* no timeout function */
+                                           baton,
+                                           0     /* no timeout */);
 }
-static apr_status_t event_unregister_socket_callback(apr_socket_t **s, apr_pool_t *p)
+static apr_status_t event_unregister_poll_callback(apr_array_header_t *pfds)
 {
-    int i = 0, nsock;
-    apr_status_t final_rc = APR_SUCCESS;
-    apr_pollfd_t **pfds = NULL;
-
-    while(s[i] != NULL) { 
-        i++; 
-    }
-    nsock = i;
- 
-    pfds = apr_palloc(p, nsock * sizeof(apr_pollfd_t*));
-
-    for (i = 0; i<nsock; i++) { 
-        apr_status_t rc;
-        pfds[i] = apr_pcalloc(p, sizeof(apr_pollfd_t));
-        pfds[i]->desc_type = APR_POLL_SOCKET;
-        pfds[i]->reqevents = APR_POLLERR | APR_POLLHUP;
-        pfds[i]->desc.s = s[i];
-        pfds[i]->client_data = NULL;
-        rc = apr_pollset_remove(event_pollset, pfds[i]);
-        if (rc != APR_SUCCESS && !APR_STATUS_IS_NOTFOUND(rc)) {
-            final_rc = rc;
-        }
-    }
-
-    return final_rc;
+    return apr_pool_cleanup_run(pfds->pool, pfds, event_cleanup_poll_callback);
 }
 
 /*
@@ -1828,10 +1814,11 @@ static void * APR_THREAD_FUNC listener_t
             if (te->when < now + EVENT_FUDGE_FACTOR) {
                 apr_skiplist_pop(timer_skiplist, NULL);
                 if (!te->canceled) { 
-                    if (te->remove != NULL) {
-                        apr_pollfd_t **pfds;
-                        for (pfds = (te->remove); *pfds != NULL; pfds++) { 
-                            apr_pollset_remove(event_pollset, *pfds);
+                    if (te->remove) {
+                        int i;
+                        for (i = 0; i < te->remove->nelts; i++) {
+                            apr_pollfd_t *pfd = (apr_pollfd_t *)te->remove->elts +
i;
+                            apr_pollset_remove(event_pollset, pfd);
                         }
                     }
                     push_timer2worker(te);
@@ -2056,8 +2043,10 @@ static void * APR_THREAD_FUNC listener_t
                                                0, /* don't insert it */
                                                NULL /* no associated socket callback */);
                     /* remove all sockets in my set */
-                    for (i = 0; i < baton->nsock; i++) { 
-                        apr_pollset_remove(event_pollset, baton->pfds[i]); 
+                    for (i = 0; i < baton->pfds->nelts; i++) {
+                        apr_pollfd_t *pfd = (apr_pollfd_t *)baton->pfds->elts + i;
+                        apr_pollset_remove(event_pollset, pfd);
+                        pfd->client_data = NULL;
                     }
 
                     push_timer2worker(te);
@@ -3789,11 +3778,11 @@ static void event_hooks(apr_pool_t * p)
     ap_hook_mpm_query(event_query, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_mpm_register_timed_callback(event_register_timed_callback, NULL, NULL,
                                         APR_HOOK_MIDDLE);
-    ap_hook_mpm_register_socket_callback(event_register_socket_callback, NULL, NULL,
+    ap_hook_mpm_register_poll_callback(event_register_poll_callback, NULL, NULL,
                                         APR_HOOK_MIDDLE);
-    ap_hook_mpm_register_socket_callback_timeout(event_register_socket_callback_ex, NULL,
NULL,
+    ap_hook_mpm_register_poll_callback_timeout(event_register_poll_callback_ex, NULL, NULL,
                                         APR_HOOK_MIDDLE);
-    ap_hook_mpm_unregister_socket_callback(event_unregister_socket_callback, NULL, NULL,
+    ap_hook_mpm_unregister_poll_callback(event_unregister_poll_callback, NULL, NULL,
                                         APR_HOOK_MIDDLE);
     ap_hook_pre_read_request(event_pre_read_request, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_read_request(event_post_read_request, NULL, NULL, APR_HOOK_MIDDLE);

Modified: httpd/httpd/trunk/server/mpm/event/fdqueue.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/fdqueue.h?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/fdqueue.h (original)
+++ httpd/httpd/trunk/server/mpm/event/fdqueue.h Wed Mar 16 13:09:47 2016
@@ -64,13 +64,14 @@ typedef struct fd_queue_elem_t fd_queue_
 
 typedef struct timer_event_t timer_event_t;
 
-struct timer_event_t {
+struct timer_event_t
+{
     APR_RING_ENTRY(timer_event_t) link;
     apr_time_t when;
     ap_mpm_callback_fn_t *cbfunc;
     void *baton;
-    int canceled;           
-    apr_pollfd_t **remove;  
+    int canceled;
+    apr_array_header_t *remove;
 };
 
 struct fd_queue_t

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1735227&r1=1735226&r2=1735227&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Wed Mar 16 13:09:47 2016
@@ -68,9 +68,9 @@
     APR_HOOK_LINK(mpm) \
     APR_HOOK_LINK(mpm_query) \
     APR_HOOK_LINK(mpm_register_timed_callback) \
-    APR_HOOK_LINK(mpm_register_socket_callback) \
-    APR_HOOK_LINK(mpm_register_socket_callback_timeout) \
-    APR_HOOK_LINK(mpm_unregister_socket_callback) \
+    APR_HOOK_LINK(mpm_register_poll_callback) \
+    APR_HOOK_LINK(mpm_register_poll_callback_timeout) \
+    APR_HOOK_LINK(mpm_unregister_poll_callback) \
     APR_HOOK_LINK(mpm_get_name) \
     APR_HOOK_LINK(mpm_resume_suspended) \
     APR_HOOK_LINK(end_generation) \
@@ -110,15 +110,15 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t
 AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_resume_suspended,
                             (conn_rec *c),
                             (c), APR_ENOTIMPL)
-AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_socket_callback,
-                            (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_callback_fn_t
*cbfn, void *baton),
-                            (s, p, for_read, cbfn, baton), APR_ENOTIMPL)
-AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_socket_callback_timeout,
-                            (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_callback_fn_t
*cbfn, ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout),
-                            (s, p, for_read, cbfn, tofn, baton, timeout), APR_ENOTIMPL)
-AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_unregister_socket_callback,
-                            (apr_socket_t **s, apr_pool_t *p),
-                            (s, p), APR_ENOTIMPL)
+AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_poll_callback,
+                            (apr_array_header_t *pds, ap_mpm_callback_fn_t *cbfn, void *baton),
+                            (pds, cbfn, baton), APR_ENOTIMPL)
+AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_register_poll_callback_timeout,
+                            (apr_array_header_t *pds, ap_mpm_callback_fn_t *cbfn, ap_mpm_callback_fn_t
*tofn, void *baton, apr_time_t timeout),
+                            (pds, cbfn, tofn, baton, timeout), APR_ENOTIMPL)
+AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_unregister_poll_callback,
+                            (apr_array_header_t *pds),
+                            (pds), APR_ENOTIMPL)
 AP_IMPLEMENT_HOOK_RUN_FIRST(int, output_pending,
                             (conn_rec *c), (c), DECLINED)
 AP_IMPLEMENT_HOOK_RUN_FIRST(int, input_pending,
@@ -557,31 +557,35 @@ void ap_core_child_status(server_rec *s,
                  pid, gen, slot, status_msg);
 }
 
-AP_DECLARE(apr_status_t) ap_mpm_resume_suspended(conn_rec *c) {
+AP_DECLARE(apr_status_t) ap_mpm_resume_suspended(conn_rec *c)
+{
     return ap_run_mpm_resume_suspended(c);
 }
 
-AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t, ap_mpm_callback_fn_t
*cbfn, void *baton)
+AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t,
+        ap_mpm_callback_fn_t *cbfn, void *baton)
 {
     return ap_run_mpm_register_timed_callback(t, cbfn, baton);
 }
-AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback(apr_socket_t **s, apr_pool_t *p,
int for_read, ap_mpm_callback_fn_t *cbfn, void *baton)
+
+AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback(apr_array_header_t *pds,
+        ap_mpm_callback_fn_t *cbfn, void *baton)
 {
-    return ap_run_mpm_register_socket_callback(s, p, for_read, cbfn, baton);
+    return ap_run_mpm_register_poll_callback(pds, cbfn, baton);
 }
-AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback_timeout(apr_socket_t **s, 
-                                                                 apr_pool_t *p, 
-                                                                 int for_read, 
-                                                                 ap_mpm_callback_fn_t *cbfn,

-                                                                 ap_mpm_callback_fn_t *tofn,

-                                                                 void *baton, 
-                                                                 apr_time_t timeout)
+
+AP_DECLARE(apr_status_t) ap_mpm_register_poll_callback_timeout(
+        apr_array_header_t *pds, ap_mpm_callback_fn_t *cbfn,
+        ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout)
 {
-    return ap_run_mpm_register_socket_callback_timeout(s, p, for_read, cbfn, tofn, baton,
timeout);
+    return ap_run_mpm_register_poll_callback_timeout(pds, cbfn, tofn, baton,
+            timeout);
 }
-AP_DECLARE(apr_status_t) ap_mpm_unregister_socket_callback(apr_socket_t **s, apr_pool_t *p)
+
+AP_DECLARE(apr_status_t) ap_mpm_unregister_poll_callback(
+        apr_array_header_t *pds)
 {
-    return ap_run_mpm_unregister_socket_callback(s, p);
+    return ap_run_mpm_unregister_poll_callback(pds);
 }
 
 AP_DECLARE(const char *)ap_show_mpm(void)



Mime
View raw message