]> granicus.if.org Git - apache/commitdiff
Revert r1601943, r1602058, r1605307 (socket callback returning pollfds)
authorTakashi Sato <takashi@apache.org>
Fri, 27 Jun 2014 04:17:30 +0000 (04:17 +0000)
committerTakashi Sato <takashi@apache.org>
Fri, 27 Jun 2014 04:17:30 +0000 (04:17 +0000)
Revert r1605369 (wstunnel refactoring)

per discassion on dev@httpd.a.o thread Message-ID:
<CALK=YjN9HfThP_k_rF9iJPcUhcQk9sNOaDPxZNG+HcJNWS4ZAQ@mail.gmail.com>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1605946 13f79535-47bb-0310-9956-ffa450edef68

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_common.c

index 7c84de1188377d68b279b472a3495589566b0836..c01fb3461fcc71f279ddacbe0027bffdf7e18332 100644 (file)
                            ap_mpm_register_socket_callback and 
                            ap_mpm_register_socket_callback_timeout.
  * 20140611.1 (2.5.0-dev)  Add ap_proxy_connect_uds().
+ * 20140627.0 (2.5.0-dev)  Revert 20140611.0 change.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20140611
+#define MODULE_MAGIC_NUMBER_MAJOR 20140627
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index f70865929c8049dd40172b8346689a2b6c918ac3..d50acd95e3af312aaaad4fc69472dc73affb59f4 100644 (file)
@@ -198,7 +198,6 @@ AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result);
 /** @} */
 
 typedef void (ap_mpm_callback_fn_t)(void *baton);
-typedef void (ap_mpm_socket_callback_fn_t)(void *baton, const apr_pollfd_t *pfd);
 
 /* only added support in the Event MPM....  check for APR_ENOTIMPL */
 AP_DECLARE(apr_status_t) ap_mpm_resume_suspended(conn_rec *c);
@@ -223,7 +222,7 @@ AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t,
 AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback(apr_socket_t **s,
                                                          apr_pool_t *p,
                                                          int for_read, 
-                                                         ap_mpm_socket_callback_fn_t *cbfn,
+                                                         ap_mpm_callback_fn_t *cbfn,
                                                          void *baton);
  /**
  * Register a callback on the readability or writability on a group of sockets, with a timeout
@@ -244,7 +243,7 @@ AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback(apr_socket_t **s,
 AP_DECLARE(apr_status_t) ap_mpm_register_socket_callback_timeout(apr_socket_t **s,
                                                          apr_pool_t *p,
                                                          int for_read, 
-                                                         ap_mpm_socket_callback_fn_t *cbfn,
+                                                         ap_mpm_callback_fn_t *cbfn,
                                                          ap_mpm_callback_fn_t *tofn,
                                                          void *baton,
                                                          apr_time_t timeout);
index f3a66eed5eb0a181416ad02d1be673ad48d25c9d..4031b51ddf1f96175f044f74cdac07d77387d13e 100644 (file)
@@ -427,7 +427,7 @@ AP_DECLARE_HOOK(apr_status_t, mpm_register_timed_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_socket_callback_fn_t *cbfn, void *baton))
+                (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_callback_fn_t *cbfn, void *baton))
 
 /* register the specified callback, with timeout 
  * @ingroup hooks
@@ -435,7 +435,7 @@ AP_DECLARE_HOOK(apr_status_t, mpm_register_socket_callback,
  */
 AP_DECLARE_HOOK(apr_status_t, mpm_register_socket_callback_timeout,
                 (apr_socket_t **s, apr_pool_t *p, int for_read, 
-                 ap_mpm_socket_callback_fn_t *cbfn,  
+                 ap_mpm_callback_fn_t *cbfn,  
                  ap_mpm_callback_fn_t *tofn, 
                  void *baton, 
                  apr_time_t timeout))
index 1e810d7adbdad592a71543c0bedf921eb2183cdc..cba25a0cb18027e35ae18f298ba15e6153683d74 100644 (file)
@@ -38,68 +38,21 @@ typedef struct ws_baton_t {
 
 static apr_status_t proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
                                      apr_bucket_brigade *bb, char *name);
-static void proxy_wstunnel_callback(void *b, const apr_pollfd_t *pfd);
+static void proxy_wstunnel_callback(void *b);
 
-static apr_status_t proxy_wstunnel_pump2(ws_baton_t *baton, const apr_pollfd_t *pfd){
+static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_async) {
     request_rec *r = baton->r;
     conn_rec *c = r->connection;
     proxy_conn_rec *conn = baton->proxy_connrec;
     apr_socket_t *sock = conn->sock;
     conn_rec *backconn = conn->connection;
-    apr_int16_t pollevent;
-    apr_socket_t *client_socket = baton->client_soc;
-    apr_bucket_brigade *bb = baton->bb;
-
-    if (pfd->desc.s == sock) {
-        pollevent = pfd->rtnevents;
-        if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
-                    "sock was readable");
-            return proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
-        }
-        else if (pollevent & APR_POLLERR) {
-            ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
-                    "error on backconn");
-            return APR_EPIPE;
-        }
-        else { 
-            ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
-                    "unknown event on backconn %d", pollevent);
-            return APR_EGENERAL;
-        }
-    }
-    else if (pfd->desc.s == client_socket) {
-        pollevent = pfd->rtnevents;
-        if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
-                    "client was readable");
-            return proxy_wstunnel_transfer(r, c, backconn, bb, "client");
-        }
-        else if (pollevent & APR_POLLERR) {
-            ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
-                    "error on client conn");
-            c->aborted = 1;
-            return APR_EPIPE;
-        }
-        else { 
-            ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02606)
-                    "unknown event on client conn %d", pollevent);
-            return APR_EGENERAL;
-        }
-    }
-    else {
-        ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02449)
-                "unknown socket in pollset");
-        return APR_EBADF;
-    }
-}
-
-static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_async) {
-    request_rec *r = baton->r;
     const apr_pollfd_t *signalled;
     apr_int32_t pollcnt, pi;
+    apr_int16_t pollevent;
     apr_pollset_t *pollset = baton->pollset;
+    apr_socket_t *client_socket = baton->client_soc;
     apr_status_t rv;
+    apr_bucket_brigade *bb = baton->bb;
 
     while(1) { 
         if ((rv = apr_pollset_poll(pollset, timeout, &pollcnt, &signalled))
@@ -126,7 +79,51 @@ static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_as
                 "woke from poll(), i=%d", pollcnt);
 
         for (pi = 0; pi < pollcnt; pi++) {
-            rv = proxy_wstunnel_pump2(baton, &signalled[pi]);
+            const apr_pollfd_t *cur = &signalled[pi];
+
+            if (cur->desc.s == sock) {
+                pollevent = cur->rtnevents;
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
+                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
+                            "sock was readable");
+                    rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
+                }
+                else if (pollevent & APR_POLLERR) {
+                    rv = APR_EPIPE;
+                    ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
+                            "error on backconn");
+                }
+                else { 
+                    rv = APR_EGENERAL;
+                    ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
+                            "unknown event on backconn %d", pollevent);
+                }
+            }
+            else if (cur->desc.s == client_socket) {
+                pollevent = cur->rtnevents;
+                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
+                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
+                            "client was readable");
+                    rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
+                }
+                else if (pollevent & APR_POLLERR) {
+                    rv = APR_EPIPE;
+                    c->aborted = 1;
+                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
+                            "error on client conn");
+                }
+                else { 
+                    rv = APR_EGENERAL;
+                    ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02606)
+                            "unknown event on client conn %d", pollevent);
+                }
+            }
+            else {
+                rv = APR_EBADF;
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02449)
+                        "unknown socket in pollset");
+            }
+
         }
         if (rv != APR_SUCCESS) {
             break;
@@ -168,12 +165,14 @@ static void proxy_wstunnel_cancel_callback(void *b)
  *  We don't need the invoke_mtx, since we never put multiple callback events
  *  in the queue.
  */
-static void proxy_wstunnel_callback(void *b, const apr_pollfd_t *pfd) { 
+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);
-    if (proxy_wstunnel_pump2(baton, pfd) == APR_SUCCESS) {
+    status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->is_async);
+    if (status == SUSPENDED) {
         sockets[0] = baton->client_soc;
         sockets[1] = baton->server_soc;
         ap_mpm_register_socket_callback_timeout(sockets, baton->subpool, 1, 
index 382fcd582f6b522a0ab53750b9054404d8c2e8e1..3eb2ba2367373fca8f44fe1f5cc76a1e25b94ceb 100644 (file)
@@ -320,7 +320,7 @@ typedef struct
 
 typedef struct
 {
- ap_mpm_socket_callback_fn_t *cbfunc;
+ ap_mpm_callback_fn_t *cbfunc;
  void *user_baton; 
  apr_pollfd_t **pfds;
  int nsock;
@@ -1478,7 +1478,7 @@ static apr_status_t event_register_timed_callback(apr_time_t t,
 static apr_status_t event_register_socket_callback_ex(apr_socket_t **s, 
                                                   apr_pool_t *p, 
                                                   int for_read,
-                                                  ap_mpm_socket_callback_fn_t *cbfn,
+                                                  ap_mpm_callback_fn_t *cbfn,
                                                   ap_mpm_callback_fn_t *tofn,
                                                   void *baton, 
                                                   apr_time_t timeout)
@@ -1526,7 +1526,7 @@ static apr_status_t event_register_socket_callback_ex(apr_socket_t **s,
 static apr_status_t event_register_socket_callback(apr_socket_t **s, 
                                                   apr_pool_t *p, 
                                                   int for_read,
-                                                  ap_mpm_socket_callback_fn_t *cbfn,
+                                                  ap_mpm_callback_fn_t *cbfn,
                                                   void *baton)
 {
     return event_register_socket_callback_ex(s, p, for_read, 
@@ -1647,12 +1647,6 @@ static void process_timeout_queue(struct timeout_queue *q,
     apr_thread_mutex_lock(timeout_mutex);
 }
 
-static void socket_callback_wrapper(void *baton){
-    const apr_pollfd_t *out_pfd = (const apr_pollfd_t *)baton;
-    socket_callback_baton_t *scb_baton = (socket_callback_baton_t *) ((listener_poll_type *) out_pfd->client_data)->baton;
-    scb_baton->cbfunc(scb_baton->user_baton, out_pfd);
-}
-
 static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
 {
     apr_status_t rc;
@@ -1967,12 +1961,10 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
 
                 /* We only signal once per N sockets with this baton */
                 if (!(baton->signaled)) { 
-                    apr_pollfd_t *newpfd = apr_palloc(out_pfd->p, sizeof(apr_pollfd_t));
                     baton->signaled = 1;
-                    *newpfd = *out_pfd;
                     te = event_get_timer_event(-1 /* fake timer */, 
-                                               socket_callback_wrapper
-                                               newpfd,
+                                               baton->cbfunc
+                                               baton->user_baton, 
                                                0, /* don't insert it */
                                                NULL /* no associated socket callback */);
                     /* remove other sockets in my set */
index 1fba06e810b0fe211e7c10b87f7a5cbc8840d9d8..387c5cd06b0fc63aa0dcf56c1772d82e08b5b9e0 100644 (file)
@@ -108,10 +108,10 @@ 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_socket_callback_fn_t *cbfn, void *baton),
+                            (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_socket_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t 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),
@@ -559,14 +559,14 @@ AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t, ap_mpm_cal
 {
     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_socket_callback_fn_t *cbfn, void *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)
 {
     return ap_run_mpm_register_socket_callback(s, p, for_read, 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_socket_callback_fn_t *cbfn, 
+                                                                 ap_mpm_callback_fn_t *cbfn, 
                                                                  ap_mpm_callback_fn_t *tofn, 
                                                                  void *baton, 
                                                                  apr_time_t timeout)