rpms/libmemcached/F-10 libmemcached-hsieh.patch, NONE, 1.1 libmemcached.spec, NONE, 1.1 sources, 1.1, 1.2

Remi Collet remi at fedoraproject.org
Sat May 2 06:34:59 UTC 2009


Author: remi

Update of /cvs/extras/rpms/libmemcached/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28119

Modified Files:
	sources 
Added Files:
	libmemcached-hsieh.patch libmemcached.spec 
Log Message:
new package

libmemcached-hsieh.patch:

--- NEW FILE libmemcached-hsieh.patch ---

# HG changeset patch
# User Eric Lambert <eric.lambert at sun.com>
# Date 1241145108 25200
# Node ID 0fc2011585180b2fc78cdaea965cd46926d62e59
# Parent 7cca934315994b66cbbf4c5cec1651112498e026
Disable hsieh algorithm by default

Per a conversation with Brian earlier this week, there are some licensing
issues with the hsieh hashing algorithm that make it 'desirable' for support
of this algorithm to be a compile time option. This patch turns off support
for hsieh by default but allows it to be used when '--enable-hsieh_hash' is
passed into configure.

--- a/configure.ac	Thu Apr 30 11:27:26 2009 -0700
+++ b/configure.ac	Thu Apr 30 19:31:48 2009 -0700
@@ -64,6 +64,7 @@
 sinclude(config/protocol_binary.m4)
 sinclude(config/memcached.m4)
 sinclude(config/setsockopt.m4)
+sinclude(config/hsieh.m4)
 
 # We only support GCC and Sun's forte at the moment
 if test "$GCC" = "yes"
--- a/docs/memcached_behavior.pod	Thu Apr 30 11:27:26 2009 -0700
+++ b/docs/memcached_behavior.pod	Thu Apr 30 19:31:48 2009 -0700
@@ -84,6 +84,7 @@
 Makes the default hashing algorithm for keys use MD5. The value can be set
 to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR. 
 Each hash has it's advantages and it's weaknesses. If you dont know or dont care, just go with the default.
+Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable support for this hashing algorithm, configure and build libmemcached with the --enable-hash_hsieh. 
 
 =item MEMCACHED_BEHAVIOR_DISTRIBUTION
 
--- a/libmemcached/Makefile.am	Thu Apr 30 11:27:26 2009 -0700
+++ b/libmemcached/Makefile.am	Thu Apr 30 19:31:48 2009 -0700
@@ -29,7 +29,6 @@
 lib_LTLIBRARIES = libmemcached.la
 
 libmemcached_la_SOURCES = crc.c \
-			  hsieh_hash.c \
 			  memcached.c \
 			  memcached_auto.c \
 			  memcached_analyze.c \
@@ -62,6 +61,10 @@
 			  murmur_hash.c \
 			  jenkins_hash.c
 
+if INCLUDE_HSIEH_SRC
+libmemcached_la_SOURCES += hsieh_hash.c
+endif
+
 if BUILD_BYTEORDER
 libmemcached_la_SOURCES += byteorder.c
 endif
--- a/libmemcached/common.h	Thu Apr 30 11:27:26 2009 -0700
+++ b/libmemcached/common.h	Thu Apr 30 19:31:48 2009 -0700
@@ -84,7 +84,9 @@
 void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result);
 uint32_t hash_crc32(const char *data,
                     size_t data_len);
+#ifdef HAVE_HSIEH_HASH
 uint32_t hsieh_hash(const char *key, size_t key_length);
+#endif
 uint32_t murmur_hash(const char *key, size_t key_length);
 uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval);
 
--- a/libmemcached/memcached_behavior.c	Thu Apr 30 11:27:26 2009 -0700
+++ b/libmemcached/memcached_behavior.c	Thu Apr 30 19:31:48 2009 -0700
@@ -100,6 +100,10 @@
       break;
     }
   case MEMCACHED_BEHAVIOR_HASH:
+#ifndef HAVE_HSIEH_HASH
+    if ((memcached_hash)(data) == MEMCACHED_HASH_HSIEH)
+      return MEMCACHED_FAILURE;
+#endif
     ptr->hash= (memcached_hash)(data);
     break;
   case MEMCACHED_BEHAVIOR_KETAMA_HASH:
--- a/libmemcached/memcached_hash.c	Thu Apr 30 11:27:26 2009 -0700
+++ b/libmemcached/memcached_hash.c	Thu Apr 30 19:31:48 2009 -0700
@@ -74,11 +74,13 @@
       }
     }
     break;
+#ifdef HAVE_HSIEH_HASH
     case MEMCACHED_HASH_HSIEH:
     {
       hash= hsieh_hash(key, key_length);
       break;
     }
+#endif
     case MEMCACHED_HASH_MURMUR:
     {
       hash= murmur_hash(key, key_length);
--- a/tests/function.c	Thu Apr 30 11:27:26 2009 -0700
+++ b/tests/function.c	Thu Apr 30 19:31:48 2009 -0700
@@ -2856,9 +2856,12 @@
 
 static memcached_return  pre_hsieh(memcached_st *memc)
 {
+#ifdef HAVE_HSIEH_HASH
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH);
-
   return MEMCACHED_SUCCESS;
+#else
+  return MEMCACHED_FAILURE;
+#endif
 }
 
 static memcached_return  pre_hash_fnv1_64(memcached_st *memc)
@@ -3069,7 +3072,8 @@
   memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT;
   memcached_hash hash;
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value);
-  pre_hsieh(memc);
+  if (pre_hsieh(memc) != MEMCACHED_SUCCESS)
+    return MEMCACHED_FAILURE;
 
   value= (memcached_server_distribution)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION);
   assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT);
@@ -3624,6 +3628,18 @@
   return TEST_SUCCESS;
 }
 
+test_return hsieh_avaibility_test (memcached_st *memc)
+{
+  memcached_return expected_rc= MEMCACHED_FAILURE;
+#ifdef HAVE_HSIEH_HASH
+  expected_rc= MEMCACHED_SUCCESS;
+#endif
+  memcached_return rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
+                                            (uint64_t)MEMCACHED_HASH_HSIEH);
+  assert(rc == expected_rc);
+  return TEST_SUCCESS;
+}
+
 test_st udp_setup_server_tests[] ={
   {"set_udp_behavior_test", 0, set_udp_behavior_test},
   {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},
@@ -3795,7 +3811,13 @@
   {0, 0, 0}
 };
 
+test_st hsieh_availability[] ={
+  {"hsieh_avaibility_test",0,hsieh_avaibility_test},
+  {0, 0, 0}
+};
+
 collection_st collection[] ={
+  {"hsieh_availability",0,0,hsieh_availability},
   {"udp_setup", init_udp, 0, udp_setup_server_tests},
   {"udp_io", init_udp, 0, upd_io_tests},
   {"udp_binary_io", binary_init_udp, 0, upd_io_tests},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/hsieh.m4	Thu Apr 30 19:31:48 2009 -0700
@@ -0,0 +1,22 @@
+dnl ---------------------------------------------------------------------------
+dnl Macro: HSIEH_HASH
+dnl ---------------------------------------------------------------------------
+AC_ARG_ENABLE(hsieh_hash,
+    [  --enable-hsieh_hash     build with support for hsieh hashing.],
+    [
+      if test "x$enableval" != "xno"; then
+          ENABLE_HSIEH="true"
+          AC_DEFINE([HAVE_HSIEH_HASH], [1], [Enables hsieh hashing support])
+      else
+          ENABLE_HSIEH="false"
+      fi
+    ],
+    [
+      ENABLE_HSIEH="false"
+    ]
+)
+
+AM_CONDITIONAL([INCLUDE_HSIEH_SRC], [test "x$ENABLE_HSIEH" = "xtrue"])
+dnl ---------------------------------------------------------------------------
+dnl End Macro: HSIEH_HASH
+dnl ---------------------------------------------------------------------------



--- NEW FILE libmemcached.spec ---
Name:      libmemcached
Summary:   Client library and command line tools for memcached server
Version:   0.28
Release:   2%{?dist}
License:   BSD
Group:     System Environment/Libraries
URL:       http://tangent.org/552/libmemcached.html
Source0:   http://download.tangent.org/libmemcached-%{version}.tar.gz

# Patch from upstream to disable hsieh hash (non free)
# http://hg.tangent.org/libmemcached/rev/0fc201158518
Patch0:    %{name}-hsieh.patch
# Temporary for above patch
BuildRequires: libtool

# checked during configure (for test suite)
BuildRequires: memcached

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)


%description
libmemcached is a C client library to the memcached server
(http://danga.com/memcached). It has been designed to be light on memory
usage, and provide full access to server side methods.

It also implements several command line tools:

memcat - Copy the value of a key to standard output.
memflush - Flush the contents of your servers.
memrm - Remove a key(s) from the server.
memstat - Dump the stats of your servers to standard output.
memslap - Generate testing loads on a memcached cluster.
memcp - Copy files to memcached servers.
memerror - Creates human readable messages from libmemcached error codes.


%package devel
Summary: Header files and development libraries for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig

%description devel
This package contains the header files and development libraries
for %{name}. If you like to develop programs using %{name}, 
you will need to install %{name}-devel.


%prep
%setup -q

%patch0 -p1 
%{__rm} -f libmemcached/hsieh_hash.c 

%{__mkdir} examples
%{__cp} -p tests/*.{c,cpp,h} examples/

# Temporary because of patched .m4 files
libtoolize --force
aclocal
automake --add-missing -Wno-portability
autoconf
autoheader


%build
%configure
%{__make} %{_smp_mflags}


%install
%{__rm} -rf %{buildroot}
%{__make} install  DESTDIR="%{buildroot}" AM_INSTALL_PROGRAM_FLAGS=""


%check
# For documentation only:
# test suite cannot run in mock (same port use for memcache servers on all arch)
# All tests completed successfully
# diff output.res output.cmp fails but result depend on server version
#%{__make} test


%clean
%{__rm} -rf %{buildroot}


%post -p /sbin/ldconfig


%postun -p /sbin/ldconfig
 

%files
%defattr (-,root,root,-) 
%doc AUTHORS COPYING README THANKS TODO ChangeLog
%{_bindir}/mem*
%exclude %{_libdir}/libmemcached.a
%exclude %{_libdir}/libmemcached.la
%{_libdir}/libmemcached.so.*
%{_mandir}/man1/mem*


%files devel
%defattr (-,root,root,-) 
%doc examples
%{_includedir}/libmemcached
%{_libdir}/libmemcached.so
%{_libdir}/pkgconfig/libmemcached.pc
%{_libdir}/libmemcached.so
%{_mandir}/man3/libmemcached*.3.gz
%{_mandir}/man3/memcached_*.3.gz


%changelog
* Fri May 01 2009 Remi Collet <Fedora at famillecollet.com> - 0.28-2
- add upstream patch to disable nonfree hsieh hash method

* Sat Apr 25 2009 Remi Collet <Fedora at famillecollet.com> - 0.28-1
- Initial RPM from Brian Aker spec
- create -devel subpackage
- add %%post %%postun %%check section



Index: sources
===================================================================
RCS file: /cvs/extras/rpms/libmemcached/F-10/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- sources	1 May 2009 20:58:20 -0000	1.1
+++ sources	2 May 2009 06:34:29 -0000	1.2
@@ -0,0 +1 @@
+7224e49fd4b0606f35b149ebb8c34e08  libmemcached-0.28.tar.gz




More information about the fedora-extras-commits mailing list