From dd0c96a8a7220842fbd4eec11d7c6e28bfeaa1c8 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Tue, 24 Nov 2009 01:32:59 +0000 Subject: [PATCH] fixed implementation of hashtable_test_and_set --- src/stasis/concurrentHash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stasis/concurrentHash.c b/src/stasis/concurrentHash.c index 2436b65..fc2754b 100644 --- a/src/stasis/concurrentHash.c +++ b/src/stasis/concurrentHash.c @@ -194,7 +194,13 @@ void * hashtable_insert(hashtable_t *ht, pageid_t p, void * val) { return ret; } void * hashtable_test_and_set(hashtable_t *ht, pageid_t p, void * val) { - void * ret = hashtable_op(TRYINSERT, ht, p, val); + hashtable_bucket_handle_t h; + void * ret = hashtable_begin_op(TRYINSERT, ht, p, val, &h); + if(ret) { + hashtable_end_op(LOOKUP, ht, val, &h); + } else { + hashtable_end_op(INSERT, ht, val, &h); + } return ret; } void * hashtable_lookup(hashtable_t *ht, pageid_t p) {