httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1813167 - in /httpd/httpd/trunk: CHANGES modules/proxy/mod_proxy.c modules/proxy/mod_proxy_balancer.c
Date Tue, 24 Oct 2017 10:50:34 GMT
Author: ylavic
Date: Tue Oct 24 10:50:34 2017
New Revision: 1813167

URL: http://svn.apache.org/viewvc?rev=1813167&view=rev
Log:
mod_proxy_balancer: fix runtime lbfactor value changed in 2.4.28.

It is assumed to be between 1 and 100 by lbmethods, so normalize it
accordingly.


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1813167&r1=1813166&r2=1813167&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Oct 24 10:50:34 2017
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy_balancer: fix runtime lbfactor value changed in 2.4.28. It is
+     assumed to be between 1 and 100 by lbmethods, so normalize it accordingly.
+     [Yann Ylavic]
+
   *) mod_md: v1.0.1, ServerName/Alias names from pure-http: virtual hosts are no longer
      auto-added to a Managed Domain. Error counts of jobs are presisted. When the server
      restarts (gracefully) any errored staging areas are purged to reset the signup/renewal

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1813167&r1=1813166&r2=1813167&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Oct 24 10:50:34 2017
@@ -104,13 +104,13 @@ static const char *set_worker_param(apr_
 
     if (!strcasecmp(key, "loadfactor")) {
         /* Normalized load factor. Used with BalancerMember,
-         * it is a number between 1 and 100.
+         * it is a number between 1 and 100 (or 0.01 and 1.0).
          */
         double fval = atof(val);
         ival = fval * 100.0;
         if (ival < 100 || ival > 10000)
             return "LoadFactor must be a number between 1..100";
-        worker->s->lbfactor = ival;
+        worker->s->lbfactor = ival / 100;
     }
     else if (!strcasecmp(key, "retry")) {
         /* If set it will give the retry timeout for the worker
@@ -2883,7 +2883,7 @@ static int proxy_status_hook(request_rec
                 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>%.2f</td>", (float)((*worker)->s->lbfactor)/100.0);
+                ap_rprintf(r, "</td><td>%d</td>", (*worker)->s->lbfactor);
                 ap_rprintf(r, "<td>%d</td>", (*worker)->s->lbset);
                 ap_rprintf(r, "<td>%" APR_SIZE_T_FMT "</td><td>",
                            (*worker)->s->elected);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1813167&r1=1813166&r2=1813167&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Tue Oct 24 10:50:34 2017
@@ -1093,11 +1093,10 @@ static int balancer_handler(request_rec
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01192) "settings worker params");
 
         if ((val = apr_table_get(params, "w_lf"))) {
-            int ival;
             double fval = atof(val);
-            ival = fval * 100.0;
+            int ival = fval * 100.0;
             if (ival >= 100 && ival <= 10000) {
-                wsel->s->lbfactor = ival;
+                wsel->s->lbfactor = ival / 100;
                 if (bsel)
                     recalc_factors(bsel);
             }
@@ -1364,8 +1363,8 @@ static int balancer_handler(request_rec
                           "</httpd:scheme>\n", NULL);
                 ap_rvputs(r, "          <httpd:hostname>", worker->s->hostname,
                           "</httpd:hostname>\n", NULL);
-                ap_rprintf(r, "          <httpd:loadfactor>%.2f</httpd:loadfactor>\n",
-                          (float)(worker->s->lbfactor)/100.0);
+                ap_rprintf(r, "          <httpd:loadfactor>%d</httpd:loadfactor>\n",
+                           worker->s->lbfactor);
                 ap_rprintf(r,
                            "          <httpd:port>%d</httpd:port>\n",
                            worker->s->port);
@@ -1418,8 +1417,8 @@ static int balancer_handler(request_rec
                            "          <httpd:lbstatus>%d</httpd:lbstatus>\n",
                            worker->s->lbstatus);
                 ap_rprintf(r,
-                           "          <httpd:loadfactor>%.2f</httpd:loadfactor>\n",
-                           (float)(worker->s->lbfactor)/100.0);
+                           "          <httpd:loadfactor>%d</httpd:loadfactor>\n",
+                           worker->s->lbfactor);
                 ap_rprintf(r,
                            "          <httpd:transferred>%" APR_OFF_T_FMT "</httpd:transferred>\n",
                            worker->s->transferred);
@@ -1605,7 +1604,7 @@ static int balancer_handler(request_rec
                           NULL);
                 ap_rvputs(r, "</td><td>",
                           ap_escape_html(r->pool, worker->s->redirect), NULL);
-                ap_rprintf(r, "</td><td>%.2f</td>", (float)(worker->s->lbfactor)/100.0);
+                ap_rprintf(r, "</td><td>%d</td>", worker->s->lbfactor);
                 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);
@@ -1640,7 +1639,7 @@ static int balancer_handler(request_rec
             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='%.2f'></td></tr>\n", (float)(wsel->s->lbfactor)/100.0);
+            ap_rprintf(r, "value='%d'></td></tr>\n", wsel->s->lbfactor);
             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);



Mime
View raw message