| 229 | } |
| 230 | |
| 231 | bool |
| 232 | ParentConfigParams::parentExists(HttpRequestData *rdata) |
| 233 | { |
| 234 | P_table *tablePtr = parent_table; |
| 235 | ParentRecord *rec = nullptr; |
| 236 | ParentResult result; |
| 237 | |
| 238 | // Initialize the result structure; |
| 239 | result.reset(); |
| 240 | |
| 241 | tablePtr->Match(rdata, &result); |
| 242 | rec = result.rec; |
| 243 | |
| 244 | if (rec == nullptr) { |
| 245 | Dbg(dbg_ctl_parent_select, "No matching parent record was found for the request."); |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | if (rec->num_parents > 0) { |
| 250 | for (int ii = 0; ii < rec->num_parents; ii++) { |
| 251 | if (rec->parents[ii].available) { |
| 252 | Dbg(dbg_ctl_parent_select, "found available parent: %s", rec->parents[ii].hostname); |
| 253 | return true; |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | if (rec->secondary_parents && rec->num_secondary_parents > 0) { |
| 258 | for (int ii = 0; ii < rec->num_secondary_parents; ii++) { |
| 259 | if (rec->secondary_parents[ii].available) { |
| 260 | Dbg(dbg_ctl_parent_select, "found available parent: %s", rec->secondary_parents[ii].hostname); |
| 261 | return true; |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | return false; |
| 266 | } |
| 267 | |
| 268 | int ParentConfig::m_id = 0; |
| 269 |
no test coverage detected