]> granicus.if.org Git - apache/commitdiff
Merge r1805188, r1805190, r1805206, r1808723 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 19 Sep 2017 10:17:40 +0000 (10:17 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 19 Sep 2017 10:17:40 +0000 (10:17 +0000)
loadfactor now decimal

Umm. This is C :)

Fix remaining lint from ms capability for hchecks.

format typo

Reviewed by: jim, humbedooh, ylavic

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1808855 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index e7a2d65763b2fe88d61956d2e4256b8fa174c78b..c6b3bcaedb3e850dc91041ee82e0b0643638b621 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,9 @@ Changes with Apache 2.4.28
      length in a password file.
      [Luca Toscano, Hanno Böck <hanno hboeck de>]
 
+  *) mod_proxy: loadfactor parameter can now be a decimal number (eg: 1.25).
+     [Jim Jagielski]
+
   *) mod_proxy_wstunnel: Allow upgrade to any protocol dynamically.
      PR 61142.
 
diff --git a/STATUS b/STATUS
index 5766e70a844fe348873feb7fbd1b7f14eb311f58..6aa0a9f5a6a561b9f5ea4e754ed8534009c70c0c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -115,15 +115,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_proxy: Loadfactor can now be a decimal number (eg: 1.25)
-     trunk patch: http://svn.apache.org/r1805188
-                  http://svn.apache.org/r1805190
-                  http://svn.apache.org/r1805206 (partial)
-                  http://svn.apache.org/r1808723
-     2.4.x patch: http://home.apache.org/~jim/patches/httpd-2.4-loadfactor-v2.patch
-     +1: jim, humbedooh, ylavic
-     ylavic: conflicts on the docs, addressable while backporting I guess.
-
   *) mod_speling: Don't embed Referer data in link in error page.
      trunk patch: http://svn.apache.org/r1808780
      2.4.x: trunk patch applies
index 73b2042b1d3b4523bbae9aa52125e4698a4e9560..4bd5146986bce1912c84bd8e105dd65693c9e5c6 100644 (file)
@@ -785,8 +785,8 @@ expressions</description>
             directive and can take any of the key value pair parameters available to
             <directive module="mod_proxy">ProxyPass</directive> directives.</p>
         <p>One additional parameter is available only to <directive>BalancerMember</directive> directives:
-            <var>loadfactor</var>. This is the member load factor - a number between 1
-            (default) and 100, which defines the weighted load to be applied to the
+            <var>loadfactor</var>. This is the member load factor - a decimal number between 1.0
+            (default) and 100.0, which defines the weighted load to be applied to the
             member in question.</p>
         <p>The <var>balancerurl</var> is only needed when not within a
             <code>&lt;Proxy <var>balancer://</var>...&gt;</code>
@@ -1332,7 +1332,7 @@ ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofail
 ProxyPass "/" "balancer://hotcluster/"
 &lt;Proxy "balancer://hotcluster"&gt;
     BalancerMember "ajp://1.2.3.4:8009" loadfactor=1
-    BalancerMember "ajp://1.2.3.5:8009" loadfactor=2
+    BalancerMember "ajp://1.2.3.5:8009" loadfactor=2.25
     # The server below is on hot standby
     BalancerMember "ajp://1.2.3.6:8009" status=+H
     ProxySet lbmethod=bytraffic
index 3f916f66dfc5780427b172726705cc74edb0cf9b..314fc0d78231d5524d269c63ba2299c1913350b8 100644 (file)
@@ -103,7 +103,8 @@ static const char *set_worker_param(apr_pool_t *p,
         /* Normalized load factor. Used with BalancerMember,
          * it is a number between 1 and 100.
          */
-        ival = atoi(val);
+        double fval = atof(val);
+        ival = fval * 100.0;
         if (ival < 1 || ival > 100)
             return "LoadFactor must be a number between 1..100";
         worker->s->lbfactor = ival;
@@ -2685,7 +2686,7 @@ static int proxy_status_hook(request_rec *r, int flags)
                 ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL);
                 ap_rvputs(r, "</td><td>", (*worker)->s->route, NULL);
                 ap_rvputs(r, "</td><td>", (*worker)->s->redirect, NULL);
-                ap_rprintf(r, "</td><td>%d</td>", (*worker)->s->lbfactor);
+                ap_rprintf(r, "</td><td>%.2f</td>", (float)((*worker)->s->lbfactor)/100.0);
                 ap_rprintf(r, "<td>%d</td>", (*worker)->s->lbset);
                 ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>",
                            (*worker)->s->elected);
index 61ff5e4721f26bb6ab6a25a6ca54eb8b833e490f..9c58590a87cc9f7d181aae25dd9817c715bbe27f 100644 (file)
@@ -700,10 +700,10 @@ static void recalc_factors(proxy_balancer *balancer)
     /* Recalculate lbfactors */
     workers = (proxy_worker **)balancer->workers->elts;
     /* Special case if there is only one worker its
-     * load factor will always be 1
+     * load factor will always be 100
      */
     if (balancer->workers->nelts == 1) {
-        (*workers)->s->lbstatus = (*workers)->s->lbfactor = 1;
+        (*workers)->s->lbstatus = (*workers)->s->lbfactor = 100;
         return;
     }
     for (i = 0; i < balancer->workers->nelts; i++) {
@@ -1093,8 +1093,10 @@ static int balancer_handler(request_rec *r)
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01192) "settings worker params");
 
         if ((val = apr_table_get(params, "w_lf"))) {
-            int ival = atoi(val);
-            if (ival >= 1 && ival <= 100) {
+            int ival;
+            double fval = atof(val);
+            ival = fval * 100.0;
+            if (ival >= 100 && ival <= 10000) {
                 wsel->s->lbfactor = ival;
                 if (bsel)
                     recalc_factors(bsel);
@@ -1362,8 +1364,8 @@ static int balancer_handler(request_rec *r)
                           "</httpd:scheme>\n", NULL);
                 ap_rvputs(r, "          <httpd:hostname>", worker->s->hostname,
                           "</httpd:hostname>\n", NULL);
-                ap_rprintf(r, "          <httpd:loadfactor>%d</httpd:loadfactor>\n",
-                          worker->s->lbfactor);
+                ap_rprintf(r, "          <httpd:loadfactor>%.2f</httpd:loadfactor>\n",
+                          (float)(worker->s->lbfactor)/100.0);
                 ap_rprintf(r,
                            "          <httpd:port>%d</httpd:port>\n",
                            worker->s->port);
@@ -1416,8 +1418,8 @@ static int balancer_handler(request_rec *r)
                            "          <httpd:lbstatus>%d</httpd:lbstatus>\n",
                            worker->s->lbstatus);
                 ap_rprintf(r,
-                           "          <httpd:loadfactor>%d</httpd:loadfactor>\n",
-                           worker->s->lbfactor);
+                           "          <httpd:loadfactor>%.2f</httpd:loadfactor>\n",
+                           (float)(worker->s->lbfactor)/100.0);
                 ap_rprintf(r,
                            "          <httpd:transferred>%" APR_OFF_T_FMT "</httpd:transferred>\n",
                            worker->s->transferred);
@@ -1603,7 +1605,7 @@ static int balancer_handler(request_rec *r)
                           NULL);
                 ap_rvputs(r, "</td><td>",
                           ap_escape_html(r->pool, worker->s->redirect), NULL);
-                ap_rprintf(r, "</td><td>%d</td>", worker->s->lbfactor);
+                ap_rprintf(r, "</td><td>%.2f</td>", (float)(worker->s->lbfactor)/100.0);
                 ap_rprintf(r, "<td>%d</td><td>", worker->s->lbset);
                 ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, worker), NULL);
                 ap_rputs("</td>", r);
@@ -1638,7 +1640,7 @@ static int balancer_handler(request_rec *r)
             ap_rputs("<form method='POST' enctype='application/x-www-form-urlencoded' action='", r);
             ap_rvputs(r, ap_escape_uri(r->pool, action), "'>\n", NULL);
             ap_rputs("<table><tr><td>Load factor:</td><td><input name='w_lf' id='w_lf' type=text ", r);
-            ap_rprintf(r, "value='%d'></td></tr>\n", wsel->s->lbfactor);
+            ap_rprintf(r, "value='%.2f'></td></tr>\n", (float)(wsel->s->lbfactor)/100.0);
             ap_rputs("<tr><td>LB Set:</td><td><input name='w_ls' id='w_ls' type=text ", r);
             ap_rprintf(r, "value='%d'></td></tr>\n", wsel->s->lbset);
             ap_rputs("<tr><td>Route:</td><td><input name='w_wr' id='w_wr' type=text ", r);
index 663c3af57ade4ab9a0b7f1592bb800128f126a41..b61d56fd4ee7d18fee3bcadfc27e0e41986f79a7 100644 (file)
@@ -1699,7 +1699,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
     wshared->flush_packets = flush_off;
     wshared->flush_wait = PROXY_FLUSH_WAIT;
     wshared->is_address_reusable = 1;
-    wshared->lbfactor = 1;
+    wshared->lbfactor = 100;
     wshared->passes = 1;
     wshared->fails = 1;
     wshared->interval = apr_time_from_sec(HCHECK_WATHCHDOG_DEFAULT_INTERVAL);