int firstfree;
uint32_t size;
uint32_t current_size;
- char* version;
+ char *version;
};
-static memcached_return mutex_enter(pthread_mutex_t *mutex)
+static memcached_return_t mutex_enter(pthread_mutex_t *mutex)
{
int ret;
do
return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS;
}
-static memcached_return mutex_exit(pthread_mutex_t *mutex) {
+static memcached_return_t mutex_exit(pthread_mutex_t *mutex) {
int ret;
do
ret= pthread_mutex_unlock(mutex);
{
memcached_pool_st* ret = NULL;
memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER,
- .cond = PTHREAD_COND_INITIALIZER,
- .master = mmc,
- .mmc = calloc(max, sizeof(memcached_st*)),
- .firstfree = -1,
- .size = max,
- .current_size = 0 };
+ .cond = PTHREAD_COND_INITIALIZER,
+ .master = mmc,
+ .mmc = calloc(max, sizeof(memcached_st*)),
+ .firstfree = -1,
+ .size = max,
+ .current_size = 0 };
if (object.mmc != NULL)
{
/* Try to create the initial size of the pool. An allocation failure at
* this time is not fatal..
- */
+ */
for (unsigned int ii=0; ii < initial; ++ii)
if (grow_pool(ret) == -1)
break;
free(pool->mmc[xx]);
pool->mmc[xx] = NULL;
}
-
+
pthread_mutex_destroy(&pool->mutex);
pthread_cond_destroy(&pool->cond);
free(pool->mmc);
memcached_st* memcached_pool_pop(memcached_pool_st* pool,
bool block,
- memcached_return *rc)
+ memcached_return_t *rc)
{
memcached_st *ret= NULL;
if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS)
do
{
if (pool->firstfree > -1)
- ret= pool->mmc[pool->firstfree--];
+ ret= pool->mmc[pool->firstfree--];
else if (pool->current_size == pool->size)
{
if (!block)
}
else if (grow_pool(pool) == -1)
{
- *rc= mutex_exit(&pool->mutex);
- return NULL;
+ *rc= mutex_exit(&pool->mutex);
+ return NULL;
}
}
while (ret == NULL);
return ret;
}
-memcached_return memcached_pool_push(memcached_pool_st* pool,
- memcached_st *mmc)
+memcached_return_t memcached_pool_push(memcached_pool_st* pool,
+ memcached_st *mmc)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
return rc;
pthread_cond_broadcast(&pool->cond);
}
- memcached_return rval= mutex_exit(&pool->mutex);
+ memcached_return_t rval= mutex_exit(&pool->mutex);
if (rc == MEMCACHED_SOME_ERRORS)
return rc;
}
-memcached_return memcached_pool_behavior_set(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t data)
+memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t data)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
- return rc;
+ return rc;
/* update the master */
rc= memcached_behavior_set(pool->master, flag, data);
if (memcached_clone(pool->mmc[xx], pool->master) == NULL)
{
/* I'm not sure what to do in this case.. this would happen
- if we fail to push the server list inside the client..
- I should add a testcase for this, but I believe the following
- would work, except that you would add a hole in the pool list..
- in theory you could end up with an empty pool....
+ if we fail to push the server list inside the client..
+ I should add a testcase for this, but I believe the following
+ would work, except that you would add a hole in the pool list..
+ in theory you could end up with an empty pool....
*/
free(pool->mmc[xx]);
pool->mmc[xx]= NULL;
return mutex_exit(&pool->mutex);
}
-memcached_return memcached_pool_behavior_get(memcached_pool_st *pool,
- memcached_behavior flag,
- uint64_t *value)
+memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool,
+ memcached_behavior_t flag,
+ uint64_t *value)
{
- memcached_return rc= mutex_enter(&pool->mutex);
+ memcached_return_t rc= mutex_enter(&pool->mutex);
if (rc != MEMCACHED_SUCCESS)
return rc;
*value= memcached_behavior_get(pool->master, flag);