diff options
Diffstat (limited to 'lang/io/files/patch-memchached-1-fd67950')
-rw-r--r-- | lang/io/files/patch-memchached-1-fd67950 | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/lang/io/files/patch-memchached-1-fd67950 b/lang/io/files/patch-memchached-1-fd67950 new file mode 100644 index 000000000000..4cf23b1d273a --- /dev/null +++ b/lang/io/files/patch-memchached-1-fd67950 @@ -0,0 +1,93 @@ +From fd6795035e4bcd1d2606f4f8f69c104bfbf5d5ff Mon Sep 17 00:00:00 2001 +From: Charles Ellis <hamled@gmail.com> +Date: Sun, 20 May 2012 23:20:33 -0700 +Subject: [PATCH] Memcached stats method compatiblity fix + +The stats method of Memcached is now compatible with libmemcached 1.0+. +--- + addons/Memcached/source/IoMemcached.c | 41 +++++++++++++++++++++-------------- + modules/FindLibMemcached.cmake | 2 +- + 2 files changed, 26 insertions(+), 17 deletions(-) + +diff --git a/addons/Memcached/source/IoMemcached.c b/addons/Memcached/source/IoMemcached.c +index c1be9ff..aa3fe67 100644 +--- addons/Memcached/source/IoMemcached.c ++++ addons/Memcached/source/IoMemcached.c +@@ -472,39 +472,48 @@ values are maps with actual stats. + IoObject *IoMemcached_stats(IoMemcached *self, IoObject *locals, IoMessage *m) + { + IoMap *results_map = IoMap_new(IOSTATE); ++ memcached_st *mc = DATA(self)->mc; + +- int i; +- for(i = 0; i < memcached_server_list_count(DATA(self)->mc->servers); i++) { +- memcached_server_st *server = DATA(self)->mc->servers + i; ++ uint32_t pos = 0; ++ while(pos < memcached_server_count(mc)) { ++ memcached_server_instance_st server = memcached_server_instance_by_position(mc, pos); ++ if(server == NULL) ++ continue; ++ ++ const char *hostname = memcached_server_name(server); ++ const in_port_t port = memcached_server_port(server); + + memcached_stat_st stats; +- if(memcached_stat_servername(&stats, "", server->hostname, server->port) != 0) ++ memcached_return_t rc = memcached_stat_servername(&stats, "", hostname, port); ++ if(rc != MEMCACHED_SUCCESS) + continue; + +- memcached_return rc; +- char **ckeys = memcached_stat_get_keys(DATA(self)->mc, &stats, &rc); +- +- int ckeys_count = 0; +- while(ckeys[ckeys_count] != NULL) +- ckeys_count++; ++ char **ckeys = memcached_stat_get_keys(mc, &stats, &rc); ++ if(rc != MEMCACHED_SUCCESS) ++ continue; + + IoMap *per_server_map = IoMap_new(IOSTATE); +- int k; +- for(k = 0; k < ckeys_count; k++) { +- char *ckey = ckeys[k]; +- char *cvalue = memcached_stat_get_value(DATA(self)->mc, &stats, ckey, &rc); ++ char *ckey = *ckeys; ++ while(ckey != NULL) { ++ char *cvalue = memcached_stat_get_value(mc, &stats, ckey, &rc); ++ if(rc != MEMCACHED_SUCCESS) ++ continue; ++ + IoMap_rawAtPut(per_server_map, IOSYMBOL(ckey), IOSYMBOL(cvalue)); + free(cvalue); ++ ckey++; + } + + free(ckeys); + + // "127.0.0.1:11211" +- char *server_key = (char *) malloc((strlen(server->hostname) + 1 + 5 + 1) * sizeof(char)); +- sprintf(server_key, "%s:%d", server->hostname, server->port); ++ char *server_key = (char *) malloc((strlen(hostname) + 1 + 5 + 1) * sizeof(char)); ++ sprintf(server_key, "%s:%d", hostname, port); + + IoMap_rawAtPut(results_map, IOSYMBOL(server_key), per_server_map); + free(server_key); ++ ++ pos++; + } + + return results_map; +diff --git a/modules/FindLibMemcached.cmake b/modules/FindLibMemcached.cmake +index 46bf5e5..07ee3bb 100644 +--- modules/FindLibMemcached.cmake ++++ modules/FindLibMemcached.cmake +@@ -6,7 +6,7 @@ + + FIND_PATH(LIBMEMCACHED_INCLUDE_DIR libmemcached/memcached.h) + +-FIND_LIBRARY(LIBMEMCACHED_LIBRARY NAMES memcached PATH /usr/lib /usr/local/lib) ++FIND_LIBRARY(LIBMEMCACHED_LIBRARY NAMES memcached libmemcached PATH /usr/lib /usr/local/lib) + + IF(LIBMEMCACHED_INCLUDE_DIR AND LIBMEMCACHED_LIBRARY) + SET(LIBMEMCACHED_FOUND 1) |