projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Merge in all current libmemcached work, plus restore older, working,
[awesomized/libmemcached]
/
libmemcached
/
stats.c
diff --git
a/libmemcached/stats.c
b/libmemcached/stats.c
index 0c52d97a6b4fbe8c9f1b6367dcca796b8b7c2a16..83d342a1f096559cc66d5a66be5e124415783d7c 100644
(file)
--- a/
libmemcached/stats.c
+++ b/
libmemcached/stats.c
@@
-162,7
+162,8
@@
static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char
strcmp("reclaimed", key) == 0))
{
WATCHPOINT_STRING(key);
strcmp("reclaimed", key) == 0))
{
WATCHPOINT_STRING(key);
- return MEMCACHED_UNKNOWN_STAT_KEY;
+ /* return MEMCACHED_UNKNOWN_STAT_KEY; */
+ return MEMCACHED_SUCCESS;
}
return MEMCACHED_SUCCESS;
}
return MEMCACHED_SUCCESS;
@@
-177,49
+178,49
@@
char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_
*error= MEMCACHED_SUCCESS;
*error= MEMCACHED_SUCCESS;
- if (!memcmp("pid", key, s
trlen("pid")
))
+ if (!memcmp("pid", key, s
izeof("pid") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pid);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pid);
- else if (!memcmp("uptime", key, s
trlen("uptime")
))
+ else if (!memcmp("uptime", key, s
izeof("uptime") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->uptime);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->uptime);
- else if (!memcmp("time", key, s
trlen("time")
))
+ else if (!memcmp("time", key, s
izeof("time") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->time);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->time);
- else if (!memcmp("version", key, s
trlen("version")
))
+ else if (!memcmp("version", key, s
izeof("version") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%s", memc_stat->version);
length= snprintf(buffer, SMALL_STRING_LEN,"%s", memc_stat->version);
- else if (!memcmp("pointer_size", key, s
trlen("pointer_size")
))
+ else if (!memcmp("pointer_size", key, s
izeof("pointer_size") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pointer_size);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pointer_size);
- else if (!memcmp("rusage_user", key, s
trlen("rusage_user")
))
+ else if (!memcmp("rusage_user", key, s
izeof("rusage_user") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds);
length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds);
- else if (!memcmp("rusage_system", key, s
trlen("rusage_system")
))
+ else if (!memcmp("rusage_system", key, s
izeof("rusage_system") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds);
length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds);
- else if (!memcmp("curr_items", key, s
trlen("curr_items")
))
+ else if (!memcmp("curr_items", key, s
izeof("curr_items") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_items);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_items);
- else if (!memcmp("total_items", key, s
trlen("total_items")
))
+ else if (!memcmp("total_items", key, s
izeof("total_items") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_items);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_items);
- else if (!memcmp("curr_connections", key, s
trlen("curr_connections")
))
+ else if (!memcmp("curr_connections", key, s
izeof("curr_connections") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_connections);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_connections);
- else if (!memcmp("total_connections", key, s
trlen("total_connections")
))
+ else if (!memcmp("total_connections", key, s
izeof("total_connections") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_connections);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_connections);
- else if (!memcmp("connection_structures", key, s
trlen("connection_structures")
))
+ else if (!memcmp("connection_structures", key, s
izeof("connection_structures") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->connection_structures);
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->connection_structures);
- else if (!memcmp("cmd_get", key, s
trlen("cmd_get")
))
+ else if (!memcmp("cmd_get", key, s
izeof("cmd_get") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_get);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_get);
- else if (!memcmp("cmd_set", key, s
trlen("cmd_set")
))
+ else if (!memcmp("cmd_set", key, s
izeof("cmd_set") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_set);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_set);
- else if (!memcmp("get_hits", key, s
trlen("get_hits")
))
+ else if (!memcmp("get_hits", key, s
izeof("get_hits") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_hits);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_hits);
- else if (!memcmp("get_misses", key, s
trlen("get_misses")
))
+ else if (!memcmp("get_misses", key, s
izeof("get_misses") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_misses);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_misses);
- else if (!memcmp("evictions", key, s
trlen("evictions")
))
+ else if (!memcmp("evictions", key, s
izeof("evictions") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->evictions);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->evictions);
- else if (!memcmp("bytes_read", key, s
trlen("bytes_read")
))
+ else if (!memcmp("bytes_read", key, s
izeof("bytes_read") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_read);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_read);
- else if (!memcmp("bytes_written", key, s
trlen("bytes_written")
))
+ else if (!memcmp("bytes_written", key, s
izeof("bytes_written") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_written);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_written);
- else if (!memcmp("bytes", key, s
trlen("bytes")
))
+ else if (!memcmp("bytes", key, s
izeof("bytes") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes);
- else if (!memcmp("limit_maxbytes", key, s
trlen("limit_maxbytes")
))
+ else if (!memcmp("limit_maxbytes", key, s
izeof("limit_maxbytes") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->limit_maxbytes);
length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->limit_maxbytes);
- else if (!
memcmp("threads", key, strlen("threads")
))
+ else if (!
memcmp("threads", key, sizeof("threads") -1
))
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->threads);
else
{
length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->threads);
else
{
@@
-227,6
+228,12
@@
char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_
return NULL;
}
return NULL;
}
+ if (length >= SMALL_STRING_LEN || length < 0)
+ {
+ *error= MEMCACHED_FAILURE;
+ return NULL;
+ }
+
ret= libmemcached_malloc(ptr, (size_t) (length + 1));
memcpy(ret, buffer, (size_t) length);
ret[length]= '\0';
ret= libmemcached_malloc(ptr, (size_t) (length + 1));
memcpy(ret, buffer, (size_t) length);
ret[length]= '\0';
@@
-329,7
+336,7
@@
static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,
{
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
{
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
-
size_
t send_length;
+
in
t send_length;
if (args)
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
if (args)
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
@@
-338,10
+345,10
@@
static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"stats\r\n");
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"stats\r\n");
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+ if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE
|| send_length < 0
)
return MEMCACHED_WRITE_FAILURE;
return MEMCACHED_WRITE_FAILURE;
- rc= memcached_do(instance, buffer, send_length, true);
+ rc= memcached_do(instance, buffer,
(size_t)
send_length, true);
if (rc != MEMCACHED_SUCCESS)
goto error;
if (rc != MEMCACHED_SUCCESS)
goto error;
@@
-393,27
+400,40
@@
error:
return rc;
}
return rc;
}
-memcached_stat_st *memcached_stat(memcached_st *
ptr
, char *args, memcached_return_t *error)
+memcached_stat_st *memcached_stat(memcached_st *
self
, char *args, memcached_return_t *error)
{
memcached_return_t rc;
memcached_stat_st *stats;
{
memcached_return_t rc;
memcached_stat_st *stats;
- unlikely (ptr->flags.use_udp)
+ if (! self)
+ {
+ WATCHPOINT_ASSERT(self);
+ return NULL;
+ }
+
+ WATCHPOINT_ASSERT(error);
+
+
+ unlikely (self->flags.use_udp)
{
{
- *error= MEMCACHED_NOT_SUPPORTED;
+ if (error)
+ *error= MEMCACHED_NOT_SUPPORTED;
+
return NULL;
}
return NULL;
}
- stats= libmemcached_calloc(
ptr, memcached_server_count(ptr
), sizeof(memcached_stat_st));
+ stats= libmemcached_calloc(
self, memcached_server_count(self
), sizeof(memcached_stat_st));
if (! stats)
{
if (! stats)
{
- *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ if (error)
+ *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+
return NULL;
}
rc= MEMCACHED_SUCCESS;
return NULL;
}
rc= MEMCACHED_SUCCESS;
- for (uint32_t x= 0; x < memcached_server_count(
ptr
); x++)
+ for (uint32_t x= 0; x < memcached_server_count(
self
); x++)
{
memcached_return_t temp_return;
memcached_server_write_instance_st instance;
{
memcached_return_t temp_return;
memcached_server_write_instance_st instance;
@@
-421,11
+441,11
@@
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
stat_instance= stats + x;
stat_instance= stats + x;
- stat_instance->root=
ptr
;
+ stat_instance->root=
self
;
- instance= memcached_server_instance_fetch(
ptr
, x);
+ instance= memcached_server_instance_fetch(
self
, x);
- if (
ptr
->flags.binary_protocol)
+ if (
self
->flags.binary_protocol)
{
temp_return= binary_stats_fetch(stat_instance, args, instance, NULL);
}
{
temp_return= binary_stats_fetch(stat_instance, args, instance, NULL);
}
@@
-438,7
+458,9
@@
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
rc= MEMCACHED_SOME_ERRORS;
}
rc= MEMCACHED_SOME_ERRORS;
}
- *error= rc;
+ if (error)
+ *error= rc;
+
return stats;
}
return stats;
}