balancer = NULL;
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)
max_attempts = balancer->max_attempts;
/* firstly, try a proxy, unless a NoProxy directive is active */
worker = (proxy_worker *)conf->workers->elts;
for (i = 0; i < conf->workers->nelts; i++) {
ap_proxy_initialize_worker_share(conf, worker, s);
- ap_proxy_initialize_worker(worker, s);
+ ap_proxy_initialize_worker(worker, s, p);
worker++;
}
/* Create and initialize forward worker if defined */
conf->forward->hostname = "*";
conf->forward->scheme = "*";
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 */
conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
/* Disable address cache for generic forward worker */
reverse->hostname = "*";
reverse->scheme = "*";
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 */
reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;
/* Disable address cache for generic reverse worker */
* Initize the worker
* @param worker worker to initialize
* @param s current server record
+ * @param p memory pool used for mutex and Connection pool.
* @return APR_SUCCESS or error code
*/
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
* @param p memory pool used for finding balancer
}
}
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) {
/* Set to the original configuration */
(*workers)->s->lbstatus = (*workers)->s->lbfactor =
(*worker)->smax = -1;
/* Increase the total worker count */
proxy_lb_workers++;
- init_conn_pool(p, *worker);
-#if APR_HAS_THREADS
- 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
+ (*worker)->cp = NULL;
+ (*worker)->mutex = NULL;
return NULL;
}
worker->smax = -1;
/* Increase the total worker count */
proxy_lb_workers++;
- init_conn_pool(p, worker);
+ worker->cp = NULL;
+ worker->mutex = NULL;
return worker;
}
}
-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;
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 (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);
if (mpm_threads > 1) {
/* Set hard max to no more then mpm_threads */