You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2016/05/20 16:49:41 UTC
[trafficserver] 09/15: TS-4413: Fix potential consistent hash
iterator race.
This is an automated email from the ASF dual-hosted git repository.
sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 69ad8fe673ebb6950ced372afd08829f99fbd1f8
Author: John J. Rushford <Jo...@cable.comcast.com>
AuthorDate: Tue May 3 15:05:28 2016 +0000
TS-4413: Fix potential consistent hash iterator race.
(cherry picked from commit d01dc00218566e3e41b504de41a655cb80cf423b)
---
proxy/ParentConsistentHash.cc | 10 +++++-----
proxy/ParentConsistentHash.h | 1 -
proxy/ParentSelection.h | 4 +++-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/proxy/ParentConsistentHash.cc b/proxy/ParentConsistentHash.cc
index e145cbc..8ee81f9 100644
--- a/proxy/ParentConsistentHash.cc
+++ b/proxy/ParentConsistentHash.cc
@@ -120,7 +120,7 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir
path_hash = getPathHash(request_info, (ATSHash64 *)&hash);
fhash = chash[PRIMARY];
if (path_hash) {
- prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &chashIter[last_lookup], &wrap_around[last_lookup]);
+ prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &result->chashIter[last_lookup], &wrap_around[last_lookup]);
if (prtmp)
pRec = (parents[last_lookup] + prtmp->idx);
}
@@ -130,14 +130,14 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir
last_lookup = SECONDARY;
fhash = chash[SECONDARY];
path_hash = getPathHash(request_info, (ATSHash64 *)&hash);
- prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &chashIter[last_lookup], &wrap_around[last_lookup]);
+ prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &result->chashIter[last_lookup], &wrap_around[last_lookup]);
if (prtmp)
pRec = (parents[last_lookup] + prtmp->idx);
} else {
last_lookup = PRIMARY;
fhash = chash[PRIMARY];
do { // search until we've selected a different parent.
- prtmp = (pRecord *)fhash->lookup(NULL, &chashIter[last_lookup], &wrap_around[last_lookup], &hash);
+ prtmp = (pRecord *)fhash->lookup(NULL, &result->chashIter[last_lookup], &wrap_around[last_lookup], &hash);
if (prtmp)
pRec = (parents[last_lookup] + prtmp->idx);
} while (prtmp && strcmp(prtmp->hostname, result->hostname) == 0);
@@ -172,10 +172,10 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir
last_lookup = PRIMARY;
}
if (firstCall) {
- prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &chashIter[last_lookup], &wrap_around[last_lookup]);
+ prtmp = (pRecord *)fhash->lookup_by_hashval(path_hash, &result->chashIter[last_lookup], &wrap_around[last_lookup]);
firstCall = false;
} else {
- prtmp = (pRecord *)fhash->lookup(NULL, &chashIter[last_lookup], &wrap_around[last_lookup], &hash);
+ prtmp = (pRecord *)fhash->lookup(NULL, &result->chashIter[last_lookup], &wrap_around[last_lookup], &hash);
}
if (prtmp) {
diff --git a/proxy/ParentConsistentHash.h b/proxy/ParentConsistentHash.h
index e86a65e..443af78 100644
--- a/proxy/ParentConsistentHash.h
+++ b/proxy/ParentConsistentHash.h
@@ -43,7 +43,6 @@ class ParentConsistentHash : public ParentSelectionStrategy
// and SECONDARY parents.
ATSHash64Sip24 hash[2];
ATSConsistentHash *chash[2];
- ATSConsistentHashIter chashIter[2];
pRecord *parents[2];
bool foundParents[2][MAX_PARENTS];
bool ignore_query;
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 897e813..b72cbd8 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -267,7 +267,9 @@ private:
uint32_t last_parent;
uint32_t start_parent;
bool wrap_around;
- int last_lookup; // state for for consistent hash.
+ // state for consistent hash.
+ int last_lookup;
+ ATSConsistentHashIter chashIter[2];
friend class ParentConsistentHash;
friend class ParentRoundRobin;
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.