projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Merging Trond
[m6w6/libmemcached]
/
libmemcached
/
memcached_stats.c
diff --git
a/libmemcached/memcached_stats.c
b/libmemcached/memcached_stats.c
index e6a4e07f161f6f95df241d7ceb61b11ac5458802..d52f781a641199d03fe857238cb40f7fa3555a4e 100644
(file)
--- a/
libmemcached/memcached_stats.c
+++ b/
libmemcached/memcached_stats.c
@@
-30,12
+30,13
@@
static char *memcached_stat_keys[] = {
};
};
-static
void
set_data(memcached_stat_st *stat, char *key, char *value)
+static
memcached_return
set_data(memcached_stat_st *stat, char *key, char *value)
{
if(strlen(key) < 1)
{
{
if(strlen(key) < 1)
{
- fprintf(stderr, "Invalid key %s\n", key);
+ WATCHPOINT_STRING(key);
+ return MEMCACHED_UNKNOWN_STAT_KEY;
}
else if (!strcmp("pid", key))
{
}
else if (!strcmp("pid", key))
{
@@
-149,8
+150,11
@@
static void set_data(memcached_stat_st *stat, char *key, char *value)
strcmp("accepting_conns", key) == 0 ||
strcmp("listen_disabled_num", key) == 0))
{
strcmp("accepting_conns", key) == 0 ||
strcmp("listen_disabled_num", key) == 0))
{
- fprintf(stderr, "Unknown key %s\n", key);
+ WATCHPOINT_STRING(key);
+ return MEMCACHED_UNKNOWN_STAT_KEY;
}
}
+
+ return MEMCACHED_SUCCESS;
}
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
}
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
@@
-212,10
+216,7
@@
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat,
return NULL;
}
return NULL;
}
- if (ptr->call_malloc)
- ret= ptr->call_malloc(ptr, length + 1);
- else
- ret= malloc(length + 1);
+ ret= ptr->call_malloc(ptr, length + 1);
memcpy(ret, buffer, length);
ret[length]= '\0';
memcpy(ret, buffer, length);
ret[length]= '\0';
@@
-278,7
+279,11
@@
static memcached_return binary_stats_fetch(memcached_st *ptr,
return rc;
}
return rc;
}
- set_data(stat, buffer, buffer + strlen(buffer) + 1);
+ unlikely((set_data(stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY)
+ {
+ WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
+ WATCHPOINT_ASSERT(0);
+ }
} while (1);
/* shit... memcached_response will decrement the counter, so I need to
} while (1);
/* shit... memcached_response will decrement the counter, so I need to
@@
-332,7
+337,11
@@
static memcached_return ascii_stats_fetch(memcached_st *ptr,
value= string_ptr;
value[(size_t)(end_ptr-string_ptr)]= 0;
string_ptr= end_ptr + 2;
value= string_ptr;
value[(size_t)(end_ptr-string_ptr)]= 0;
string_ptr= end_ptr + 2;
- set_data(stat, key, value);
+ unlikely((set_data(stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY)
+ {
+ WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
+ WATCHPOINT_ASSERT(0);
+ }
}
else
break;
}
else
break;
@@
-357,10
+366,7
@@
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
return NULL;
}
return NULL;
}
- if (ptr->call_malloc)
- stats= (memcached_stat_st *)ptr->call_malloc(ptr, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
- else
- stats= (memcached_stat_st *)calloc(1, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
+ stats= ptr->call_calloc(ptr, ptr->number_of_hosts, sizeof(memcached_stat_st));
if (!stats)
{
if (!stats)
{
@@
-416,10
+422,7
@@
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat __att
char **list;
size_t length= sizeof(memcached_stat_keys);
char **list;
size_t length= sizeof(memcached_stat_keys);
- if (ptr->call_malloc)
- list= (char **)ptr->call_malloc(ptr, length);
- else
- list= (char **)calloc(1, length);
+ list= ptr->call_malloc(ptr, length);
if (!list)
{
if (!list)
{
@@
-442,7
+445,7
@@
void memcached_stat_free(memcached_st *ptr, memcached_stat_st *stat)
return;
}
return;
}
- if (ptr
&& ptr->call_free
)
+ if (ptr)
ptr->call_free(ptr, stat);
else
free(stat);
ptr->call_free(ptr, stat);
else
free(stat);