Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions proxy/ParentSelection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down