Loading modules/proxy/mod_proxy.c +2 −0 Original line number Diff line number Diff line Loading @@ -1807,6 +1807,8 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog, { APR_OPTIONAL_HOOK(ap, status_hook, proxy_status_hook, NULL, NULL, APR_HOOK_MIDDLE); /* Reset workers count on gracefull restart */ proxy_lb_workers = 0; return OK; } Loading modules/proxy/mod_proxy.h +614 −605 Original line number Diff line number Diff line Loading @@ -595,11 +595,20 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, #else #define PROXY_HAS_SCOREBOARD 0 #endif /* The number of dynamic balancers that can be added */ /* The number of dynamic workers that can be added when reconfiguring. * If this limit is reached you must stop and restart the server. */ #define PROXY_DYNAMIC_BALANCER_LIMIT 16 /** * Calculate number of maximum number of workers in scoreboard. * @return number of workers to allocate in the scoreboard */ int ap_proxy_lb_workers(void); /* For proxy_util */ extern module PROXY_DECLARE_DATA proxy_module; extern int PROXY_DECLARE_DATA proxy_lb_workers; #endif /*MOD_PROXY_H*/ modules/proxy/proxy_balancer.c +4 −3 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ module AP_MODULE_DECLARE_DATA proxy_balancer_module; #define PROXY_BALANCER_UNLOCK(b) APR_SUCCESS #endif static int init_runtime_score(proxy_server_conf *conf, proxy_balancer *balancer) static int init_runtime_score(proxy_server_conf *conf, server_rec *s, proxy_balancer *balancer) { int i; int median, ffactor = 0; Loading @@ -45,6 +45,7 @@ static int init_runtime_score(proxy_server_conf *conf, proxy_balancer *balancer) for (i = 0; i < balancer->workers->nelts; i++) { ap_proxy_initialize_worker_share(conf, workers); ap_proxy_initialize_worker(workers, s); workers->s->status = PROXY_WORKER_INITIALIZED; ++workers; } Loading Loading @@ -441,7 +442,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker, apr_table_setn(r->notes, "session-route", route); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy: BALANCER (%s) worker (%s) rewrritten to %s", "proxy: BALANCER (%s) worker (%s) rewritten to %s", (*balancer)->name, (*worker)->name, *url); return access_status; Loading Loading @@ -786,7 +787,7 @@ static void child_init(apr_pool_t *p, server_rec *s) /* Initialize shared scoreboard data */ balancer = (proxy_balancer *)conf->balancers->elts; for (i = 0; i < conf->balancers->nelts; i++) { init_runtime_score(conf, balancer); init_runtime_score(conf, s, balancer); balancer++; } s = s->next; Loading modules/proxy/proxy_util.c +1843 −1846 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #endif /* Global balancer counter */ static int lb_workers = 0; int PROXY_DECLARE_DATA proxy_lb_workers = 0; static int lb_workers_limit = 0; static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r); Loading Loading @@ -1142,9 +1142,9 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker, if (port == -1) port = apr_uri_port_of_scheme((*worker)->scheme); (*worker)->port = port; (*worker)->id = lb_workers; (*worker)->id = proxy_lb_workers; /* Increase the total worker count */ ++lb_workers; proxy_lb_workers++; init_conn_pool(p, *worker); return NULL; Loading @@ -1155,9 +1155,9 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p) proxy_worker *worker; worker = (proxy_worker *)apr_pcalloc(p, sizeof(proxy_worker)); worker->id = lb_workers; worker->id = proxy_lb_workers; /* Increase the total worker count */ ++lb_workers; proxy_lb_workers++; init_conn_pool(p, worker); return worker; Loading @@ -1169,27 +1169,11 @@ ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer, { proxy_worker *runtime; #if PROXY_HAS_SCOREBOARD int mpm_daemons; ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &mpm_daemons); /* Check if we are prefork or single child */ if (worker->hmax && mpm_daemons > 1) { /* Check only if workers_limit is set */ if (lb_workers_limit && (lb_workers + 1) > lb_workers_limit) { ap_log_perror(APLOG_MARK, APLOG_ERR, 0, pool, "proxy: Can not add worker (%s) to balancer (%s)." " Dynamic limit reached.", worker->name, balancer->name); return; } } #endif runtime = apr_array_push(balancer->workers); memcpy(runtime, worker, sizeof(proxy_worker)); runtime->id = lb_workers; runtime->id = proxy_lb_workers; /* Increase the total runtime count */ ++lb_workers; proxy_lb_workers++; } Loading Loading @@ -1389,16 +1373,25 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, #endif #if PROXY_HAS_SCOREBOARD /* Get scoreboard slot */ if (ap_scoreboard_image) if (ap_scoreboard_image) { score = ap_get_scoreboard_lb(worker->id); if (!score) ap_log_perror(APLOG_MARK, APLOG_ERR, 0, conf->pool, "proxy: ap_get_scoreboard_lb(%d) failed for worker %s", worker->id, worker->name); } #endif if (!score) score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); worker->s = (proxy_worker_stat *)score; if (worker->route) strcpy(worker->s->route, worker->route); else *worker->s->route = '\0'; if (worker->redirect) strcpy(worker->s->redirect, worker->redirect); else *worker->s->redirect = '\0'; } PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s) Loading Loading @@ -1435,8 +1428,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser apr_pool_cleanup_null); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: initialized worker for (%s) min=%d max=%d smax=%d", worker->hostname, worker->min, worker->hmax, worker->smax); "proxy: initialized worker %d for (%s) min=%d max=%d smax=%d", worker->id, worker->hostname, worker->min, worker->hmax, worker->smax); #if (APR_MAJOR_VERSION > 0) /* Set the acquire timeout */ Loading @@ -1450,8 +1443,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser rv = connection_constructor((void **)&(worker->cp->conn), worker, worker->cp->pool); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: initialized single connection worker for (%s)", worker->hostname); "proxy: initialized single connection worker %d for (%s)", worker->id, worker->hostname); } if (rv == APR_SUCCESS) worker->s->status |= PROXY_WORKER_INITIALIZED; Loading Loading @@ -1840,7 +1833,11 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, int ap_proxy_lb_workers(void) { /* Set the dynamic #workers limit */ lb_workers_limit = lb_workers + PROXY_DYNAMIC_BALANCER_LIMIT; /* Since we can't resize the scoreboard when reconfiguring, we * have to impose a limit on the number of workers, we are * able to reconfigure to. */ if (!lb_workers_limit) lb_workers_limit = proxy_lb_workers + PROXY_DYNAMIC_BALANCER_LIMIT; return lb_workers_limit; } Loading
modules/proxy/mod_proxy.c +2 −0 Original line number Diff line number Diff line Loading @@ -1807,6 +1807,8 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog, { APR_OPTIONAL_HOOK(ap, status_hook, proxy_status_hook, NULL, NULL, APR_HOOK_MIDDLE); /* Reset workers count on gracefull restart */ proxy_lb_workers = 0; return OK; } Loading
modules/proxy/mod_proxy.h +614 −605 Original line number Diff line number Diff line Loading @@ -595,11 +595,20 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, #else #define PROXY_HAS_SCOREBOARD 0 #endif /* The number of dynamic balancers that can be added */ /* The number of dynamic workers that can be added when reconfiguring. * If this limit is reached you must stop and restart the server. */ #define PROXY_DYNAMIC_BALANCER_LIMIT 16 /** * Calculate number of maximum number of workers in scoreboard. * @return number of workers to allocate in the scoreboard */ int ap_proxy_lb_workers(void); /* For proxy_util */ extern module PROXY_DECLARE_DATA proxy_module; extern int PROXY_DECLARE_DATA proxy_lb_workers; #endif /*MOD_PROXY_H*/
modules/proxy/proxy_balancer.c +4 −3 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ module AP_MODULE_DECLARE_DATA proxy_balancer_module; #define PROXY_BALANCER_UNLOCK(b) APR_SUCCESS #endif static int init_runtime_score(proxy_server_conf *conf, proxy_balancer *balancer) static int init_runtime_score(proxy_server_conf *conf, server_rec *s, proxy_balancer *balancer) { int i; int median, ffactor = 0; Loading @@ -45,6 +45,7 @@ static int init_runtime_score(proxy_server_conf *conf, proxy_balancer *balancer) for (i = 0; i < balancer->workers->nelts; i++) { ap_proxy_initialize_worker_share(conf, workers); ap_proxy_initialize_worker(workers, s); workers->s->status = PROXY_WORKER_INITIALIZED; ++workers; } Loading Loading @@ -441,7 +442,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker, apr_table_setn(r->notes, "session-route", route); } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy: BALANCER (%s) worker (%s) rewrritten to %s", "proxy: BALANCER (%s) worker (%s) rewritten to %s", (*balancer)->name, (*worker)->name, *url); return access_status; Loading Loading @@ -786,7 +787,7 @@ static void child_init(apr_pool_t *p, server_rec *s) /* Initialize shared scoreboard data */ balancer = (proxy_balancer *)conf->balancers->elts; for (i = 0; i < conf->balancers->nelts; i++) { init_runtime_score(conf, balancer); init_runtime_score(conf, s, balancer); balancer++; } s = s->next; Loading
modules/proxy/proxy_util.c +1843 −1846 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #endif /* Global balancer counter */ static int lb_workers = 0; int PROXY_DECLARE_DATA proxy_lb_workers = 0; static int lb_workers_limit = 0; static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r); Loading Loading @@ -1142,9 +1142,9 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker, if (port == -1) port = apr_uri_port_of_scheme((*worker)->scheme); (*worker)->port = port; (*worker)->id = lb_workers; (*worker)->id = proxy_lb_workers; /* Increase the total worker count */ ++lb_workers; proxy_lb_workers++; init_conn_pool(p, *worker); return NULL; Loading @@ -1155,9 +1155,9 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p) proxy_worker *worker; worker = (proxy_worker *)apr_pcalloc(p, sizeof(proxy_worker)); worker->id = lb_workers; worker->id = proxy_lb_workers; /* Increase the total worker count */ ++lb_workers; proxy_lb_workers++; init_conn_pool(p, worker); return worker; Loading @@ -1169,27 +1169,11 @@ ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer, { proxy_worker *runtime; #if PROXY_HAS_SCOREBOARD int mpm_daemons; ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &mpm_daemons); /* Check if we are prefork or single child */ if (worker->hmax && mpm_daemons > 1) { /* Check only if workers_limit is set */ if (lb_workers_limit && (lb_workers + 1) > lb_workers_limit) { ap_log_perror(APLOG_MARK, APLOG_ERR, 0, pool, "proxy: Can not add worker (%s) to balancer (%s)." " Dynamic limit reached.", worker->name, balancer->name); return; } } #endif runtime = apr_array_push(balancer->workers); memcpy(runtime, worker, sizeof(proxy_worker)); runtime->id = lb_workers; runtime->id = proxy_lb_workers; /* Increase the total runtime count */ ++lb_workers; proxy_lb_workers++; } Loading Loading @@ -1389,16 +1373,25 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf, #endif #if PROXY_HAS_SCOREBOARD /* Get scoreboard slot */ if (ap_scoreboard_image) if (ap_scoreboard_image) { score = ap_get_scoreboard_lb(worker->id); if (!score) ap_log_perror(APLOG_MARK, APLOG_ERR, 0, conf->pool, "proxy: ap_get_scoreboard_lb(%d) failed for worker %s", worker->id, worker->name); } #endif if (!score) score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat)); worker->s = (proxy_worker_stat *)score; if (worker->route) strcpy(worker->s->route, worker->route); else *worker->s->route = '\0'; if (worker->redirect) strcpy(worker->s->redirect, worker->redirect); else *worker->s->redirect = '\0'; } PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s) Loading Loading @@ -1435,8 +1428,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser apr_pool_cleanup_null); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: initialized worker for (%s) min=%d max=%d smax=%d", worker->hostname, worker->min, worker->hmax, worker->smax); "proxy: initialized worker %d for (%s) min=%d max=%d smax=%d", worker->id, worker->hostname, worker->min, worker->hmax, worker->smax); #if (APR_MAJOR_VERSION > 0) /* Set the acquire timeout */ Loading @@ -1450,8 +1443,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser rv = connection_constructor((void **)&(worker->cp->conn), worker, worker->cp->pool); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: initialized single connection worker for (%s)", worker->hostname); "proxy: initialized single connection worker %d for (%s)", worker->id, worker->hostname); } if (rv == APR_SUCCESS) worker->s->status |= PROXY_WORKER_INITIALIZED; Loading Loading @@ -1840,7 +1833,11 @@ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, int ap_proxy_lb_workers(void) { /* Set the dynamic #workers limit */ lb_workers_limit = lb_workers + PROXY_DYNAMIC_BALANCER_LIMIT; /* Since we can't resize the scoreboard when reconfiguring, we * have to impose a limit on the number of workers, we are * able to reconfigure to. */ if (!lb_workers_limit) lb_workers_limit = proxy_lb_workers + PROXY_DYNAMIC_BALANCER_LIMIT; return lb_workers_limit; }