This is an automated email from the ASF dual-hosted git repository.
jrushford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 98893b6 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.
98893b6 is described below
commit 98893b6df4e9acfe68c770ec6c8ef75bcebd0919
Author: John Rushford <[email protected]>
AuthorDate: Thu Jan 16 20:01:23 2020 +0000
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.
---
proxy/ParentSelection.cc | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index b3762ac..b82cef4 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -106,12 +106,6 @@ ParentConfigParams::findParent(HttpRequestData *rdata,
ParentResult *result, uns
ParentRecord *defaultPtr = DefaultParent;
ParentRecord *rec;
- Debug("parent_select", "In ParentConfigParams::findParent(): parent_table:
%p.", parent_table);
- ink_assert(result->result == PARENT_UNDEFINED);
-
- // Initialize the result structure
- result->reset();
-
// Check to see if the parent was set through the
// api
if (apiParentExists(rdata)) {
@@ -126,6 +120,9 @@ ParentConfigParams::findParent(HttpRequestData *rdata,
ParentResult *result, uns
return;
}
+ // Initialize the result structure
+ result->reset();
+
tablePtr->Match(rdata, result);
rec = result->rec;
@@ -226,17 +223,38 @@ ParentConfigParams::nextParent(HttpRequestData *rdata,
ParentResult *result, uns
bool
ParentConfigParams::parentExists(HttpRequestData *rdata)
{
- unsigned int fail_threshold = policy.FailThreshold;
- unsigned int retry_time = policy.ParentRetryTime;
+ P_table *tablePtr = parent_table;
+ ParentRecord *rec = nullptr;
ParentResult result;
- findParent(rdata, &result, fail_threshold, retry_time);
+ // Initialize the result structure;
+ result.reset();
- if (result.result == PARENT_SPECIFIED) {
- return true;
- } else {
+ tablePtr->Match(rdata, &result);
+ rec = result.rec;
+
+ if (rec == nullptr) {
+ Debug("parent_select", "No matching parent record was found for the
request.");
return false;
}
+
+ if (rec->num_parents > 0) {
+ for (int ii = 0; ii < rec->num_parents; ii++) {
+ if (rec->parents[ii].available) {
+ Debug("parent_select", "found available parent: %s",
rec->parents[ii].hostname);
+ return true;
+ }
+ }
+ }
+ if (rec->secondary_parents && rec->num_secondary_parents > 0) {
+ for (int ii = 0; ii < rec->num_secondary_parents; ii++) {
+ if (rec->secondary_parents[ii].available) {
+ Debug("parent_select", "found available parent: %s",
rec->secondary_parents[ii].hostname);
+ return true;
+ }
+ }
+ }
+ return false;
}
int ParentConfig::m_id = 0;