From 1112b6c958669815fcd8c78e49d060b2664f815d Mon Sep 17 00:00:00 2001 From: "John J. Rushford" Date: Mon, 29 Aug 2016 20:07:23 +0000 Subject: [PATCH] TS-4744: ParentConsistentHash::selectParent may select the unavailable parent. --- proxy/ParentConsistentHash.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proxy/ParentConsistentHash.cc b/proxy/ParentConsistentHash.cc index 0179fb83479..1b3317900ca 100644 --- a/proxy/ParentConsistentHash.cc +++ b/proxy/ParentConsistentHash.cc @@ -142,6 +142,8 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir prtmp = (pRecord *)fhash->lookup(NULL, &result->chashIter[last_lookup], &wrap_around[last_lookup], &hash); if (prtmp) { pRec = (parents[last_lookup] + prtmp->idx); + } else { + pRec = NULL; } } while (prtmp && strcmp(prtmp->hostname, result->hostname) == 0); } @@ -184,6 +186,8 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir if (prtmp) { pRec = (parents[last_lookup] + prtmp->idx); Debug("parent_select", "Selected a new parent: %s.", pRec->hostname); + } else { + pRec = NULL; } } if (wrap_around[PRIMARY] && chash[SECONDARY] == NULL) {