Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 89317 invoked from network); 13 May 2009 16:55:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 May 2009 16:55:55 -0000 Received: (qmail 24930 invoked by uid 500); 13 May 2009 16:55:54 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 24848 invoked by uid 500); 13 May 2009 16:55:54 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 24839 invoked by uid 99); 13 May 2009 16:55:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 16:55:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 16:55:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 332DE2388872; Wed, 13 May 2009 16:55:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r774427 - in /httpd/httpd/branches/httpd-2.2-proxy/modules/proxy: examples/mod_lbmethod_rr.c mod_lbmethod_bybusyness.c mod_lbmethod_byrequests.c mod_lbmethod_bytraffic.c mod_proxy.c mod_proxy.h mod_proxy_balancer.c proxy_util.c Date: Wed, 13 May 2009 16:55:18 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090513165532.332DE2388872@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jim Date: Wed May 13 16:55:06 2009 New Revision: 774427 URL: http://svn.apache.org/viewvc?rev=774427&view=rev Log: Sync up with trunk Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/examples/mod_lbmethod_rr.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bybusyness.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_byrequests.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bytraffic.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.h httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/examples/mod_lbmethod_rr.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/examples/mod_lbmethod_rr.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/examples/mod_lbmethod_rr.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/examples/mod_lbmethod_rr.c Wed May 13 16:55:06 2009 @@ -95,11 +95,21 @@ return mycandidate; } +static apr_status_t reset(proxy_balancer *balancer, server_rec *s) { + return APR_SUCCESS; +} + +static apr_status_t age(proxy_balancer *balancer, server_rec *s) { + return APR_SUCCESS; +} + static const proxy_balancer_method roundrobin = { "roundrobin", &find_best_roundrobin, - NULL + NULL, + &reset, + &age }; Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bybusyness.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bybusyness.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bybusyness.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bybusyness.c Wed May 13 16:55:06 2009 @@ -103,11 +103,11 @@ } -static apr_status_t reset(proxy_balancer *balancer, request_rec *r) { +static apr_status_t reset(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } -static apr_status_t age(proxy_balancer *balancer, request_rec *r) { +static apr_status_t age(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } @@ -115,7 +115,7 @@ { "bybusyness", &find_best_bybusyness, + NULL, &reset, - &age, - NULL + &age }; Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_byrequests.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_byrequests.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_byrequests.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_byrequests.c Wed May 13 16:55:06 2009 @@ -130,11 +130,11 @@ return mycandidate; } -static apr_status_t reset(proxy_balancer *balancer, request_rec *r) { +static apr_status_t reset(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } -static apr_status_t age(proxy_balancer *balancer, request_rec *r) { +static apr_status_t age(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } @@ -148,7 +148,7 @@ { "byrequests", &find_best_byrequests, + NULL, &reset, - &age, - NULL + &age }; Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bytraffic.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bytraffic.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bytraffic.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_lbmethod_bytraffic.c Wed May 13 16:55:06 2009 @@ -103,11 +103,11 @@ return mycandidate; } -static apr_status_t reset(proxy_balancer *balancer, request_rec *r) { +static apr_status_t reset(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } -static apr_status_t age(proxy_balancer *balancer, request_rec *r) { +static apr_status_t age(proxy_balancer *balancer, server_rec *s) { return APR_SUCCESS; } @@ -115,7 +115,7 @@ { "bytraffic", &find_best_bytraffic, + NULL, &reset, - &age, - NULL + &age }; Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.c Wed May 13 16:55:06 2009 @@ -933,6 +933,13 @@ 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 */ @@ -2286,7 +2293,7 @@ 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 */ @@ -2296,7 +2303,7 @@ 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 */ @@ -2308,7 +2315,7 @@ 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 */ Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.h URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.h?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.h (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy.h Wed May 13 16:55:06 2009 @@ -392,9 +392,9 @@ const char *name; /* name of the load balancer method*/ proxy_worker *(*finder)(proxy_balancer *balancer, request_rec *r); - apr_status_t (*reset)(proxy_balancer *balancer, request_rec *r); - apr_status_t (*age)(proxy_balancer *balancer, request_rec *r); void *context; /* general purpose storage */ + apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s); + apr_status_t (*age)(proxy_balancer *balancer, server_rec *s); }; #if APR_HAS_THREADS @@ -572,10 +572,12 @@ * 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 Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/mod_proxy_balancer.c Wed May 13 16:55:06 2009 @@ -106,7 +106,7 @@ } } 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 = @@ -943,6 +943,9 @@ /* Initialize shared scoreboard data */ balancer = (proxy_balancer *)conf->balancers->elts; for (i = 0; i < conf->balancers->nelts; i++) { + proxy_balancer_method *lbmethod = balancer->lbmethod; + if (balancer->lbmethod!=NULL && balancer->lbmethod->reset != NULL) + balancer->lbmethod->reset(balancer, s); init_balancer_members(conf, s, balancer); balancer++; } Modified: httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c?rev=774427&r1=774426&r2=774427&view=diff ============================================================================== --- httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c (original) +++ httpd/httpd/branches/httpd-2.2-proxy/modules/proxy/proxy_util.c Wed May 13 16:55:06 2009 @@ -1443,14 +1443,8 @@ (*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; } @@ -1464,7 +1458,8 @@ worker->smax = -1; /* Increase the total worker count */ proxy_lb_workers++; - init_conn_pool(p, worker); + worker->cp = NULL; + worker->mutex = NULL; return worker; } @@ -1839,7 +1834,7 @@ } -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; @@ -1864,7 +1859,24 @@ 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 APR_EGENERAL; + } + #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 */