X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Flibmemcachedutil%2Fpool.cc;h=759b9576c66fe345d1b8fda089092592e077ac9e;hb=46bddd219732926aae6734a1962c3899b9946ffb;hp=718be8b25c4dd363260457283525cb3c45cf9afb;hpb=0f27cca46a4a529459ca988268972f480a9730c6;p=awesomized%2Flibmemcached diff --git a/src/libmemcachedutil/pool.cc b/src/libmemcachedutil/pool.cc index 718be8b2..759b9576 100644 --- a/src/libmemcachedutil/pool.cc +++ b/src/libmemcachedutil/pool.cc @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include @@ -62,12 +64,12 @@ struct memcached_pool_st { } int error; - if ((error = pthread_mutex_destroy(&mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_destroy() %s(%d)", strerror(error), error); + if ((error = pthread_mutex_destroy(&mutex))) { + assert_vmsg(error, "pthread_mutex_destroy() %s(%d)", strerror(error), error); } - if ((error = pthread_cond_destroy(&cond)) != 0) { - assert_vmsg(error != 0, "pthread_cond_destroy() %s", strerror(error)); + if ((error = pthread_cond_destroy(&cond))) { + assert_vmsg(error, "pthread_cond_destroy() %s", strerror(error)); } delete[] server_pool; @@ -200,7 +202,7 @@ memcached_st *memcached_pool_st::fetch(const struct timespec &relative_time, rc = MEMCACHED_SUCCESS; int error; - if ((error = pthread_mutex_lock(&mutex)) != 0) { + if ((error = pthread_mutex_lock(&mutex))) { rc = MEMCACHED_IN_PROGRESS; return NULL; } @@ -222,10 +224,10 @@ memcached_st *memcached_pool_st::fetch(const struct timespec &relative_time, time_to_wait.tv_nsec = relative_time.tv_nsec; int thread_ret; - if ((thread_ret = pthread_cond_timedwait(&cond, &mutex, &time_to_wait)) != 0) { + if ((thread_ret = pthread_cond_timedwait(&cond, &mutex, &time_to_wait))) { int unlock_error; - if ((unlock_error = pthread_mutex_unlock(&mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((unlock_error = pthread_mutex_unlock(&mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } if (thread_ret == ETIMEDOUT) { @@ -239,16 +241,16 @@ memcached_st *memcached_pool_st::fetch(const struct timespec &relative_time, } } else if (grow_pool(this) == false) { int unlock_error; - if ((unlock_error = pthread_mutex_unlock(&mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((unlock_error = pthread_mutex_unlock(&mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } return NULL; } } while (ret == NULL); - if ((error = pthread_mutex_unlock(&mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((error = pthread_mutex_unlock(&mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } return ret; @@ -283,12 +285,12 @@ bool memcached_pool_st::release(memcached_st *released, memcached_return_t &rc) if (firstfree == 0 and current_size == size) { /* we might have people waiting for a connection.. wake them up :-) */ - if ((error = pthread_cond_broadcast(&cond)) != 0) { - assert_vmsg(error != 0, "pthread_cond_broadcast() %s", strerror(error)); + if ((error = pthread_cond_broadcast(&cond))) { + assert_vmsg(error, "pthread_cond_broadcast() %s", strerror(error)); } } - if ((error = pthread_mutex_unlock(&mutex)) != 0) { + if ((error = pthread_mutex_unlock(&mutex))) { } return true; @@ -362,8 +364,8 @@ memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcache /* update the master */ memcached_return_t rc = memcached_behavior_set(pool->master, flag, data); if (memcached_failed(rc)) { - if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((error = pthread_mutex_unlock(&pool->mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } return rc; } @@ -388,8 +390,8 @@ memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcache } } - if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((error = pthread_mutex_unlock(&pool->mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } return rc; @@ -408,8 +410,8 @@ memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcache *value = memcached_behavior_get(pool->master, flag); - if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) { - assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error)); + if ((error = pthread_mutex_unlock(&pool->mutex))) { + assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error)); } return MEMCACHED_SUCCESS;