From bae3a4fd9406635608edf0c0d16c52cf7ca06a66 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@smartai.com> Date: 星期六, 23 十月 2021 15:20:57 +0800 Subject: [PATCH] Optimize the code source. --- src/shm/hashtable.cpp | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/shm/hashtable.cpp b/src/shm/hashtable.cpp index c4a81fc..62d052e 100755 --- a/src/shm/hashtable.cpp +++ b/src/shm/hashtable.cpp @@ -102,7 +102,7 @@ void *oldvalue; int rv; - if( (rv = svsem_wait(hashtable->mutex)) != 0) { + if( (rv = svsem_uni_wait(hashtable->mutex)) != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_remove\n"); } tailq_header_t *my_tailq_head = hashtable->array[code] ; @@ -140,7 +140,7 @@ void *hashtable_get(hashtable_t *hashtable, int key) { int rv; - if((rv = svsem_wait(hashtable->mutex)) != 0) { + if((rv = svsem_uni_wait(hashtable->mutex)) != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_get\n"); } void * res = _hashtable_get(hashtable, key); @@ -154,7 +154,7 @@ void hashtable_put(hashtable_t *hashtable, int key, void *value) { int rv; - if((rv = svsem_wait(hashtable->mutex)) != 0) { + if((rv = svsem_uni_wait(hashtable->mutex)) != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_put\n"); } _hashtable_put(hashtable, key, value); @@ -170,7 +170,7 @@ int rv; void * val; - if(( rv = svsem_wait(hashtable->mutex)) != 0) { + if(( rv = svsem_uni_wait(hashtable->mutex)) != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_put\n"); } if(overwrite) { @@ -178,7 +178,6 @@ goto suc; } val = _hashtable_get(hashtable, key); - // val = 1鏄痑llockey鐨勬儏鍐� if(val != NULL && val != (void *)1) goto fail; @@ -209,7 +208,7 @@ key = START_KEY; } - rv = svsem_wait(hashtable->mutex); + rv = svsem_uni_wait(hashtable->mutex); if(rv != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_alloc_key\n"); } @@ -272,7 +271,7 @@ { tailq_entry_t *item; int rv; - if( (rv = svsem_wait(hashtable->mutex)) != 0) { + if( (rv = svsem_uni_wait(hashtable->mutex)) != 0) { LoggerFactory::getLogger()->error(errno, "hashtable_removeall\n"); } for (int i = 0; i < MAPSIZE; i++) -- Gitblit v1.8.0