httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject svn commit: r774400 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Wed, 13 May 2009 15:27:09 GMT
Author: jfclere
Date: Wed May 13 15:27:05 2009
New Revision: 774400

URL: http://svn.apache.org/viewvc?rev=774400&view=rev
Log:
Allow the load balancing method to "create" workers.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=774400&r1=774399&r2=774400&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Wed May 13 15:27:05 2009
@@ -940,6 +940,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 */
@@ -2295,7 +2302,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 */
@@ -2305,7 +2312,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 */
@@ -2317,7 +2324,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/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=774400&r1=774399&r2=774400&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Wed May 13 15:27:05 2009
@@ -570,10 +570,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/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=774400&r1=774399&r2=774400&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Wed May 13 15:27:05 2009
@@ -104,7 +104,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 =

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=774400&r1=774399&r2=774400&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Wed May 13 15:27:05 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 ;
+    } 
+
 #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 */



Mime
View raw message