Loading modules/proxy/mod_proxy.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define CORE_PRIVATE #define CORE_PRIVATE #include "mod_proxy.h" #include "mod_proxy.h" #include "slotmem.h" #include "mod_core.h" #include "mod_core.h" #include "apr_optional.h" #include "apr_optional.h" #include "scoreboard.h" #include "scoreboard.h" Loading Loading @@ -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_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https); proxy_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup); 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; return OK; } } Loading Loading @@ -1994,6 +1998,9 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog, APR_HOOK_MIDDLE); APR_HOOK_MIDDLE); /* Reset workers count on gracefull restart */ /* Reset workers count on gracefull restart */ proxy_lb_workers = 0; proxy_lb_workers = 0; /* get a provider for the shared data storagge */ proxy_lookup_storage_provider(); return OK; return OK; } } static void register_hooks(apr_pool_t *p) static void register_hooks(apr_pool_t *p) Loading modules/proxy/proxy_util.c +33 −12 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,8 @@ /* Utility routines for Apache proxy */ /* Utility routines for Apache proxy */ #include "mod_proxy.h" #include "mod_proxy.h" #include "slotmem.h" #include "ap_mpm.h" #include "ap_mpm.h" #include "scoreboard.h" #include "apr_version.h" #include "apr_version.h" #if APR_HAVE_UNISTD_H #if APR_HAVE_UNISTD_H Loading @@ -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, APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr), (r, pr), (request_rec *r, request_rec *pr), (r, pr), OK, DECLINED) OK, DECLINED) /* Storage for the comarea */ static const slotmem_storage_method *storage = NULL; /* already called in the knowledge that the characters are hex digits */ /* already called in the knowledge that the characters are hex digits */ PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) Loading Loading @@ -1625,11 +1627,10 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, proxy_worker *worker, proxy_worker *worker, server_rec *s) server_rec *s) { { #if PROXY_HAS_SCOREBOARD lb_score *score = NULL; #else void *score = NULL; 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)) { if (worker->s && PROXY_WORKER_IS_INITIALIZED(worker)) { /* The worker share is already initialized */ /* The worker share is already initialized */ Loading @@ -1638,22 +1639,24 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, worker->name); worker->name); return; return; } } #if PROXY_HAS_SCOREBOARD if (storage) { /* Get scoreboard slot */ if (ap_scoreboard_image) { rv = storage->ap_slotmem_create(&myscore, "proxy/comarea", item_size, ap_proxy_lb_workers(), conf->pool); score = ap_get_scoreboard_lb(worker->id); if (rv == APR_SUCCESS) rv = storage->ap_slotmem_mem(myscore, worker->id, &score); if (rv != APR_SUCCESS) score = NULL; if (!score) { if (!score) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, 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); worker->id, getpid(), worker->name); } } else { else { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, 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); worker->id, getpid(), worker->name); } } } } #endif if (!score) { if (!score) { score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, Loading Loading @@ -2215,3 +2218,21 @@ PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r, e = apr_bucket_eos_create(c->bucket_alloc); e = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(brigade, e); 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"); } Loading
modules/proxy/mod_proxy.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define CORE_PRIVATE #define CORE_PRIVATE #include "mod_proxy.h" #include "mod_proxy.h" #include "slotmem.h" #include "mod_core.h" #include "mod_core.h" #include "apr_optional.h" #include "apr_optional.h" #include "scoreboard.h" #include "scoreboard.h" Loading Loading @@ -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_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https); proxy_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup); 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; return OK; } } Loading Loading @@ -1994,6 +1998,9 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog, APR_HOOK_MIDDLE); APR_HOOK_MIDDLE); /* Reset workers count on gracefull restart */ /* Reset workers count on gracefull restart */ proxy_lb_workers = 0; proxy_lb_workers = 0; /* get a provider for the shared data storagge */ proxy_lookup_storage_provider(); return OK; return OK; } } static void register_hooks(apr_pool_t *p) static void register_hooks(apr_pool_t *p) Loading
modules/proxy/proxy_util.c +33 −12 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,8 @@ /* Utility routines for Apache proxy */ /* Utility routines for Apache proxy */ #include "mod_proxy.h" #include "mod_proxy.h" #include "slotmem.h" #include "ap_mpm.h" #include "ap_mpm.h" #include "scoreboard.h" #include "apr_version.h" #include "apr_version.h" #if APR_HAVE_UNISTD_H #if APR_HAVE_UNISTD_H Loading @@ -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, APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr), (r, pr), (request_rec *r, request_rec *pr), (r, pr), OK, DECLINED) OK, DECLINED) /* Storage for the comarea */ static const slotmem_storage_method *storage = NULL; /* already called in the knowledge that the characters are hex digits */ /* already called in the knowledge that the characters are hex digits */ PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) Loading Loading @@ -1625,11 +1627,10 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, proxy_worker *worker, proxy_worker *worker, server_rec *s) server_rec *s) { { #if PROXY_HAS_SCOREBOARD lb_score *score = NULL; #else void *score = NULL; 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)) { if (worker->s && PROXY_WORKER_IS_INITIALIZED(worker)) { /* The worker share is already initialized */ /* The worker share is already initialized */ Loading @@ -1638,22 +1639,24 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, worker->name); worker->name); return; return; } } #if PROXY_HAS_SCOREBOARD if (storage) { /* Get scoreboard slot */ if (ap_scoreboard_image) { rv = storage->ap_slotmem_create(&myscore, "proxy/comarea", item_size, ap_proxy_lb_workers(), conf->pool); score = ap_get_scoreboard_lb(worker->id); if (rv == APR_SUCCESS) rv = storage->ap_slotmem_mem(myscore, worker->id, &score); if (rv != APR_SUCCESS) score = NULL; if (!score) { if (!score) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, 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); worker->id, getpid(), worker->name); } } else { else { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, 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); worker->id, getpid(), worker->name); } } } } #endif if (!score) { if (!score) { score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, Loading Loading @@ -2215,3 +2218,21 @@ PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r, e = apr_bucket_eos_create(c->bucket_alloc); e = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(brigade, e); 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"); }