}
/* Add the worker to the load balancer */
ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);
-
return NULL;
}
static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
+ proxy_server_conf *conf =
+ (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
+ proxy_worker *worker;
+ int i;
+
proxy_ssl_enable = APR_RETRIEVE_OPTIONAL_FN(ssl_proxy_enable);
proxy_ssl_disable = APR_RETRIEVE_OPTIONAL_FN(ssl_engine_disable);
+ /* Initialize all the workers */
+ worker = (proxy_worker *)conf->workers->elts;
+ for (i = 0; i < conf->workers->nelts; i++) {
+ ap_proxy_initialize_worker(worker, s);
+ worker++;
+ }
+
return OK;
}
} proxy_runtime_worker;
struct proxy_balancer {
- int status;
apr_array_header_t *workers; /* array of proxy_runtime_workers */
const char *name; /* name of the load balancer */
const char *sticky; /* sticky session identifier */
apr_pool_t *p,
proxy_server_conf *conf,
const char *url);
+
+/**
+ * Initize the worker
+ * @param worker the new worker
+ * @param p memory pool to allocate worker from
+ * @param s current server record
+ * @return APR_SUCCESS or error code
+ */
+PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
+ server_rec *s);
/**
* Get the balancer from proxy configuration
* @param p memory pool used for finding balancer
return connection_destructor(conn, NULL, NULL);
}
-static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
+PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s)
{
apr_status_t rv;
#endif
{
- connection_constructor((void **)&(worker->cp->conn), s, worker->cp->pool);
- rv = APR_SUCCESS;
+ rv = connection_constructor((void **)&(worker->cp->conn), s, worker->cp->pool);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"proxy: initialized single connection worker for (%s)",
worker->hostname);
}
-
+ if (rv == APR_SUCCESS)
+ worker->status |= PROXY_WORKER_INITIALIZED;
return rv;
}
{
apr_status_t rv;
- if (!(worker->status & PROXY_WORKER_INITIALIZED)) {
- if ((rv = init_conn_worker(worker, s)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
- "proxy: %s: failed to initialize worker for (%s)",
- proxy_function, worker->hostname);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- worker->status |= PROXY_WORKER_INITIALIZED;
- }
-
if (!PROXY_WORKER_IS_USABLE(worker)) {
/* Retry the worker */
ap_proxy_retry_worker(proxy_function, worker, s);