httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r964089 - in /httpd/httpd/trunk: include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/proxy_util.c
Date Wed, 14 Jul 2010 16:03:19 GMT
Author: jim
Date: Wed Jul 14 16:03:19 2010
New Revision: 964089

URL: http://svn.apache.org/viewvc?rev=964089&view=rev
Log:
Allow for modules to keep track of worker slot
numbers themselves if they want, by allowing for
worker create/alloc functions to take a slot number id.
Done via _wid() variants of 3 proxy funcs.


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

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=964089&r1=964088&r2=964089&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Wed Jul 14 16:03:19 2010
@@ -234,6 +234,7 @@
  * 20100630.0 (2.3.7-dev)  make module_levels vector of char instead of int
  * 20100701.0 (2.3.7-dev)  re-order struct members to improve alignment
  * 20100701.1 (2.3.7-dev)  add note_auth_failure hook
+ * 20100701.2 (2.3.7-dev)  add ap_proxy_*_wid() functions
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -241,7 +242,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20100701
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=964089&r1=964088&r2=964089&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Wed Jul 14 16:03:19 2010
@@ -532,6 +532,21 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_g
  * @param p      memory pool to allocate worker from 
  * @param conf   current proxy server configuration
  * @param url    url containing worker name
+ * @param id     slotnumber id or -1 for auto allocation
+ * @return       error message or NULL if successfull
+ */
+PROXY_DECLARE(const char *) ap_proxy_add_worker_wid(proxy_worker **worker,
+                                                apr_pool_t *p,
+                                                proxy_server_conf *conf,
+                                                const char *url,
+                                                int id);
+
+/**
+ * Add the worker to proxy configuration
+ * @param worker the new worker
+ * @param p      memory pool to allocate worker from 
+ * @param conf   current proxy server configuration
+ * @param url    url containing worker name
  * @return       error message or NULL if successfull
  */
 PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
@@ -542,6 +557,14 @@ PROXY_DECLARE(const char *) ap_proxy_add
 /**
  * Create new worker
  * @param p      memory pool to allocate worker from 
+ * @param id     slotnumber id or -1 for auto allocation
+ * @return       new worker
+ */
+PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker_wid(apr_pool_t *p, int id);
+
+/**
+ * Create new worker
+ * @param p      memory pool to allocate worker from 
  * @return       new worker
  */
 PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p);
@@ -596,6 +619,18 @@ PROXY_DECLARE(const char *) ap_proxy_add
  * @param pool     memory pool for adding worker 
  * @param balancer balancer to add to
  * @param worker worker to add
+ * @param id     slotnumber id or -1 for auto allocation
+ * @note Single worker can be added to multiple balancers.
+ */
+PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer_wid(apr_pool_t *pool,
+                                                    proxy_balancer *balancer,
+                                                    proxy_worker *worker,
+                                                    int id);
+/**
+ * Add the worker to the balancer
+ * @param pool     memory pool for adding worker 
+ * @param balancer balancer to add to
+ * @param worker worker to add
  * @note Single worker can be added to multiple balancers.
  */
 PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=964089&r1=964088&r2=964089&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Wed Jul 14 16:03:19 2010
@@ -1442,10 +1442,11 @@ static void init_conn_pool(apr_pool_t *p
     worker->cp = cp;
 }
 
-PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
+PROXY_DECLARE(const char *) ap_proxy_add_worker_wid(proxy_worker **worker,
                                                 apr_pool_t *p,
                                                 proxy_server_conf *conf,
-                                                const char *url)
+                                                const char *url,
+                                                int id)
 {
     int rv;
     apr_uri_t uri;
@@ -1467,27 +1468,35 @@ PROXY_DECLARE(const char *) ap_proxy_add
     (*worker)->scheme = uri.scheme;
     (*worker)->hostname = uri.hostname;
     (*worker)->port = uri.port;
-    (*worker)->id   = proxy_lb_workers;
+    if (id < 0) {
+        (*worker)->id   = proxy_lb_workers;
+        proxy_lb_workers++;
+    } else {
+        (*worker)->id   = id;
+    }
     (*worker)->flush_packets = flush_off;
     (*worker)->flush_wait = PROXY_FLUSH_WAIT;
     (*worker)->smax = -1;
     /* Increase the total worker count */
-    proxy_lb_workers++;
     (*worker)->cp = NULL;
     (*worker)->mutex = NULL;
 
     return NULL;
 }
 
-PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p)
+PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker_wid(apr_pool_t *p, int id)
 {
 
     proxy_worker *worker;
     worker = (proxy_worker *)apr_pcalloc(p, sizeof(proxy_worker));
-    worker->id = proxy_lb_workers;
+    if (id < 0) {
+        worker->id = proxy_lb_workers;
+        /* Increase the total worker count */
+        proxy_lb_workers++;
+    } else {
+        worker->id = id;
+    }
     worker->smax = -1;
-    /* Increase the total worker count */
-    proxy_lb_workers++;
     worker->cp = NULL;
     worker->mutex = NULL;
 
@@ -1495,17 +1504,41 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_c
 }
 
 PROXY_DECLARE(void)
-ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer,
-                                proxy_worker *worker)
+ap_proxy_add_worker_to_balancer_wid(apr_pool_t *pool, proxy_balancer *balancer,
+                                proxy_worker *worker, int id)
 {
     proxy_worker **runtime;
 
     runtime = apr_array_push(balancer->workers);
     *runtime = worker;
-    (*runtime)->id = proxy_lb_workers;
-    /* Increase the total runtime count */
-    proxy_lb_workers++;
+    if (id < 0) {
+        (*runtime)->id = proxy_lb_workers;
+        /* Increase the total runtime count */
+        proxy_lb_workers++;
+    } else {
+        (*runtime)->id = id;
+    }
+
+}
+
+PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
+                                                apr_pool_t *p,
+                                                proxy_server_conf *conf,
+                                                const char *url)
+{
+    return ap_proxy_add_worker_wid(worker, p, conf, url, -1);
+}
 
+PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p)
+{
+    return ap_proxy_create_worker_wid(p, -1);
+}
+
+PROXY_DECLARE(void)
+ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer *balancer,
+                                proxy_worker *worker)
+{
+    ap_proxy_add_worker_to_balancer_wid(pool, balancer, worker, -1);
 }
 
 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,



Mime
View raw message