diff options
author | Takashi Sato <takashi@apache.org> | 2014-06-27 06:17:30 +0200 |
---|---|---|
committer | Takashi Sato <takashi@apache.org> | 2014-06-27 06:17:30 +0200 |
commit | 3d83bde5eff816af96487fd64a6411f241643497 (patch) | |
tree | 5afd426e57c63efbfe6880c7f6b364f4e22f0998 | |
parent | Update transformations. (diff) | |
download | apache2-3d83bde5eff816af96487fd64a6411f241643497.tar.xz apache2-3d83bde5eff816af96487fd64a6411f241643497.zip |
Revert r1601943, r1602058, r1605307 (socket callback returning pollfds)
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
-rw-r--r-- | include/ap_mmn.h | 5 | ||||
-rw-r--r-- | include/ap_mpm.h | 5 | ||||
-rw-r--r-- | include/mpm_common.h | 4 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_wstunnel.c | 109 | ||||
-rw-r--r-- | server/mpm/event/event.c | 18 | ||||
-rw-r--r-- | server/mpm_common.c | 8 |
6 files changed, 70 insertions, 79 deletions
diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 7c84de1188..c01fb3461f 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -462,14 +462,15 @@ 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 diff --git a/include/ap_mpm.h b/include/ap_mpm.h index f70865929c..d50acd95e3 100644 --- a/include/ap_mpm.h +++ b/include/ap_mpm.h @@ -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); diff --git a/include/mpm_common.h b/include/mpm_common.h index f3a66eed5e..4031b51ddf 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -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)) diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c index 1e810d7adb..cba25a0cb1 100644 --- a/modules/proxy/mod_proxy_wstunnel.c +++ b/modules/proxy/mod_proxy_wstunnel.c @@ -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, diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 382fcd582f..3eb2ba2367 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -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 */ diff --git a/server/mpm_common.c b/server/mpm_common.c index 1fba06e810..387c5cd06b 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -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) |