MCPcopy Create free account
hub / github.com/apache/trafficserver / findParent

Method findParent

src/proxy/ParentSelection.cc:106–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void
107ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, unsigned int fail_threshold, unsigned int retry_time)
108{
109 P_table *tablePtr = parent_table;
110 ParentRecord *defaultPtr = DefaultParent;
111 ParentRecord *rec;
112
113 // Check to see if the parent was set through the
114 // api
115 if (apiParentExists(rdata)) {
116 result->result = PARENT_SPECIFIED;
117 result->hostname = rdata->api_info->parent_proxy_name;
118 result->port = rdata->api_info->parent_proxy_port;
119 result->rec = extApiRecord;
120 result->start_parent = 0;
121 result->last_parent = 0;
122 result->url = rdata->get_host();
123
124 Dbg(dbg_ctl_parent_select, "Result for %s was API set parent %s:%d", rdata->get_host(), result->hostname, result->port);
125 return;
126 }
127
128 // Initialize the result structure
129 result->reset();
130
131 tablePtr->Match(rdata, result);
132 rec = result->rec;
133 result->url = rdata->get_host();
134
135 if (rec == nullptr) {
136 // No parents were found
137 //
138 // If there is a default parent, use it
139 if (defaultPtr != nullptr) {
140 rec = result->rec = defaultPtr;
141 } else {
142 result->result = PARENT_DIRECT;
143 Dbg(dbg_ctl_parent_select, "Returning PARENT_DIRECT (no parents were found)");
144 return;
145 }
146 }
147
148 if (rec != extApiRecord) {
149 selectParent(true, result, rdata, fail_threshold, retry_time);
150 }
151
152 if (dbg_ctl_parent_select.on()) {
153 switch (result->result) {
154 case PARENT_UNDEFINED:
155 DbgPrint(dbg_ctl_parent_select, "PARENT_UNDEFINED");
156 DbgPrint(dbg_ctl_parent_select, "Result for %s was %s", result->url, ParentResultStr[result->result]);
157 break;
158 case PARENT_FAIL:
159 DbgPrint(dbg_ctl_parent_select, "PARENT_FAIL");
160 break;
161 case PARENT_DIRECT:
162 DbgPrint(dbg_ctl_parent_select, "PARENT_DIRECT");
163 DbgPrint(dbg_ctl_parent_select, "Result for %s was %s", result->url, ParentResultStr[result->result]);

Callers 2

findServerMethod · 0.45
findParentFunction · 0.45

Calls 4

get_hostMethod · 0.45
resetMethod · 0.45
MatchMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected