Skip to content

Commit eac22df

Browse files
elsloozwoop
authored andcommitted
Fixes a scoping bug that leads to "sticky" weights (apache#8606)
* 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)
1 parent b1df63a commit eac22df

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

proxy/ParentSelection.cc

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

451451
if (parents != nullptr && isPrimary == true) {
452452
return "Can not specify more than one set of parents";
@@ -470,6 +470,7 @@ ParentRecord::ProcessParents(char *val, bool isPrimary)
470470
// Loop through the set of parents specified
471471
//
472472
for (int i = 0; i < numTok; i++) {
473+
weight = DEFAULT_PARENT_WEIGHT; // reset weight to the default
473474
current = pTok[i];
474475

475476
// 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)