Skip to content

Commit ffbaa4a

Browse files
jrushfordzwoop
authored andcommitted
Fixes Issue #6321 caused when proxy.config.http.no_dns_just_forward_to_parent
is enabled. When this configuration variable is enabled, a parent selection strategies findParent() function is called twice on each transaction resulting in unexpected results such as every other parent is only used in a strict round robin strategy. (cherry picked from commit 98893b6) Conflicts: proxy/ParentSelection.cc
1 parent 7bd54d9 commit ffbaa4a

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

proxy/ParentSelection.cc

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
140140
return;
141141
}
142142

143+
// Initialize the result structure
144+
result->reset();
145+
143146
tablePtr->Match(rdata, result);
144147
rec = result->rec;
145148

@@ -240,17 +243,38 @@ ParentConfigParams::nextParent(HttpRequestData *rdata, ParentResult *result, uns
240243
bool
241244
ParentConfigParams::parentExists(HttpRequestData *rdata)
242245
{
243-
unsigned int fail_threshold = policy.FailThreshold;
244-
unsigned int retry_time = policy.ParentRetryTime;
246+
P_table *tablePtr = parent_table;
247+
ParentRecord *rec = nullptr;
245248
ParentResult result;
246249

247-
findParent(rdata, &result, fail_threshold, retry_time);
250+
// Initialize the result structure;
251+
result.reset();
248252

249-
if (result.result == PARENT_SPECIFIED) {
250-
return true;
251-
} else {
253+
tablePtr->Match(rdata, &result);
254+
rec = result.rec;
255+
256+
if (rec == nullptr) {
257+
Debug("parent_select", "No matching parent record was found for the request.");
252258
return false;
253259
}
260+
261+
if (rec->num_parents > 0) {
262+
for (int ii = 0; ii < rec->num_parents; ii++) {
263+
if (rec->parents[ii].available) {
264+
Debug("parent_select", "found available parent: %s", rec->parents[ii].hostname);
265+
return true;
266+
}
267+
}
268+
}
269+
if (rec->secondary_parents && rec->num_secondary_parents > 0) {
270+
for (int ii = 0; ii < rec->num_secondary_parents; ii++) {
271+
if (rec->secondary_parents[ii].available) {
272+
Debug("parent_select", "found available parent: %s", rec->secondary_parents[ii].hostname);
273+
return true;
274+
}
275+
}
276+
}
277+
return false;
254278
}
255279

256280
int ParentConfig::m_id = 0;

0 commit comments

Comments
 (0)