Helper function to abstract calling ATSConsistentHash lookup_by_hashval() vs lookup().
| 114 | |
| 115 | // Helper function to abstract calling ATSConsistentHash lookup_by_hashval() vs lookup(). |
| 116 | static pRecord * |
| 117 | chash_lookup(ATSConsistentHash *fhash, uint64_t path_hash, ATSConsistentHashIter *chashIter, bool *wrap_around, |
| 118 | ATSHash64Sip24 *hash, bool *chash_init, bool *mapWrapped) |
| 119 | { |
| 120 | pRecord *prtmp; |
| 121 | |
| 122 | if (*chash_init == false) { |
| 123 | prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, chashIter, wrap_around); |
| 124 | *chash_init = true; |
| 125 | } else { |
| 126 | prtmp = (pRecord *)fhash->lookup(nullptr, chashIter, wrap_around, hash); |
| 127 | } |
| 128 | // Do not set wrap_around to true until we try all the parents at least once. |
| 129 | bool wrapped = *wrap_around; |
| 130 | *wrap_around = (*mapWrapped && *wrap_around) ? true : false; |
| 131 | if (!*mapWrapped && wrapped) { |
| 132 | *mapWrapped = true; |
| 133 | } |
| 134 | return prtmp; |
| 135 | } |
| 136 | |
| 137 | void |
| 138 | ParentConsistentHash::selectParent(bool first_call, ParentResult *result, RequestData *rdata, |
no test coverage detected