Commit 33899d95 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Merge r1836381, r1836382, r1836383, r1836386, r1836603 from trunk:

* mod_proxy: Remove load order and link dependency between mod_lbmethod_*
  modules and mod_proxy by providing mod_proxy's ap_proxy_balancer_get_best_worker
  as an optional function.

PR: 62557


* Remove invalid copy and paste comments

* Always retrieve conditional function. static variable might contain garbage if module was reloaded in a static build.

* Add missing log numbers

* ap_proxy_balancer_get_best_worker cannot be exported and used as an optional
  function at the same time. So rename ap_proxy_balancer_get_best_worker to
  proxy_balancer_get_best_worker and make it static which is then used as an
  optional function and recreate ap_proxy_balancer_get_best_worker as an
  exported thin wrapper of proxy_balancer_get_best_worker.

Submitted by: rpluem
Reviewed by: covener, jim, ylavic


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1840548 13f79535-47bb-0310-9956-ffa450edef68
parent f62c6644
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ Changes with Apache 2.4.35
  *) mod_ratelimit: Don't interfere with "chunked" encoding, fixing regression
     introduced in 2.4.34.  PR 62568.  [Yann Ylavic]

  *) mod_proxy: Remove load order and link dependency between mod_lbmethod_*
     modules and mod_proxy. PR 62557. [Ruediger Pluem]

  *) Allow the argument to <IfFile>, <IfDefine>, <IfSection>, <IfDirective>,
     and <IfModule> to be quoted.  This is primarily for the benefit of
     <IfFile>. [Eric Covener]
+0 −8
Original line number Diff line number Diff line
@@ -124,14 +124,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
  [ start all new proposals below, under PATCHES PROPOSED. ]

   *) mod_proxy: fix load order dep between mod_proxy and lbmethod providers
      trunk patch: http://svn.apache.org/r1836381 
                   http://svn.apache.org/r1836382 
                   http://svn.apache.org/r1836383 
                   http://svn.apache.org/r1836386 
                   http://svn.apache.org/r1836603
      2.4.x patch: http://people.apache.org/~covener/2.4.x-proxy-opt-fn.diff
      +1: covener, jim, ylavic


PATCHES PROPOSED TO BACKPORT FROM TRUNK:
+3 −1
Original line number Diff line number Diff line
@@ -520,6 +520,8 @@
 *                          scoreboard.h.
 * 20120211.81 (2.4.35-dev) Add new duration field to worker_score struct in
 *                          scoreboard.h
 * 20120211.82 (2.4.35-dev) Add optional function declaration for
 *                          ap_proxy_balancer_get_best_worker to mod_proxy.h.
 *
 */

@@ -528,7 +530,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20120211
#endif
#define MODULE_MAGIC_NUMBER_MINOR 81                  /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 82                  /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+27 −1
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@

module AP_MODULE_DECLARE_DATA lbmethod_bybusyness_module;

static APR_OPTIONAL_FN_TYPE(proxy_balancer_get_best_worker)
                            *ap_proxy_balancer_get_best_worker_fn = NULL;

static int is_best_bybusyness(proxy_worker *current, proxy_worker *prev_best, void *baton)
{
    int *total_factor = (int *)baton;
@@ -44,7 +47,7 @@ static proxy_worker *find_best_bybusyness(proxy_balancer *balancer,
{
    int total_factor = 0;
    proxy_worker *worker =
        ap_proxy_balancer_get_best_worker(balancer, r, is_best_bybusyness,
        ap_proxy_balancer_get_best_worker_fn(balancer, r, is_best_bybusyness,
                                          &total_factor);

    if (worker) {
@@ -82,9 +85,32 @@ static const proxy_balancer_method bybusyness =
    NULL
};

/* post_config hook: */
static int lbmethod_bybusyness_post_config(apr_pool_t *pconf, apr_pool_t *plog,
        apr_pool_t *ptemp, server_rec *s)
{

    /* lbmethod_bybusyness_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;
    }

    ap_proxy_balancer_get_best_worker_fn =
                 APR_RETRIEVE_OPTIONAL_FN(proxy_balancer_get_best_worker);
    if (!ap_proxy_balancer_get_best_worker_fn) {
        ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10151)
                     "mod_proxy must be loaded for mod_lbmethod_bybusyness");
        return !OK;
    }

    return OK;
}

static void register_hook(apr_pool_t *p)
{
    ap_register_provider(p, PROXY_LBMETHOD, "bybusyness", "0", &bybusyness);
    ap_hook_post_config(lbmethod_bybusyness_post_config, NULL, NULL, APR_HOOK_MIDDLE);
}

AP_DECLARE_MODULE(lbmethod_bybusyness) = {
+27 −5
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@

module AP_MODULE_DECLARE_DATA lbmethod_byrequests_module;

static APR_OPTIONAL_FN_TYPE(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 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
                                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,13 +126,32 @@ static const proxy_balancer_method byrequests =
    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;
    }

    ap_proxy_balancer_get_best_worker_fn =
                 APR_RETRIEVE_OPTIONAL_FN(proxy_balancer_get_best_worker);
    if (!ap_proxy_balancer_get_best_worker_fn) {
        ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10152)
                     "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.
     * make sure that we are called after the mpm
     * 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) = {
Loading