From abea15ba1280807f2e9309e3ecba94e0fc0dc327 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 24 Oct 2017 10:50:34 +0000 Subject: [PATCH] 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. [Reverted by r1813255] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1813167 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/proxy/mod_proxy.c | 6 +++--- modules/proxy/mod_proxy_balancer.c | 17 ++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index f790204359..4cfb06758a 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 2aa491e372..a72d132fe4 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -104,13 +104,13 @@ static const char *set_worker_param(apr_pool_t *p, 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 *r, int flags) ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL); ap_rvputs(r, "", (*worker)->s->route, NULL); ap_rvputs(r, "", (*worker)->s->redirect, NULL); - ap_rprintf(r, "%.2f", (float)((*worker)->s->lbfactor)/100.0); + ap_rprintf(r, "%d", (*worker)->s->lbfactor); ap_rprintf(r, "%d", (*worker)->s->lbset); ap_rprintf(r, "%" APR_SIZE_T_FMT "", (*worker)->s->elected); diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index bdefc8f54e..5877aae1ab 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -1093,11 +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; 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 *r) "\n", NULL); ap_rvputs(r, " ", worker->s->hostname, "\n", NULL); - ap_rprintf(r, " %.2f\n", - (float)(worker->s->lbfactor)/100.0); + ap_rprintf(r, " %d\n", + worker->s->lbfactor); ap_rprintf(r, " %d\n", worker->s->port); @@ -1418,8 +1417,8 @@ static int balancer_handler(request_rec *r) " %d\n", worker->s->lbstatus); ap_rprintf(r, - " %.2f\n", - (float)(worker->s->lbfactor)/100.0); + " %d\n", + worker->s->lbfactor); ap_rprintf(r, " %" APR_OFF_T_FMT "\n", worker->s->transferred); @@ -1605,7 +1604,7 @@ static int balancer_handler(request_rec *r) NULL); ap_rvputs(r, "", ap_escape_html(r->pool, worker->s->redirect), NULL); - ap_rprintf(r, "%.2f", (float)(worker->s->lbfactor)/100.0); + ap_rprintf(r, "%d", worker->s->lbfactor); ap_rprintf(r, "%d", worker->s->lbset); ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, worker), NULL); ap_rputs("", r); @@ -1640,7 +1639,7 @@ static int balancer_handler(request_rec *r) ap_rputs("
\n", NULL); ap_rputs("\n", (float)(wsel->s->lbfactor)/100.0); + ap_rprintf(r, "value='%d'>\n", wsel->s->lbfactor); ap_rputs("\n", wsel->s->lbset); ap_rputs("
Load factor:
LB Set:
Route: