From 9a993218013a44dd34cb809858f6eb8b8fb84a72 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sun, 25 Nov 2007 10:04:41 -0800 Subject: [PATCH] Fixed bug in memcached_version() call --- lib/memcached_version.c | 6 +++--- tests/test.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/memcached_version.c b/lib/memcached_version.c index b811a031..a463dfc4 100644 --- a/lib/memcached_version.c +++ b/lib/memcached_version.c @@ -7,16 +7,16 @@ memcached_return memcached_version(memcached_st *ptr) memcached_return rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; char *response_ptr; + char *command= "version\r\n"; - send_length= strlen("version\r\n"); - memcpy(buffer, "version\r\n", send_length); + send_length= strlen(command); rc= MEMCACHED_SUCCESS; for (x= 0; x < ptr->number_of_hosts; x++) { memcached_return rrc; - rrc= memcached_do(ptr, x, buffer, send_length, 1); + rrc= memcached_do(ptr, x, command, send_length, 1); if (rrc != MEMCACHED_SUCCESS) { rc= MEMCACHED_SOME_ERRORS; diff --git a/tests/test.c b/tests/test.c index 2ea99ff2..9ffe21c7 100644 --- a/tests/test.c +++ b/tests/test.c @@ -14,7 +14,7 @@ #include "test.h" #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10 -#define TEST_SERVERS 1 +#define TEST_SERVERS 2 long int timedif(struct timeval a, struct timeval b) { @@ -54,14 +54,17 @@ void server_shutdown(char *server_string) { unsigned int x; - for (x= 0; x < TEST_SERVERS; x++) - { - char buffer[1024]; /* Nothing special for number */ - sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x); - system(buffer); - } if (server_string) + { + for (x= 0; x < TEST_SERVERS; x++) + { + char buffer[1024]; /* Nothing special for number */ + sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x); + system(buffer); + } + free(server_string); + } } int main(int argc, char *argv[]) @@ -123,25 +126,28 @@ int main(int argc, char *argv[]) for (x= 0; run->name; run++) { + unsigned int loop; + memcached_st *memc; + memcached_return rc; + struct timeval start_time, end_time; + if (wildcard && strcmp(wildcard, run->name)) continue; fprintf(stderr, "Testing %s", run->name); - memcached_st *memc; - memcached_return rc; - struct timeval start_time, end_time; - memc= memcached_create(NULL); assert(memc); - if (run->requires_flush) - memcached_flush(memc, 0); - rc= memcached_server_push(memc, servers); assert(rc == MEMCACHED_SUCCESS); - unsigned int loop; + if (run->requires_flush) + { + memcached_flush(memc, 0); + memcached_quit(memc); + } + for (loop= 0; loop < memcached_server_list_count(servers); loop++) { assert(memc->hosts[loop].stack_responses == 0); @@ -152,7 +158,9 @@ int main(int argc, char *argv[]) if (next->pre) { memcached_return rc; + WATCHPOINT_STRING(next->name); rc= next->pre(memc); + WATCHPOINT; if (rc != MEMCACHED_SUCCESS) { -- 2.30.2