Commit d048a32d authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Ugg... unbalanced workers *do* need a mutex as well (good catch Rüdiger!)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1068879 13f79535-47bb-0310-9956-ffa450edef68
parent 97d17394
Loading
Loading
Loading
Loading
+2 −1
Changes for modules/proxy/mod_proxy.h: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -376,6 +376,7 @@ struct proxy_worker {
    proxy_conn_pool     *cp;    /* Connection pool to use */
    proxy_worker_shared   *s;   /* Shared data */
    proxy_balancer  *balancer;  /* which balancer am I in? */
    apr_thread_mutex_t  *tmutex; /* Thread lock for updating address cache */
    void            *context;   /* general purpose storage */
};

@@ -413,7 +414,7 @@ struct proxy_balancer {
    const char *sname;            /* filesystem safe balancer name */
    apr_time_t      wupdated;    /* timestamp of last change to workers list */
    apr_global_mutex_t  *gmutex; /* global lock for updating list of workers */
    apr_thread_mutex_t  *tmutex; /* Thread lock for updating address cache and worker selection*/
    apr_thread_mutex_t  *tmutex; /* Thread lock for updating shm */
    void            *context;    /* general purpose storage */
    proxy_balancer_shared *s;    /* Shared data */
};
+1 −0
Changes for modules/proxy/mod_proxy_balancer.c: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -1373,6 +1373,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_update_members(proxy_balancer *b, server_re
            (*runtime)->cp = NULL;
            (*runtime)->balancer = b;
            (*runtime)->s = shm;
            (*runtime)->tmutex = NULL;
            if ((rv = ap_proxy_initialize_worker(*runtime, s, conf->pool)) != APR_SUCCESS) {
                ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "Cannot init worker");
                return rv;
+11 −3
Changes for modules/proxy/proxy_util.c: 11 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1467,7 +1467,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balance
        rv = apr_thread_mutex_create(&(balancer->tmutex), APR_THREAD_MUTEX_DEFAULT, p);
        if (rv != APR_SUCCESS) {
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                         "can not create thread mutex");
                         "can not create balancer thread mutex");
            return rv;
        }
    }    
@@ -1890,6 +1890,14 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                     "initializing worker %s local", worker->s->name);
        /* Now init local worker data */
        if (worker->tmutex == NULL) {
            rv = apr_thread_mutex_create(&(worker->tmutex), APR_THREAD_MUTEX_DEFAULT, p);
            if (rv != APR_SUCCESS) {
                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                             "can not create worker thread mutex");
                return rv;
            }
        }    
        if (worker->cp == NULL)
            init_conn_pool(p, worker);
        if (worker->cp == NULL) {
@@ -2293,7 +2301,7 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
                                    conn->pool);
    }
    else if (!worker->cp->addr) {
        if ((err = PROXY_THREAD_LOCK(worker->balancer)) != APR_SUCCESS) {
        if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) {
            ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server,
                         "proxy: lock");
            return HTTP_INTERNAL_SERVER_ERROR;
@@ -2310,7 +2318,7 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
                                    conn->port, 0,
                                    worker->cp->pool);
        conn->addr = worker->cp->addr;
        if ((uerr = PROXY_THREAD_UNLOCK(worker->balancer)) != APR_SUCCESS) {
        if ((uerr = PROXY_THREAD_UNLOCK(worker)) != APR_SUCCESS) {
            ap_log_error(APLOG_MARK, APLOG_ERR, uerr, r->server,
                         "proxy: unlock");
        }