From: Date: Thu, 20 Sep 2007 17:18:27 +0000 (+0200) Subject: Test cases now pass X-Git-Tag: 0.2~16 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=87424051896224c7fbc3744a1dcf94dbd76ccfef;p=m6w6%2Flibmemcached Test cases now pass --- diff --git a/lib/memcached.c b/lib/memcached.c index c636b9b4..6a7715de 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -32,8 +32,9 @@ void memcached_deinit(memcached_st *ptr) { for (x= 0; x < ptr->number_of_hosts; x++) { - if (ptr->hosts[x].fd == -1) + if (ptr->hosts[x].fd > 0) close(ptr->hosts[x].fd); + free(ptr->hosts[x].hostname); } diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index 31f8ce16..592ede44 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -12,8 +12,8 @@ memcached_return memcached_server_add(memcached_st *ptr, char *hostname, unsigne ptr->hosts= (memcached_host_st *)realloc(ptr->hosts, sizeof(memcached_host_st) * (ptr->number_of_hosts+1)); memset(ptr->hosts, 0, sizeof(memcached_host_st) * (size_t)ptr->number_of_hosts); ptr->hosts[ptr->number_of_hosts].hostname= - (char *)malloc(sizeof(char) * (strlen(hostname) + 1)); - memset(ptr->hosts[ptr->number_of_hosts].hostname, 0, sizeof(char) * (strlen(hostname) + 1)); + (char *)malloc(sizeof(char) * (strlen(hostname)+1)); + memset(ptr->hosts[ptr->number_of_hosts].hostname, 0, strlen(hostname)+1); memcpy(ptr->hosts[ptr->number_of_hosts].hostname, hostname, strlen(hostname)); ptr->hosts[ptr->number_of_hosts].port= port; ptr->hosts[ptr->number_of_hosts].fd= -1; diff --git a/lib/memcached_response.c b/lib/memcached_response.c index ec29f0aa..693f9b30 100644 --- a/lib/memcached_response.c +++ b/lib/memcached_response.c @@ -43,8 +43,15 @@ memcached_return memcached_response(memcached_st *ptr, else return MEMCACHED_UNKNOWN_READ_FAILURE; } - case 'E': /* PROTOCOL ERROR */ - return MEMCACHED_PROTOCOL_ERROR; + case 'E': /* PROTOCOL ERROR or END */ + { + if (buffer[1] == 'N') + return MEMCACHED_NOTFOUND; + else if (buffer[1] == 'R') + return MEMCACHED_PROTOCOL_ERROR; + else + return MEMCACHED_UNKNOWN_READ_FAILURE; + } case 'C': /* CLIENT ERROR */ return MEMCACHED_CLIENT_ERROR; default: diff --git a/tests/test.c b/tests/test.c index 784ec9ae..4cf41c63 100644 --- a/tests/test.c +++ b/tests/test.c @@ -133,7 +133,6 @@ void get_test(void) string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); - printf("RC %u\n", rc); assert(rc == MEMCACHED_NOTFOUND); assert(string_length == 0); assert(!string);