From: Jeff Trawick Date: Thu, 2 Apr 2009 10:05:39 +0000 (+0000) Subject: handle an unfortunate implication of loadable MPMs: X-Git-Tag: 2.3.3~737 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6652d949eb9c28cc195f645578c7203667d10c9;p=thirdparty%2Fapache%2Fhttpd.git handle an unfortunate implication of loadable MPMs: calls to ap_mpm_query() must be deferred until after the register-hooks hook, since that's where the MPM registers its mpm-query hook git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@761226 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 2108b869ad4..5a3c7055e99 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -41,8 +41,10 @@ AP_DECLARE_DATA ap_filter_rec_t *ap_chunk_filter_handle; AP_DECLARE_DATA ap_filter_rec_t *ap_http_outerror_filter_handle; AP_DECLARE_DATA ap_filter_rec_t *ap_byterange_filter_handle; -static int ap_process_http_connection(conn_rec *c); - +/* If we are using an MPM That Supports Async Connections, + * use a different processing function + */ +static int async_mpm = 0; static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy, const char *arg) @@ -130,10 +132,6 @@ static int ap_process_http_async_connection(conn_rec *c) request_rec *r; conn_state_t *cs = c->cs; - if (c->clogging_input_filters) { - return ap_process_http_connection(c); - } - AP_DEBUG_ASSERT(cs->state == CONN_STATE_READ_REQUEST_LINE); while (cs->state == CONN_STATE_READ_REQUEST_LINE) { @@ -172,7 +170,7 @@ static int ap_process_http_async_connection(conn_rec *c) return OK; } -static int ap_process_http_connection(conn_rec *c) +static int ap_process_http_sync_connection(conn_rec *c) { request_rec *r; conn_state_t *cs = c->cs; @@ -228,6 +226,16 @@ static int ap_process_http_connection(conn_rec *c) return OK; } +static int ap_process_http_connection(conn_rec *c) +{ + if (async_mpm && !c->clogging_input_filters) { + return ap_process_http_async_connection(c); + } + else { + return ap_process_http_sync_connection(c); + } +} + static int http_create_request(request_rec *r) { if (!r->main && !r->prev) { @@ -253,23 +261,19 @@ static int http_send_options(request_rec *r) return DECLINED; } -static void register_hooks(apr_pool_t *p) +static int http_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { - /** - * If we ae using an MPM That Supports Async Connections, - * use a different processing function - */ - int async_mpm = 0; - if (ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm) == APR_SUCCESS - && async_mpm == 1) { - ap_hook_process_connection(ap_process_http_async_connection, NULL, - NULL, APR_HOOK_REALLY_LAST); - } - else { - ap_hook_process_connection(ap_process_http_connection, NULL, NULL, - APR_HOOK_REALLY_LAST); + if (ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm) != APR_SUCCESS) { + async_mpm = 0; } + return OK; +} +static void register_hooks(apr_pool_t *p) +{ + ap_hook_post_config(http_post_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_process_connection(ap_process_http_connection, NULL, NULL, + APR_HOOK_REALLY_LAST); ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_map_to_storage(http_send_options,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_http_scheme(http_scheme,NULL,NULL,APR_HOOK_REALLY_LAST); diff --git a/modules/proxy/mod_serf.c b/modules/proxy/mod_serf.c index c0942463dda..056e3d5dbc4 100644 --- a/modules/proxy/mod_serf.c +++ b/modules/proxy/mod_serf.c @@ -1079,7 +1079,7 @@ static const ap_serf_cluster_provider_t builtin_static = NULL }; -static void register_hooks(apr_pool_t *p) +static int serf_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { apr_status_t rv; rv = ap_mpm_query(AP_MPMQ_HAS_SERF, &mpm_supprts_serf); @@ -1088,12 +1088,19 @@ static void register_hooks(apr_pool_t *p) mpm_supprts_serf = 0; } + return OK; +} + +static void register_hooks(apr_pool_t *p) +{ ap_register_provider(p, AP_SERF_CLUSTER_PROVIDER, "heartbeat", "0", &builtin_heartbeat); ap_register_provider(p, AP_SERF_CLUSTER_PROVIDER, "static", "0", &builtin_static); + ap_hook_post_config(serf_post_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_handler(serf_handler, NULL, NULL, APR_HOOK_FIRST); }