From: Jean-Frederic Clere Date: Wed, 19 Jul 2006 12:54:07 +0000 (+0000) Subject: Allow to use the new slotmem providers. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e784ba69324fb847c5f74d2865065c1b32095e87;p=thirdparty%2Fapache%2Fhttpd.git Allow to use the new slotmem providers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@423451 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 26aae7fb9ab..af87ac8aae6 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -17,6 +17,7 @@ #define CORE_PRIVATE #include "mod_proxy.h" +#include "slotmem.h" #include "mod_core.h" #include "apr_optional.h" #include "scoreboard.h" @@ -1854,6 +1855,9 @@ static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog, proxy_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https); proxy_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup); + /* if we have a memory provider create the comarea here */ + proxy_create_comarea(pconf); + return OK; } @@ -1994,6 +1998,9 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog, APR_HOOK_MIDDLE); /* Reset workers count on gracefull restart */ proxy_lb_workers = 0; + + /* get a provider for the shared data storagge */ + proxy_lookup_storage_provider(); return OK; } static void register_hooks(apr_pool_t *p) diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index ee3771857f3..8f12d25e57e 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -16,8 +16,8 @@ /* Utility routines for Apache proxy */ #include "mod_proxy.h" +#include "slotmem.h" #include "ap_mpm.h" -#include "scoreboard.h" #include "apr_version.h" #if APR_HAVE_UNISTD_H @@ -41,6 +41,8 @@ static int proxy_match_word(struct dirconn_entry *This, request_rec *r); APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr), (r, pr), OK, DECLINED) +/* Storage for the comarea */ +static const slotmem_storage_method *storage = NULL; /* already called in the knowledge that the characters are hex digits */ PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) @@ -1625,11 +1627,10 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, proxy_worker *worker, server_rec *s) { -#if PROXY_HAS_SCOREBOARD - lb_score *score = NULL; -#else void *score = NULL; -#endif + ap_slotmem_t *myscore; + apr_status_t rv; + apr_size_t item_size = sizeof(proxy_worker_stat); if (worker->s && PROXY_WORKER_IS_INITIALIZED(worker)) { /* The worker share is already initialized */ @@ -1638,22 +1639,24 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, worker->name); return; } -#if PROXY_HAS_SCOREBOARD - /* Get scoreboard slot */ - if (ap_scoreboard_image) { - score = ap_get_scoreboard_lb(worker->id); + if (storage) { + + rv = storage->ap_slotmem_create(&myscore, "proxy/comarea", item_size, ap_proxy_lb_workers(), conf->pool); + if (rv == APR_SUCCESS) + rv = storage->ap_slotmem_mem(myscore, worker->id, &score); + if (rv != APR_SUCCESS) + score = NULL; if (!score) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, - "proxy: ap_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT " for worker %s", + "proxy: ap_slotmem_mem(%d) failed in child %" APR_PID_T_FMT " for worker %s", worker->id, getpid(), worker->name); } else { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "proxy: grabbed scoreboard slot %d in child %" APR_PID_T_FMT " for worker %s", + "proxy: grabbed slotmem slot %d in child %" APR_PID_T_FMT " for worker %s", worker->id, getpid(), worker->name); } } -#endif if (!score) { score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, @@ -2215,3 +2218,21 @@ PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r, e = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(brigade, e); } + +/* Create shared area (comarea) called from mod_proxy post_config */ +PROXY_DECLARE(void) proxy_create_comarea(apr_pool_t *pconf) +{ + ap_slotmem_t *myscore; + apr_size_t item_size = sizeof(proxy_worker_stat); + if (storage) + storage->ap_slotmem_create(&myscore, "proxy/comarea", item_size, ap_proxy_lb_workers(), pconf); +} +/* get the storage provider for the shared area called from mod_proxy pre_config */ +PROXY_DECLARE(void) proxy_lookup_storage_provider() +{ + storage = ap_lookup_provider(SLOTMEM_STORAGE, "shared", "0"); + if (!storage) + storage = ap_lookup_provider(SLOTMEM_STORAGE, "score", "0"); + if (!storage) + storage = ap_lookup_provider(SLOTMEM_STORAGE, "plain", "0"); +}