httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1209958 - in /httpd/httpd/branches/2.4.x: ./ modules/proxy/ modules/proxy/balancers/
Date Sat, 03 Dec 2011 17:26:28 GMT
Author: minfrin
Date: Sat Dec  3 17:26:28 2011
New Revision: 1209958

URL: http://svn.apache.org/viewvc?rev=1209958&view=rev
Log:
Backport:
mod_proxy: Make ap_proxy_retry_worker() into an optional function. Allows
mod_lbmethod_bybusyness, mod_lbmethod_byrequests, mod_lbmethod_bytraffic
and mod_lbmethod_heartbeat to be loaded without mod_proxy yet being present,
which happens when modules are loaded in alphabetical order.

Added:
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.h
      - copied unchanged from r1209754, httpd/httpd/trunk/modules/proxy/proxy_util.h
Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bybusyness.c
    httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c
    httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bytraffic.c
    httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_heartbeat.c
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.c
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  3 17:26:28 2011
@@ -1,3 +1,3 @@
 /httpd/httpd/branches/revert-ap-ldap:1150158-1150173
 /httpd/httpd/branches/wombat-integration:723609-723841
-/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202236,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1206850,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603,1209618,1209623,1209741
+/httpd/httpd/trunk:1201042,1201111,1201194,1201198,1201202,1202236,1202456,1202886,1203859,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206587,1206850,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603,1209618,1209623,1209741,1209754

Modified: httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bybusyness.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bybusyness.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bybusyness.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bybusyness.c Sat Dec 
3 17:26:28 2011
@@ -22,6 +22,9 @@
 
 module AP_MODULE_DECLARE_DATA lbmethod_bybusyness_module;
 
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+        proxy_worker *worker, server_rec *s) = NULL;
+
 static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
                                 request_rec *r)
 {
@@ -36,6 +39,15 @@ static proxy_worker *find_best_bybusynes
 
     int total_factor = 0;
 
+    if (!ap_proxy_retry_worker_fn) {
+        ap_proxy_retry_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+        if (!ap_proxy_retry_worker_fn) {
+            /* can only happen if mod_proxy isn't loaded */
+            return NULL;
+        }
+    }
+
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering bybusyness for BALANCER (%s)",
                  balancer->s->name);
@@ -66,8 +78,9 @@ static proxy_worker *find_best_bybusynes
                  * The worker might still be unusable, but we try
                  * anyway.
                  */
-                if (!PROXY_WORKER_IS_USABLE(*worker))
-                    ap_proxy_retry_worker("BALANCER", *worker, r->server);
+                if (!PROXY_WORKER_IS_USABLE(*worker)) {
+                    ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
+                }
 
                 /* Take into calculation only the workers that are
                  * not in error state or not disabled.

Modified: httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c Sat Dec 
3 17:26:28 2011
@@ -22,6 +22,9 @@
 
 module AP_MODULE_DECLARE_DATA lbmethod_byrequests_module;
 
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+        proxy_worker *worker, server_rec *s) = NULL;
+
 /*
  * The idea behind the find_best_byrequests scheduler is the following:
  *
@@ -80,6 +83,15 @@ static proxy_worker *find_best_byrequest
     int checking_standby;
     int checked_standby;
 
+    if (!ap_proxy_retry_worker_fn) {
+        ap_proxy_retry_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+        if (!ap_proxy_retry_worker_fn) {
+            /* can only happen if mod_proxy isn't loaded */
+            return NULL;
+        }
+    }
+
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering byrequests for BALANCER (%s)",
                  balancer->s->name);
@@ -109,7 +121,7 @@ static proxy_worker *find_best_byrequest
                  * anyway.
                  */
                 if (!PROXY_WORKER_IS_USABLE(*worker))
-                    ap_proxy_retry_worker("BALANCER", *worker, r->server);
+                    ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
                 /* Take into calculation only the workers that are
                  * not in error state or not disabled.
                  */

Modified: httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bytraffic.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bytraffic.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bytraffic.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_bytraffic.c Sat Dec  3
17:26:28 2011
@@ -22,6 +22,9 @@
 
 module AP_MODULE_DECLARE_DATA lbmethod_bytraffic_module;
 
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+        proxy_worker *worker, server_rec *s) = NULL;
+
 /*
  * The idea behind the find_best_bytraffic scheduler is the following:
  *
@@ -52,6 +55,15 @@ static proxy_worker *find_best_bytraffic
     int checking_standby;
     int checked_standby;
 
+    if (!ap_proxy_retry_worker_fn) {
+        ap_proxy_retry_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+        if (!ap_proxy_retry_worker_fn) {
+            /* can only happen if mod_proxy isn't loaded */
+            return NULL;
+        }
+    }
+
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: Entering bytraffic for BALANCER (%s)",
                  balancer->s->name);
@@ -81,7 +93,7 @@ static proxy_worker *find_best_bytraffic
                  * anyway.
                  */
                 if (!PROXY_WORKER_IS_USABLE(*worker))
-                    ap_proxy_retry_worker("BALANCER", *worker, r->server);
+                    ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
                 /* Take into calculation only the workers that are
                  * not in error state or not disabled.
                  */

Modified: httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_heartbeat.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_heartbeat.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_heartbeat.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_heartbeat.c Sat Dec  3
17:26:28 2011
@@ -31,6 +31,9 @@
 
 module AP_MODULE_DECLARE_DATA lbmethod_heartbeat_module;
 
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+        proxy_worker *worker, server_rec *s) = NULL;
+
 static const ap_slotmem_provider_t *storage = NULL;
 static ap_slotmem_instance_t *hm_serversmem = NULL;
 
@@ -270,6 +273,15 @@ static proxy_worker *find_best_hb(proxy_
         ap_get_module_config(r->server->module_config,
                              &lbmethod_heartbeat_module);
 
+    if (!ap_proxy_retry_worker_fn) {
+        ap_proxy_retry_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+        if (!ap_proxy_retry_worker_fn) {
+            /* can only happen if mod_proxy isn't loaded */
+            return NULL;
+        }
+    }
+
     apr_pool_create(&tpool, r->pool);
 
     servers = apr_hash_make(tpool);
@@ -297,7 +309,7 @@ static proxy_worker *find_best_hb(proxy_
         }
 
         if (!PROXY_WORKER_IS_USABLE(*worker)) {
-            ap_proxy_retry_worker("BALANCER", *worker, r->server);
+            ap_proxy_retry_worker_fn("BALANCER", *worker, r->server);
         }
 
         if (PROXY_WORKER_IS_USABLE(*worker)) {

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.c Sat Dec  3 17:26:28 2011
@@ -19,6 +19,7 @@
 #include "apr_optional.h"
 #include "scoreboard.h"
 #include "mod_status.h"
+#include "proxy_util.h"
 
 #if (MODULE_MAGIC_NUMBER_MAJOR > 20020903)
 #include "mod_ssl.h"
@@ -2512,6 +2513,8 @@ static void register_hooks(apr_pool_t *p
     /* child init handling */
     ap_hook_child_init(child_init, aszPred, NULL, APR_HOOK_MIDDLE);
 
+    /* register optional functions within proxy_util.c */
+    proxy_util_register_hooks(p);
 }
 
 AP_DECLARE_MODULE(proxy) =

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h Sat Dec  3 17:26:28 2011
@@ -27,6 +27,7 @@
  */
 
 #include "apr_hooks.h"
+#include "apr_optional.h"
 #include "apr.h"
 #include "apr_lib.h"
 #include "apr_strings.h"
@@ -769,9 +770,8 @@ PROXY_DECLARE(int) ap_proxy_determine_co
  * @note The error status of the worker will cleared if the retry interval has
  * elapsed since the last error.
  */
-PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
-                                         proxy_worker *worker,
-                                         server_rec *s);
+APR_DECLARE_OPTIONAL_FN(int, ap_proxy_retry_worker,
+        (const char *proxy_function, proxy_worker *worker, server_rec *s));
 
 /**
  * Acquire a connection from worker connection pool

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c Sat Dec  3 17:26:28 2011
@@ -28,6 +28,9 @@ ap_slotmem_provider_t *storage = NULL;
 
 module AP_MODULE_DECLARE_DATA proxy_balancer_module;
 
+static int (*ap_proxy_retry_worker_fn)(const char *proxy_function,
+        proxy_worker *worker, server_rec *s) = NULL;
+
 /*
  * Register our mutex type before the config is read so we
  * can adjust the mutex settings using the Mutex directive.
@@ -224,7 +227,7 @@ static proxy_worker *find_route_worker(p
                      * The worker might still be unusable, but we try
                      * anyway.
                      */
-                    ap_proxy_retry_worker("BALANCER", worker, r->server);
+                    ap_proxy_retry_worker_fn("BALANCER", worker, r->server);
                     if (PROXY_WORKER_IS_USABLE(worker)) {
                             return worker;
                     } else {
@@ -248,7 +251,7 @@ static proxy_worker *find_route_worker(p
                                  * The worker might still be unusable, but we try
                                  * anyway.
                                  */
-                                ap_proxy_retry_worker("BALANCER", rworker, r->server);
+                                ap_proxy_retry_worker_fn("BALANCER", rworker, r->server);
                             }
                             if (rworker && PROXY_WORKER_IS_USABLE(rworker))
                                 return rworker;
@@ -413,7 +416,7 @@ static void force_recovery(proxy_balance
         }
         else {
             /* Try if we can recover */
-            ap_proxy_retry_worker("BALANCER", *worker, s);
+            ap_proxy_retry_worker_fn("BALANCER", *worker, s);
             if (!((*worker)->s->status & PROXY_WORKER_IN_ERROR)) {
                 ok = 1;
                 break;
@@ -696,8 +699,19 @@ static int balancer_post_config(apr_pool
 
     /* balancer_post_config() will be called twice during startup.  So, don't
      * set up the static data the 1st time through. */
-    if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
+    if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
         return OK;
+    }
+
+    if (!ap_proxy_retry_worker_fn) {
+        ap_proxy_retry_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_retry_worker);
+        if (!ap_proxy_retry_worker_fn) {
+            ap_log_error(
+                    APLOG_MARK, APLOG_EMERG, 0, s, "mod_proxy must be loaded for mod_proxy_balancer");
+            return !OK;
+        }
+    }
 
     /*
      * Get slotmem setups

Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c?rev=1209958&r1=1209957&r2=1209958&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c Sat Dec  3 17:26:28 2011
@@ -20,6 +20,7 @@
 #include "scoreboard.h"
 #include "apr_version.h"
 #include "apr_hash.h"
+#include "proxy_util.h"
 
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>         /* for getpid() */
@@ -1977,9 +1978,8 @@ PROXY_DECLARE(apr_status_t) ap_proxy_ini
     return rv;
 }
 
-PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
-                                         proxy_worker *worker,
-                                         server_rec *s)
+static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worker,
+        server_rec *s)
 {
     if (worker->s->status & PROXY_WORKER_IN_ERROR) {
         if (apr_time_now() > worker->s->error_time + worker->s->retry) {
@@ -3024,3 +3024,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_syn
     return APR_SUCCESS;
 }
 
+void proxy_util_register_hooks(apr_pool_t *p)
+{
+    APR_REGISTER_OPTIONAL_FN(ap_proxy_retry_worker);
+}



Mime
View raw message