From: Brian Aker Date: Mon, 31 Dec 2012 08:54:39 +0000 (-0500) Subject: Fix allocation on stat so that it uses malloc() since a user will need to use free... X-Git-Tag: 1.0.16~21^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=5d44e2b91e7055316b538128ec37c0fa81bbc28d;p=awesomized%2Flibmemcached Fix allocation on stat so that it uses malloc() since a user will need to use free() to free it. --- diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index fa4b7317..b59c0ecb 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -631,6 +631,9 @@ static memcached_return_t network_connect(org::libmemcached::Instance* server) server->fd= INVALID_SOCKET; continue; + case ECONNREFUSED: + // Probably not running service + default: break; } @@ -830,16 +833,6 @@ static memcached_return_t _memcached_connect(org::libmemcached::Instance* server return rc; } -memcached_return_t memcached_connect_try(org::libmemcached::Instance* server) -{ - if (server and server->root and server->root->state.is_parsing) - { - return MEMCACHED_SUCCESS; - } - - return _memcached_connect(server, false); -} - memcached_return_t memcached_connect(org::libmemcached::Instance* server) { return _memcached_connect(server, true); diff --git a/libmemcached/connect.hpp b/libmemcached/connect.hpp index 96419513..de1c8df5 100644 --- a/libmemcached/connect.hpp +++ b/libmemcached/connect.hpp @@ -37,6 +37,4 @@ #pragma once -memcached_return_t memcached_connect_try(org::libmemcached::Instance*); memcached_return_t memcached_connect(org::libmemcached::Instance*); - diff --git a/libmemcached/instance.cc b/libmemcached/instance.cc index ed840e55..50d6388e 100644 --- a/libmemcached/instance.cc +++ b/libmemcached/instance.cc @@ -160,11 +160,6 @@ org::libmemcached::Instance* __instance_create_with(memcached_st *memc, memcached_io_init_udp_header(self, 0); } - if (memc) - { - memcached_connect_try(self); - } - return self; } diff --git a/libmemcached/stats.cc b/libmemcached/stats.cc index 43494948..eb337680 100644 --- a/libmemcached/stats.cc +++ b/libmemcached/stats.cc @@ -232,7 +232,6 @@ char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_ { char buffer[SMALL_STRING_LEN]; int length; - char *ret; *error= MEMCACHED_SUCCESS; @@ -336,7 +335,8 @@ char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_ return NULL; } - ret= static_cast(libmemcached_malloc(ptr, (size_t) (length + 1))); + // User is responsible for free() memory, so use malloc() + char *ret= static_cast(malloc(size_t(length +1))); memcpy(ret, buffer, (size_t) length); ret[length]= '\0';