Commit 837320ca authored by Jim Jagielski's avatar Jim Jagielski
Browse files

OK, handle better the initializing of worker, separating

"shared" and "local" inits, and being aware that if the
shared aspects are initialized, this doesn't mean
the local ones are :)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@377780 13f79535-47bb-0310-9956-ffa450edef68
parent 258a4135
Loading
Loading
Loading
Loading
+34 −14
Changes for modules/proxy/proxy_util.c: 34 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -1570,6 +1570,11 @@ static apr_status_t connection_destructor(void *resource, void *params,
}
#endif

/*
 * ap_proxy_initialize_worker_share() concerns itself
 * with initializing those parts of worker which
 * are, or could be, shared. Basically worker->s
 */
PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
                                                     proxy_worker *worker,
                                                     server_rec *s)
@@ -1593,23 +1598,34 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
        score = ap_get_scoreboard_lb(worker->id);
        if (!score) {
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                  "proxy: ap_get_scoreboard_lb(%d) failed for worker %s",
                  worker->id, worker->name);
                  "proxy: ap_get_scoreboard_lb(%d) failed in child %" APR_PID_T_FMT " for worker %s",
                  worker->id, getpid(), worker->name);
        }
        else {
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "proxy: initialized scoreboard slot %d for worker %s",
                  worker->id, worker->name);
                  "proxy: grabbed scoreboard slot %d in child %" APR_PID_T_FMT " for worker %s",
                  worker->id, getpid(), worker->name);
        }
    }
#endif
    if (!score) {
        score = apr_pcalloc(conf->pool, sizeof(proxy_worker_stat));
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
              "proxy: initialized plain memory for worker %s",
              worker->name);
              "proxy: initialized plain memory in child %" APR_PID_T_FMT " for worker %s",
              getpid(), worker->name);
    }
    worker->s = (proxy_worker_stat *)score;
    /*
     * recheck to see if we've already been here. Possible
     * if proxy is using scoreboard to hold shared stats
     */
    if (worker->s->status & PROXY_WORKER_INITIALIZED) {
        /* The worker share is already initialized */
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
              "proxy: worker %s already initialized",
              worker->name);
        return;
    }
    if (worker->route)
        strcpy(worker->s->route, worker->route);
    else
@@ -1618,11 +1634,8 @@ PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
        strcpy(worker->s->redirect, worker->redirect);
    else
        *worker->s->redirect = '\0';
    /* Set default parameters */
    if (!worker->retry)
        worker->retry = apr_time_from_sec(PROXY_WORKER_DEFAULT_RETRY);
    /* By default address is reusable */
    worker->is_address_reusable = 1;

    worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED);

}

@@ -1634,11 +1647,17 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
    int mpm_threads;
#endif

    if (worker->s->status & PROXY_WORKER_INITIALIZED) {
    if (worker->status & PROXY_WORKER_INITIALIZED) {
        /* The worker is already initialized */
        return APR_SUCCESS;
    }

    /* Set default parameters */
    if (!worker->retry)
        worker->retry = apr_time_from_sec(PROXY_WORKER_DEFAULT_RETRY);
    /* By default address is reusable */
    worker->is_address_reusable = 1;

#if APR_HAS_THREADS
    ap_mpm_query(AP_MPMQ_MAX_THREADS, &mpm_threads);
    if (mpm_threads > 1) {
@@ -1686,8 +1705,9 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
             "proxy: initialized single connection worker %d in child %" APR_PID_T_FMT " for (%s)",
             worker->id, getpid(), worker->hostname);
    }
    if (rv == APR_SUCCESS)
        worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED);
    if (rv == APR_SUCCESS) {
        worker->status |= (PROXY_WORKER_INITIALIZED);
    }
    return rv;
}