From: Date: Mon, 5 Jan 2009 18:02:01 +0000 (-0800) Subject: Bug fix for host_reset() X-Git-Tag: 0.26~30^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f0f1feb94039c2022fd6f92cdbc2ae2601998ee2;p=awesomized%2Flibmemcached Bug fix for host_reset() --- diff --git a/ChangeLog b/ChangeLog index c61a7a2c..8ff99b09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.26 * Fix for decrement on hash key + * Fixed assert that was catching bad memset() call in host_reset() 0.25 Fri Nov 28 09:59:35 PST 2008 * Jenkins HASH added. diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 34bbf689..df384a9c 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -58,7 +58,6 @@ void host_reset(memcached_st *ptr, memcached_server_st *host, const char *hostname, unsigned int port, uint32_t weight, memcached_connection type) { - memset(host, 0, sizeof(memcached_server_st)); strncpy(host->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1); host->root= ptr ? ptr : NULL; host->port= port; diff --git a/libmemcached/memcached_server.c b/libmemcached/memcached_server.c index c836cfa2..dfb18797 100644 --- a/libmemcached/memcached_server.c +++ b/libmemcached/memcached_server.c @@ -17,6 +17,7 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve } else { + ptr->is_allocated= MEMCACHED_USED; memset(ptr, 0, sizeof(memcached_server_st)); } @@ -27,7 +28,7 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve void memcached_server_free(memcached_server_st *ptr) { - memcached_return rc; + WATCHPOINT_NUMBER(ptr->port); WATCHPOINT_ASSERT(ptr->is_allocated != MEMCACHED_NOT_ALLOCATED); memcached_quit_server(ptr, 0); @@ -45,8 +46,6 @@ void memcached_server_free(memcached_server_st *ptr) else free(ptr); } - else - ptr->is_allocated= MEMCACHED_USED; } /* diff --git a/tests/function.c b/tests/function.c index f06c2786..3eab8fea 100644 --- a/tests/function.c +++ b/tests/function.c @@ -2126,6 +2126,28 @@ static test_return user_supplied_bug17(memcached_st *memc) return 0; } +/* + From Andrei on IRC +*/ + +test_return user_supplied_bug19(memcached_st *memc) +{ + memcached_st *m; + memcached_server_st *s; + memcached_return res; + + (void)memc; + + m= memcached_create(NULL); + memcached_server_add_with_weight(m, "localhost", 11311, 100); + memcached_server_add_with_weight(m, "localhost", 11312, 100); + + s= memcached_server_by_key(m, "a", 1, &res); + memcached_server_free(s); + + memcached_free(m); +} + #include "ketama_test_cases.h" test_return user_supplied_bug18(memcached_st *memc) { @@ -3000,6 +3022,7 @@ test_st user_tests[] ={ {"user_supplied_bug16", 1, user_supplied_bug16 }, {"user_supplied_bug17", 1, user_supplied_bug17 }, // {"user_supplied_bug18", 1, user_supplied_bug18 }, + {"user_supplied_bug19", 1, user_supplied_bug19 }, {0, 0, 0} };