mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Allow the load balancing method to "create" workers.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@774400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -940,6 +940,13 @@ static int proxy_handler(request_rec *r)
|
|||||||
balancer = NULL;
|
balancer = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialise worker if needed, note the shared area must be initialized by the balancer logic */
|
||||||
|
if (balancer) {
|
||||||
|
ap_proxy_initialize_worker(worker, r->server, conf->pool);
|
||||||
|
ap_proxy_initialize_worker_share(conf, worker, r->server);
|
||||||
|
}
|
||||||
|
|
||||||
if (balancer && balancer->max_attempts_set && !max_attempts)
|
if (balancer && balancer->max_attempts_set && !max_attempts)
|
||||||
max_attempts = balancer->max_attempts;
|
max_attempts = balancer->max_attempts;
|
||||||
/* firstly, try a proxy, unless a NoProxy directive is active */
|
/* firstly, try a proxy, unless a NoProxy directive is active */
|
||||||
@@ -2295,7 +2302,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
|
|||||||
worker = (proxy_worker *)conf->workers->elts;
|
worker = (proxy_worker *)conf->workers->elts;
|
||||||
for (i = 0; i < conf->workers->nelts; i++) {
|
for (i = 0; i < conf->workers->nelts; i++) {
|
||||||
ap_proxy_initialize_worker_share(conf, worker, s);
|
ap_proxy_initialize_worker_share(conf, worker, s);
|
||||||
ap_proxy_initialize_worker(worker, s);
|
ap_proxy_initialize_worker(worker, s, p);
|
||||||
worker++;
|
worker++;
|
||||||
}
|
}
|
||||||
/* Create and initialize forward worker if defined */
|
/* Create and initialize forward worker if defined */
|
||||||
@@ -2305,7 +2312,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
|
|||||||
conf->forward->hostname = "*";
|
conf->forward->hostname = "*";
|
||||||
conf->forward->scheme = "*";
|
conf->forward->scheme = "*";
|
||||||
ap_proxy_initialize_worker_share(conf, conf->forward, s);
|
ap_proxy_initialize_worker_share(conf, conf->forward, s);
|
||||||
ap_proxy_initialize_worker(conf->forward, s);
|
ap_proxy_initialize_worker(conf->forward, s, p);
|
||||||
/* Do not disable worker in case of errors */
|
/* Do not disable worker in case of errors */
|
||||||
conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
|
conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
|
||||||
/* Disable address cache for generic forward worker */
|
/* Disable address cache for generic forward worker */
|
||||||
@@ -2317,7 +2324,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
|
|||||||
reverse->hostname = "*";
|
reverse->hostname = "*";
|
||||||
reverse->scheme = "*";
|
reverse->scheme = "*";
|
||||||
ap_proxy_initialize_worker_share(conf, reverse, s);
|
ap_proxy_initialize_worker_share(conf, reverse, s);
|
||||||
ap_proxy_initialize_worker(reverse, s);
|
ap_proxy_initialize_worker(reverse, s, p);
|
||||||
/* Do not disable worker in case of errors */
|
/* Do not disable worker in case of errors */
|
||||||
reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;
|
reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;
|
||||||
/* Disable address cache for generic reverse worker */
|
/* Disable address cache for generic reverse worker */
|
||||||
|
@@ -570,10 +570,12 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
|
|||||||
* Initize the worker
|
* Initize the worker
|
||||||
* @param worker worker to initialize
|
* @param worker worker to initialize
|
||||||
* @param s current server record
|
* @param s current server record
|
||||||
|
* @param p memory pool used for mutex and Connection pool.
|
||||||
* @return APR_SUCCESS or error code
|
* @return APR_SUCCESS or error code
|
||||||
*/
|
*/
|
||||||
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
|
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
|
||||||
server_rec *s);
|
server_rec *s,
|
||||||
|
apr_pool_t *p);
|
||||||
/**
|
/**
|
||||||
* Get the balancer from proxy configuration
|
* Get the balancer from proxy configuration
|
||||||
* @param p memory pool used for finding balancer
|
* @param p memory pool used for finding balancer
|
||||||
|
@@ -104,7 +104,7 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ap_proxy_initialize_worker_share(conf, *workers, s);
|
ap_proxy_initialize_worker_share(conf, *workers, s);
|
||||||
ap_proxy_initialize_worker(*workers, s);
|
ap_proxy_initialize_worker(*workers, s, conf->pool);
|
||||||
if (!worker_is_initialized) {
|
if (!worker_is_initialized) {
|
||||||
/* Set to the original configuration */
|
/* Set to the original configuration */
|
||||||
(*workers)->s->lbstatus = (*workers)->s->lbfactor =
|
(*workers)->s->lbstatus = (*workers)->s->lbfactor =
|
||||||
|
@@ -1443,14 +1443,8 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
|
|||||||
(*worker)->smax = -1;
|
(*worker)->smax = -1;
|
||||||
/* Increase the total worker count */
|
/* Increase the total worker count */
|
||||||
proxy_lb_workers++;
|
proxy_lb_workers++;
|
||||||
init_conn_pool(p, *worker);
|
(*worker)->cp = NULL;
|
||||||
#if APR_HAS_THREADS
|
(*worker)->mutex = NULL;
|
||||||
if (apr_thread_mutex_create(&((*worker)->mutex),
|
|
||||||
APR_THREAD_MUTEX_DEFAULT, p) != APR_SUCCESS) {
|
|
||||||
/* XXX: Do we need to log something here */
|
|
||||||
return "can not create thread mutex";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1464,7 +1458,8 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p)
|
|||||||
worker->smax = -1;
|
worker->smax = -1;
|
||||||
/* Increase the total worker count */
|
/* Increase the total worker count */
|
||||||
proxy_lb_workers++;
|
proxy_lb_workers++;
|
||||||
init_conn_pool(p, worker);
|
worker->cp = NULL;
|
||||||
|
worker->mutex = NULL;
|
||||||
|
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
@@ -1839,7 +1834,7 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s)
|
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s, apr_pool_t *p)
|
||||||
{
|
{
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
|
|
||||||
@@ -1864,7 +1859,24 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
|
|||||||
worker->is_address_reusable = 1;
|
worker->is_address_reusable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (worker->cp == NULL)
|
||||||
|
init_conn_pool(p, worker);
|
||||||
|
if (worker->cp == NULL) {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
|
||||||
|
"can not create connection pool");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
#if APR_HAS_THREADS
|
#if APR_HAS_THREADS
|
||||||
|
if (worker->mutex == NULL) {
|
||||||
|
rv = apr_thread_mutex_create(&(worker->mutex), APR_THREAD_MUTEX_DEFAULT, p);
|
||||||
|
if (rv != APR_SUCCESS) {
|
||||||
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
|
||||||
|
"can not create thread mutex");
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads);
|
ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads);
|
||||||
if (mpm_threads > 1) {
|
if (mpm_threads > 1) {
|
||||||
/* Set hard max to no more then mpm_threads */
|
/* Set hard max to no more then mpm_threads */
|
||||||
|
Reference in New Issue
Block a user