Commit 5a35be03 authored by Mladen Turk's avatar Mladen Turk
Browse files

Just like for balancers initialize the workers on post_config

instead on first request to skip the race condition.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105064 13f79535-47bb-0310-9956-ffa450edef68
parent d6a90ea3
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1349,7 +1349,6 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
    }
    /* Add the worker to the load balancer */
    ap_proxy_add_worker_to_balancer(cmd->pool, balancer, worker);

    return NULL;
}

@@ -1596,9 +1595,21 @@ PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c)
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;
}

+10 −1
Original line number Diff line number Diff line
@@ -282,7 +282,6 @@ typedef struct {
} 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 */
@@ -409,6 +408,16 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
                                                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
+4 −14
Original line number Diff line number Diff line
@@ -1377,7 +1377,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_close_connection(proxy_conn_rec *conn)
    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;

@@ -1420,13 +1420,13 @@ static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
#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;
}

@@ -1465,16 +1465,6 @@ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
{
    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);