Skip to content

Commit 96e1ac4

Browse files
Jeff Elslooelsloo
authored andcommitted
Fixes a scoping bug that leads to "sticky" weights (apache#8606) (apache#296)
* Due to scoping, the last user-provided weight seen will be applied to all subsequent hosts that lack a weight * Added a constant to specify the default weight * Resets the weight to default prior to parsing each parent's configuration to ensure defaults are used when no weight exists (cherry picked from commit 4e6dc02) Co-authored-by: Jeff Elsloo <elsloo@users.noreply.github.com>
1 parent 7928c21 commit 96e1ac4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

proxy/ParentSelection.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ ParentRecord::ProcessParents(char *val, bool isPrimary)
450450
int port = 0;
451451
char *tmp = nullptr, *tmp2 = nullptr, *tmp3 = nullptr;
452452
const char *errPtr = nullptr;
453-
float weight = 1.0;
453+
float weight = DEFAULT_PARENT_WEIGHT;
454454

455455
if (parents != nullptr && isPrimary == true) {
456456
return "Can not specify more than one set of parents";
@@ -474,6 +474,7 @@ ParentRecord::ProcessParents(char *val, bool isPrimary)
474474
// Loop through the set of parents specified
475475
//
476476
for (int i = 0; i < numTok; i++) {
477+
weight = DEFAULT_PARENT_WEIGHT; // reset weight to the default
477478
current = pTok[i];
478479

479480
// Find the parent port

proxy/ParentSelection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <vector>
4444

4545
#define MAX_PARENTS 64
46+
#define DEFAULT_PARENT_WEIGHT 1.0
4647

4748
struct RequestData;
4849
struct matcher_line;

0 commit comments

Comments
 (0)