diff options
author | Takashi Sato <takashi@apache.org> | 2014-06-11 18:39:34 +0200 |
---|---|---|
committer | Takashi Sato <takashi@apache.org> | 2014-06-11 18:39:34 +0200 |
commit | 0e4cf76a64040dc0d6d0154603ca189cb32b4ae1 (patch) | |
tree | 2e7e61cbf5b1cb3088b881362befdb2f53285053 | |
parent | mod_ssl: dump SSL IO/state for the write side of the connection(s), like reads. (diff) | |
download | apache2-0e4cf76a64040dc0d6d0154603ca189cb32b4ae1.tar.xz apache2-0e4cf76a64040dc0d6d0154603ca189cb32b4ae1.zip |
Socket event callback now takes pollfd.
User (e.g. mod_proxy_wstunnel) can know
which socket is ready.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1601943 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | include/ap_mmn.h | 8 | ||||
-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 | 4 | ||||
-rw-r--r-- | server/mpm/event/event.c | 16 | ||||
-rw-r--r-- | server/mpm_common.c | 8 |
6 files changed, 28 insertions, 17 deletions
diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 55cc96395d..6aaf04dc1d 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -457,14 +457,18 @@ * 20140207.6 (2.5.0-dev) Added ap_log_common(). * 20140207.7 (2.5.0-dev) Added ap_force_set_tz(). * 20140207.8 (2.5.0-dev) Added ap_shutdown_conn(). + * 20140611.0 (2.5.0-dev) Add ap_mpm_socket_callback_fn_t. + Changes 3rd argument's type of + ap_mpm_register_socket_callback and + ap_mpm_register_socket_callback_timeout. */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20140207 +#define MODULE_MAGIC_NUMBER_MAJOR 20140611 #endif -#define MODULE_MAGIC_NUMBER_MINOR 8 /* 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 d50acd95e3..facabf95e1 100644 --- a/include/ap_mpm.h +++ b/include/ap_mpm.h @@ -198,6 +198,7 @@ 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 *pdf); /* only added support in the Event MPM.... check for APR_ENOTIMPL */ AP_DECLARE(apr_status_t) ap_mpm_resume_suspended(conn_rec *c); @@ -222,7 +223,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_callback_fn_t *cbfn, + ap_mpm_socket_callback_fn_t *cbfn, void *baton); /** * Register a callback on the readability or writability on a group of sockets, with a timeout @@ -243,7 +244,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_callback_fn_t *cbfn, + ap_mpm_socket_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 4031b51ddf..f3a66eed5e 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_callback_fn_t *cbfn, void *baton)) + (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_socket_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_callback_fn_t *cbfn, + ap_mpm_socket_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 3939df2fa2..8ef8761be9 100644 --- a/modules/proxy/mod_proxy_wstunnel.c +++ b/modules/proxy/mod_proxy_wstunnel.c @@ -38,7 +38,7 @@ 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); +static void proxy_wstunnel_callback(void *b, const apr_pollfd_t *dummy); static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_async) { request_rec *r = baton->r; @@ -164,7 +164,7 @@ 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) { +static void proxy_wstunnel_callback(void *b, const apr_pollfd_t *dummy) { int status; apr_socket_t *sockets[3] = {NULL, NULL, NULL}; ws_baton_t *baton = (ws_baton_t*)b; diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 2f5229aaa2..9979ee03e5 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -320,7 +320,7 @@ typedef struct typedef struct { - ap_mpm_callback_fn_t *cbfunc; + ap_mpm_socket_callback_fn_t *cbfunc; void *user_baton; apr_pollfd_t **pfds; int nsock; @@ -1488,7 +1488,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_callback_fn_t *cbfn, + ap_mpm_socket_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout) @@ -1536,7 +1536,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_callback_fn_t *cbfn, + ap_mpm_socket_callback_fn_t *cbfn, void *baton) { return event_register_socket_callback_ex(s, p, for_read, @@ -1657,6 +1657,12 @@ 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) { timer_event_t *ep; @@ -1974,8 +1980,8 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy) if (!(baton->signaled)) { baton->signaled = 1; te = event_get_timer_event(-1 /* fake timer */, - baton->cbfunc, - baton->user_baton, + socket_callback_wrapper, + (apr_pollfd_t *)out_pfd, 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 387c5cd06b..1fba06e810 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_callback_fn_t *cbfn, void *baton), + (apr_socket_t **s, apr_pool_t *p, int for_read, ap_mpm_socket_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), + (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), (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_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_socket_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_callback_fn_t *cbfn, + ap_mpm_socket_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout) |