From 6da3e92dab82554db8492d2bd7981ecd9ef3fd65 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 23 七月 2020 15:57:34 +0800 Subject: [PATCH] sycronized --- src/queue/hashtable.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/queue/hashtable.c b/src/queue/hashtable.c index 43c59ce..21700ac 100755 --- a/src/queue/hashtable.c +++ b/src/queue/hashtable.c @@ -91,9 +91,12 @@ size_t code = hashcode(key); tailq_entry_t *item; void *oldvalue; + + SemUtil::dec(hashtable->wlock); tailq_header_t *my_tailq_head = hashtable->array[code] ; if ( my_tailq_head == NULL) { + SemUtil::inc(hashtable->wlock); return NULL; } else @@ -108,11 +111,12 @@ /* mm_free the item as we don't need it anymore. */ mm_free(item); - + SemUtil::inc(hashtable->wlock); return oldvalue; } } } + SemUtil::inc(hashtable->wlock); return NULL; } @@ -124,6 +128,7 @@ void hashtable_removeall(hashtable_t *hashtable) { tailq_entry_t *item; + SemUtil::dec(hashtable->wlock); for (int i = 0; i < MAPSIZE; i++) { tailq_header_t *my_tailq_head = hashtable->array[i] ; @@ -139,6 +144,7 @@ mm_free(my_tailq_head); hashtable->array[i] = NULL; } + SemUtil::inc(hashtable->wlock); } /** -- Gitblit v1.8.0