git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: svn commit: r1832609 - in /httpd/httpd/branches/2.4.x: ./ docs/manual/howto/ docs/manual/mod/ modules/proxy/ modules/proxy/balancers/



On 07/19/2018 08:24 PM, William A Rowe Jr wrote:
> On Thu, May 31, 2018 at 8:24 AM, <jim@xxxxxxxxxx <mailto:jim@xxxxxxxxxx>> wrote:
> 
>     Author: jim
>     Date: Thu May 31 13:24:04 2018
>     New Revision: 1832609
> 
>     URL: http://svn.apache.org/viewvc?rev=1832609&view=rev <http://svn.apache.org/viewvc?rev=1832609&view=rev>
>     Log:
>     Merge r1828890, r1832500 from trunk:
> 
> [...] 
> 
>     URL:
>     http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c?rev=1832609&r1=1832608&r2=1832609&view=diff
>     <http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/balancers/mod_lbmethod_byrequests.c?rev=1832609&r1=1832608&r2=1832609&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 Thu May 31 13:24:04 2018
> 
> [...] 
> 
>     @@ -70,82 +77,17 @@ static int (*ap_proxy_retry_worker_fn)(c
>       *   b a d c d a c d b d ...
>       *
>       */
>     -
>      static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
>                                      request_rec *r)
>      {
>     -    int i;
>          int total_factor = 0;
> 
> [...] 
> 
>     +    proxy_worker *worker = ap_proxy_balancer_get_best_worker(balancer, r, is_best_byrequests, &total_factor);
> 
> 
> This introduced a new hard runtime config ordering problem on mod_lbmethod_byrequest.so, which must now be loaded AFTER
> mod_proxy.so.
> 
> This was not previously true, as illustrated by mod_lbmethod_heartbeat, using the ap_proxy_retry_worker using an
> optional function.
> 
> lbmethod sorts before proxy, fwiw.
> 

Something like the attached? The mod_lbmethod_byrequests.c part needs to be done for lb modules though.

Regards

Rüdiger



Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c	(revision 1836329)
+++ modules/proxy/proxy_util.c	(working copy)
@@ -4079,4 +4079,5 @@
 {
     APR_REGISTER_OPTIONAL_FN(ap_proxy_retry_worker);
     APR_REGISTER_OPTIONAL_FN(ap_proxy_clear_connection);
+    APR_REGISTER_OPTIONAL_FN(ap_proxy_balancer_get_best_worker);
 }
Index: modules/proxy/balancers/mod_lbmethod_byrequests.c
===================================================================
--- modules/proxy/balancers/mod_lbmethod_byrequests.c	(revision 1836329)
+++ modules/proxy/balancers/mod_lbmethod_byrequests.c	(working copy)
@@ -22,6 +22,9 @@
 
 module AP_MODULE_DECLARE_DATA lbmethod_byrequests_module;
 
+static APR_OPTIONAL_FN_TYPE(ap_proxy_balancer_get_best_worker)
+                            *ap_proxy_balancer_get_best_worker_fn = NULL;
+
 static int is_best_byrequests(proxy_worker *current, proxy_worker *prev_best, void *baton)
 {
     int *total_factor = (int *)baton;
@@ -81,7 +84,7 @@
                                 request_rec *r)
 {
     int total_factor = 0;
-    proxy_worker *worker = ap_proxy_balancer_get_best_worker(balancer, r, is_best_byrequests, &total_factor);
+    proxy_worker *worker = ap_proxy_balancer_get_best_worker_fn(balancer, r, is_best_byrequests, &total_factor);
 
     if (worker) {
         worker->s->lbstatus -= total_factor;
@@ -123,6 +126,30 @@
     NULL
 };
 
+/* post_config hook: */
+static int lbmethod_byrequests_post_config(apr_pool_t *pconf, apr_pool_t *plog,
+        apr_pool_t *ptemp, server_rec *s)
+{
+
+    /* lbmethod_byrequests_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) {
+        return OK;
+    }
+
+    if (!ap_proxy_balancer_get_best_worker_fn) {
+        ap_proxy_balancer_get_best_worker_fn =
+                APR_RETRIEVE_OPTIONAL_FN(ap_proxy_balancer_get_best_worker);
+        if (!ap_proxy_balancer_get_best_worker_fn) {
+            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO()
+                         "mod_proxy must be loaded for mod_lbmethod_byrequests");
+            return !OK;
+        }
+    }
+
+    return OK;
+}
+
 static void register_hook(apr_pool_t *p)
 {
     /* Only the mpm_winnt has child init hook handler.
@@ -130,6 +157,7 @@
      * initializes and after the mod_proxy
      */
     ap_register_provider(p, PROXY_LBMETHOD, "byrequests", "0", &byrequests);
+    ap_hook_post_config(lbmethod_byrequests_post_config, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 AP_DECLARE_MODULE(lbmethod_byrequests) = {
Index: modules/proxy/mod_proxy.h
===================================================================
--- modules/proxy/mod_proxy.h	(revision 1836329)
+++ modules/proxy/mod_proxy.h	(working copy)
@@ -880,6 +880,14 @@
                                                                 request_rec *r,
                                                                 proxy_is_best_callback_fn_t *is_best,
                                                                 void *baton);
+/*
+ * Needed by the lb modules.
+ */
+APR_DECLARE_OPTIONAL_FN(proxy_worker *, ap_proxy_balancer_get_best_worker,
+                                        (proxy_balancer *balancer,
+                                         request_rec *r,
+                                         proxy_is_best_callback_fn_t *is_best,
+                                         void *baton));
 
 /**
  * Find the shm of the worker as needed
Index: include/ap_mmn.h
===================================================================
--- include/ap_mmn.h	(revision 1836329)
+++ include/ap_mmn.h	(working copy)
@@ -585,6 +585,8 @@
  * 20180716.2 (2.5.1-dev)  Add read_buf_size member to core_dir_config,
  *                         flush_max_threshold and flush_max_pipelined to
  *                         core_server_config, and ap_get_read_buf_size().
+ * 20180716.3 (2.5.1-dev)  Add optional function declaration for
+ *                         ap_proxy_balancer_get_best_worker to mod_proxy.h.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -592,7 +594,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20180716
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 3                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a


( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache2-developers/msg04336.html on line 238
Call Stack
#TimeMemoryFunctionLocation
10.0008372856{main}( ).../msg04336.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache2-developers/msg04336.html on line 238
Call Stack
#TimeMemoryFunctionLocation
10.0008372856{main}( ).../msg04336.html:0