dev-libs/libmemcached: fixing bug 545088
authorMatthew Thode <mthode@mthode.org>
Fri, 14 Aug 2015 14:53:18 +0000 (09:53 -0500)
committerMatthew Thode <mthode@mthode.org>
Fri, 14 Aug 2015 14:53:18 +0000 (09:53 -0500)
Gentoo-bug: https://bugs.gentoo.org/show_bug.cgi?id=545088
Signed-off-by: Matthew Thode <mthode@mthode.org>
dev-libs/libmemcached/files/continuum-1.0.18.patch [new file with mode: 0644]
dev-libs/libmemcached/libmemcached-1.0.18-r3.ebuild [new file with mode: 0644]

diff --git a/dev-libs/libmemcached/files/continuum-1.0.18.patch b/dev-libs/libmemcached/files/continuum-1.0.18.patch
new file mode 100644 (file)
index 0000000..2969780
--- /dev/null
@@ -0,0 +1,56 @@
+diff --git libmemcached/memcached.cc libmemcached/memcached.cc
+index 337f918..6e88c25 100644
+--- libmemcached/memcached.cc
++++ libmemcached/memcached.cc
+@@ -285,6 +285,8 @@ void memcached_servers_reset(memcached_st *shell)
+   {
+     libmemcached_free(self, self->ketama.continuum);
+     self->ketama.continuum= NULL;
++    self->ketama.continuum_count= 0;
++    self->ketama.continuum_points_counter= 0;
+     memcached_instance_list_free(memcached_instance_list(self), self->number_of_hosts);
+     memcached_instance_set(self, NULL, 0);
+diff --git tests/libmemcached-1.0/all_tests.h tests/libmemcached-1.0/all_tests.h
+index b4abe9d..f89f007 100644
+--- tests/libmemcached-1.0/all_tests.h
++++ tests/libmemcached-1.0/all_tests.h
+@@ -452,6 +452,7 @@ collection_st collection[] ={
+   {"hsieh_availability", 0, 0, hsieh_availability},
+   {"murmur_availability", 0, 0, murmur_availability},
+   {"memcached_server_add", (test_callback_fn*)memcached_servers_reset_SETUP, 0, memcached_server_add_TESTS},
++  {"memcached_server_add(continuum)", (test_callback_fn*)memcached_servers_reset_CONTINUUM, 0, memcached_server_add_TESTS},
+   {"memcached_server_add(MEMCACHED_DISTRIBUTION_CONSISTENT)", (test_callback_fn*)memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_SETUP, 0, memcached_server_add_TESTS},
+   {"memcached_server_add(MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED)", (test_callback_fn*)memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED_SETUP, 0, memcached_server_add_TESTS},
+   {"block", 0, 0, tests},
+diff --git tests/libmemcached-1.0/setup_and_teardowns.cc tests/libmemcached-1.0/setup_and_teardowns.cc
+index 4191c38..eb29128 100644
+--- tests/libmemcached-1.0/setup_and_teardowns.cc
++++ tests/libmemcached-1.0/setup_and_teardowns.cc
+@@ -177,6 +177,16 @@ test_return_t memcached_servers_reset_SETUP(memcached_st *memc)
+   return TEST_SUCCESS;
+ }
++test_return_t memcached_servers_reset_CONTINUUM(memcached_st *memc)
++{
++  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT);
++  memcached_servers_reset(memc);
++  test_compare(0, memc->ketama.continuum_count);
++  // If memc->ketama.continuum_count is non-zero at this point, any call to
++  // memcached_server_add will cause a segfault.
++  return TEST_SUCCESS;
++}
++
+ test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_SETUP(memcached_st *memc)
+ {
+   test_compare(TEST_SUCCESS, memcached_servers_reset_SETUP(memc));
+diff --git tests/libmemcached-1.0/setup_and_teardowns.h tests/libmemcached-1.0/setup_and_teardowns.h
+index 7610c5a..59b56f6 100644
+--- tests/libmemcached-1.0/setup_and_teardowns.h
++++ tests/libmemcached-1.0/setup_and_teardowns.h
+@@ -64,3 +64,4 @@ test_return_t pre_buffer(memcached_st*);
+ test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_SETUP(memcached_st *memc);
+ test_return_t memcached_servers_reset_MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED_SETUP(memcached_st *memc);
+ test_return_t memcached_servers_reset_SETUP(memcached_st *memc);
++test_return_t memcached_servers_reset_CONTINUUM(memcached_st *memc);
+
diff --git a/dev-libs/libmemcached/libmemcached-1.0.18-r3.ebuild b/dev-libs/libmemcached/libmemcached-1.0.18-r3.ebuild
new file mode 100644 (file)
index 0000000..5520a33
--- /dev/null
@@ -0,0 +1,55 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+WANT_AUTOMAKE=1.13
+
+inherit autotools eutils multilib
+RESTRICT="test" # https://bugs.gentoo.org/show_bug.cgi?id=498250 https://bugs.launchpad.net/gentoo/+bug/1278023
+
+DESCRIPTION="a C client library to the memcached server"
+HOMEPAGE="http://libmemcached.org/libMemcached.html"
+SRC_URI="http://launchpad.net/${PN}/1.0/${PV}/+download/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sh ~sparc ~x86 ~sparc-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
+IUSE="debug hsieh +libevent sasl static-libs"
+
+DEPEND="net-misc/memcached
+       sasl? ( dev-libs/cyrus-sasl )
+       libevent? ( dev-libs/libevent )"
+RDEPEND="${DEPEND}"
+
+src_prepare() {
+       epatch "${FILESDIR}/debug-disable-enable-1.0.18.patch"
+       epatch "${FILESDIR}/continuum-1.0.18.patch"
+       sed -i '6i CFLAGS = @CFLAGS@' Makefile.am
+       sed -e "/_APPEND_COMPILE_FLAGS_ERROR(\[-fmudflapth\?\])/d" -i m4/ax_harden_compiler_flags.m4
+       eautoreconf
+}
+
+src_configure() {
+       econf \
+               --disable-dtrace \
+               $(use_enable static-libs static) \
+               $(use_enable sasl sasl) \
+               $(use_enable debug debug) \
+               $(use_enable debug assert) \
+               $(use_enable hsieh hsieh_hash) \
+               --libdir=/usr/$(get_libdir) \
+               ${myconf}
+}
+
+src_install() {
+       emake DESTDIR="${D}" install
+
+       use static-libs || rm -f "${D}"/usr/$(get_libdir)/lib*.la
+
+       dodoc AUTHORS ChangeLog README THANKS TODO
+       # remove manpage to avoid collision, see bug #299330
+       rm -f "${D}"/usr/share/man/man1/memdump.*
+       newman man/memdump.1 memcached_memdump.1
+}