}
memcached_server_response_decrement(instance);
- do
+ while (1)
{
memcached_return_t rc= memcached_response(instance, buffer, sizeof(buffer), NULL);
WATCHPOINT_ASSERT(0);
}
}
- } while (1);
+ }
/*
* memcached_response will decrement the counter, so I need to reset it..
{
memcached_st memc;
+ memcached_stat_st unused_memc_stat;
+ if (memc_stat == NULL)
+ {
+ memc_stat= &unused_memc_stat;
+ }
+
memset(memc_stat, 0, sizeof(memcached_stat_st));
memcached_st *memc_ptr= memcached_create(&memc);
We make a copy of the keys since at some point in the not so distant future
we will add support for "found" keys.
*/
-char ** memcached_stat_get_keys(memcached_st *ptr,
+char ** memcached_stat_get_keys(memcached_st *memc,
memcached_stat_st *,
memcached_return_t *error)
{
- if (ptr == NULL)
+ if (memc)
{
- return NULL;
- }
+ char **list= static_cast<char **>(libmemcached_malloc(memc, sizeof(memcached_stat_keys)));
+ if (list == NULL)
+ {
+ if (error)
+ {
+ *error= memcached_set_error(*memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+ }
- char **list= static_cast<char **>(libmemcached_malloc(ptr, sizeof(memcached_stat_keys)));
- if (not list)
- {
- *error= memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
- return NULL;
- }
+ return NULL;
+ }
- memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys));
+ memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys));
- *error= MEMCACHED_SUCCESS;
+ if (error)
+ {
+ *error= MEMCACHED_SUCCESS;
+ }
+
+ return list;
+ }
- return list;
+ return NULL;
}
void memcached_stat_free(const memcached_st *, memcached_stat_st *memc_stat)
{
WATCHPOINT_ASSERT(memc_stat); // Be polite, but when debugging catch this as an error
- if (memc_stat == NULL)
- {
- return;
- }
-
- if (memc_stat->root)
+ if (memc_stat)
{
libmemcached_free(memc_stat->root, memc_stat);
- return;
}
-
- libmemcached_free(NULL, memc_stat);
}
-static memcached_return_t call_stat_fn(memcached_st *ptr,
+static memcached_return_t call_stat_fn(memcached_st *memc,
org::libmemcached::Instance* instance,
void *context)
{
- memcached_return_t rc;
- local_context *check= (struct local_context *)context;
-
- if (memcached_is_binary(ptr))
- {
- rc= binary_stats_fetch(NULL, check->args, check->args_length, instance, check);
- }
- else
+ if (memc)
{
- rc= ascii_stats_fetch(NULL, check->args, check->args_length, instance, check);
+ local_context *check= (struct local_context *)context;
+
+ if (memcached_is_binary(memc))
+ {
+ return binary_stats_fetch(NULL, check->args, check->args_length, instance, check);
+ }
+ else
+ {
+ return ascii_stats_fetch(NULL, check->args, check->args_length, instance, check);
+ }
}
- return rc;
+ return MEMCACHED_INVALID_ARGUMENTS;
}
memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context)
{
- memcached_version(memc);
+ if (memcached_fatal(memcached_version(memc)))
+ {
+ return memcached_last_error(memc);
+ }
local_context check(func, context, args, args ? strlen(args) : 0);