From c2cb3345069d0ba6c0029ee5f4f9ebc89e42dcad Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Wed, 25 Aug 2010 16:37:05 +0000 Subject: [PATCH] add comment to explain mysterious policy in concurrentWrapper --- src/stasis/replacementPolicy/concurrentWrapper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stasis/replacementPolicy/concurrentWrapper.c b/src/stasis/replacementPolicy/concurrentWrapper.c index 5a1a436..b4aabfd 100644 --- a/src/stasis/replacementPolicy/concurrentWrapper.c +++ b/src/stasis/replacementPolicy/concurrentWrapper.c @@ -72,6 +72,10 @@ static void* cwGetStaleHelper(struct replacementPolicy* impl, void*(*func)(struc } } if(bucket != oldbucket) { + // note that, even on success, we increment the bucket. Otherwise, we could + // (would) eventually get unlucky, and some caller would do a getStaleAndRemove, + // fail to get a latch, insert it back, and the next getStaleAndRemove would + // deterministically return the same page again, leading to an infinite loop. pthread_setspecific(rp->next_bucket, (void*) bucket); } return ret;