Skip to content

Commit 98893b6

Browse files
committed
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.
1 parent 473e054 commit 98893b6

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

proxy/ParentSelection.cc

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
106106
ParentRecord *defaultPtr = DefaultParent;
107107
ParentRecord *rec;
108108

109-
Debug("parent_select", "In ParentConfigParams::findParent(): parent_table: %p.", parent_table);
110-
ink_assert(result->result == PARENT_UNDEFINED);
111-
112-
// Initialize the result structure
113-
result->reset();
114-
115109
// Check to see if the parent was set through the
116110
// api
117111
if (apiParentExists(rdata)) {
@@ -126,6 +120,9 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
126120
return;
127121
}
128122

123+
// Initialize the result structure
124+
result->reset();
125+
129126
tablePtr->Match(rdata, result);
130127
rec = result->rec;
131128

@@ -226,17 +223,38 @@ ParentConfigParams::nextParent(HttpRequestData *rdata, ParentResult *result, uns
226223
bool
227224
ParentConfigParams::parentExists(HttpRequestData *rdata)
228225
{
229-
unsigned int fail_threshold = policy.FailThreshold;
230-
unsigned int retry_time = policy.ParentRetryTime;
226+
P_table *tablePtr = parent_table;
227+
ParentRecord *rec = nullptr;
231228
ParentResult result;
232229

233-
findParent(rdata, &result, fail_threshold, retry_time);
230+
// Initialize the result structure;
231+
result.reset();
234232

235-
if (result.result == PARENT_SPECIFIED) {
236-
return true;
237-
} else {
233+
tablePtr->Match(rdata, &result);
234+
rec = result.rec;
235+
236+
if (rec == nullptr) {
237+
Debug("parent_select", "No matching parent record was found for the request.");
238238
return false;
239239
}
240+
241+
if (rec->num_parents > 0) {
242+
for (int ii = 0; ii < rec->num_parents; ii++) {
243+
if (rec->parents[ii].available) {
244+
Debug("parent_select", "found available parent: %s", rec->parents[ii].hostname);
245+
return true;
246+
}
247+
}
248+
}
249+
if (rec->secondary_parents && rec->num_secondary_parents > 0) {
250+
for (int ii = 0; ii < rec->num_secondary_parents; ii++) {
251+
if (rec->secondary_parents[ii].available) {
252+
Debug("parent_select", "found available parent: %s", rec->secondary_parents[ii].hostname);
253+
return true;
254+
}
255+
}
256+
}
257+
return false;
240258
}
241259

242260
int ParentConfig::m_id = 0;

0 commit comments

Comments
 (0)