master(master_arg),
server_pool(NULL),
firstfree(-1),
- size(max_arg),
+ size(uint32_t(max_arg)),
current_size(0),
_owns_master(false)
{
for (int x= 0; x <= firstfree; ++x)
{
memcached_free(server_pool[x]);
- server_pool[x] = NULL;
+ server_pool[x]= NULL;
+ }
+
+ int error;
+ if ((error= pthread_mutex_destroy(&mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "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));
}
- pthread_mutex_destroy(&mutex);
- pthread_cond_destroy(&cond);
delete [] server_pool;
if (_owns_master)
{
bool memcached_pool_st::init(uint32_t initial)
{
server_pool= new (std::nothrow) memcached_st *[size];
- if (not server_pool)
+ if (server_pool == NULL)
+ {
return false;
+ }
/*
Try to create the initial size of the pool. An allocation failure at
{
rc= MEMCACHED_SUCCESS;
- if (pthread_mutex_lock(&mutex))
+ int error;
+ if ((error= pthread_mutex_lock(&mutex)) != 0)
{
rc= MEMCACHED_IN_PROGRESS;
return NULL;
{
if (relative_time.tv_sec == 0 and relative_time.tv_nsec == 0)
{
- pthread_mutex_unlock(&mutex);
+ error= pthread_mutex_unlock(&mutex);
rc= MEMCACHED_NOTFOUND;
return NULL;
int thread_ret;
if ((thread_ret= pthread_cond_timedwait(&cond, &mutex, &time_to_wait)) != 0)
{
- pthread_mutex_unlock(&mutex);
+ int unlock_error;
+ if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
if (thread_ret == ETIMEDOUT)
{
}
else if (grow_pool(this) == false)
{
- (void)pthread_mutex_unlock(&mutex);
+ int unlock_error;
+ if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
+
return NULL;
}
} while (ret == NULL);
- pthread_mutex_unlock(&mutex);
+ if ((error= pthread_mutex_unlock(&mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
return ret;
}
return false;
}
- if (pthread_mutex_lock(&mutex))
+ int error;
+ if ((error= pthread_mutex_lock(&mutex)))
{
rc= MEMCACHED_IN_PROGRESS;
return false;
if (firstfree == 0 and current_size == size)
{
/* we might have people waiting for a connection.. wake them up :-) */
- pthread_cond_broadcast(&cond);
+ if ((error= pthread_cond_broadcast(&cond)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_cond_broadcast() %s", strerror(error));
+ }
}
- (void)pthread_mutex_unlock(&mutex);
+ if ((error= pthread_mutex_unlock(&mutex)) != 0)
+ {
+ }
return true;
}
return MEMCACHED_INVALID_ARGUMENTS;
}
- if (pthread_mutex_lock(&pool->mutex))
+ int error;
+ if ((error= pthread_mutex_lock(&pool->mutex)))
{
return MEMCACHED_IN_PROGRESS;
}
memcached_return_t rc= memcached_behavior_set(pool->master, flag, data);
if (memcached_failed(rc))
{
- (void)pthread_mutex_unlock(&pool->mutex);
+ if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
return rc;
}
}
}
- (void)pthread_mutex_unlock(&pool->mutex);
+ if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
return rc;
}
return MEMCACHED_INVALID_ARGUMENTS;
}
- if (pthread_mutex_lock(&pool->mutex))
+ int error;
+ if ((error= pthread_mutex_lock(&pool->mutex)))
{
return MEMCACHED_IN_PROGRESS;
}
*value= memcached_behavior_get(pool->master, flag);
- (void)pthread_mutex_unlock(&pool->mutex);
+ if ((error= pthread_mutex_unlock(&pool->mutex)) != 0)
+ {
+ assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ }
return MEMCACHED_SUCCESS;
}