memcached 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. data/CHANGELOG +2 -0
  2. data/Manifest +206 -12
  3. data/Rakefile +32 -1
  4. data/ext/extconf.rb +10 -35
  5. data/ext/libmemcached-0.32/AUTHORS +7 -0
  6. data/ext/libmemcached-0.32/COPYING +32 -0
  7. data/ext/libmemcached-0.32/ChangeLog +303 -0
  8. data/ext/libmemcached-0.32/INSTALL +302 -0
  9. data/ext/libmemcached-0.32/Makefile.am +36 -0
  10. data/ext/libmemcached-0.32/Makefile.in +828 -0
  11. data/ext/libmemcached-0.32/NEWS +1 -0
  12. data/ext/libmemcached-0.32/README +33 -0
  13. data/ext/libmemcached-0.32/THANKS +14 -0
  14. data/ext/libmemcached-0.32/TODO +11 -0
  15. data/ext/libmemcached-0.32/aclocal.m4 +1852 -0
  16. data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
  17. data/ext/libmemcached-0.32/clients/Makefile.in +770 -0
  18. data/ext/libmemcached-0.32/clients/client_options.h +32 -0
  19. data/ext/libmemcached-0.32/clients/execute.c +64 -0
  20. data/ext/libmemcached-0.32/clients/execute.h +5 -0
  21. data/ext/libmemcached-0.32/clients/generator.c +74 -0
  22. data/ext/libmemcached-0.32/clients/generator.h +20 -0
  23. data/ext/libmemcached-0.32/clients/memcat.c +178 -0
  24. data/ext/libmemcached-0.32/clients/memcp.c +251 -0
  25. data/ext/libmemcached-0.32/clients/memdump.c +170 -0
  26. data/ext/libmemcached-0.32/clients/memerror.c +80 -0
  27. data/ext/libmemcached-0.32/clients/memflush.c +143 -0
  28. data/ext/libmemcached-0.32/clients/memrm.c +160 -0
  29. data/ext/libmemcached-0.32/clients/memslap.c +441 -0
  30. data/ext/libmemcached-0.32/clients/memstat.c +326 -0
  31. data/ext/libmemcached-0.32/clients/utilities.c +207 -0
  32. data/ext/libmemcached-0.32/clients/utilities.h +41 -0
  33. data/ext/libmemcached-0.32/config.h.in +252 -0
  34. data/ext/libmemcached-0.32/config/compile +143 -0
  35. data/ext/libmemcached-0.32/config/config.guess +1561 -0
  36. data/ext/libmemcached-0.32/config/config.rpath +666 -0
  37. data/ext/libmemcached-0.32/config/config.sub +1686 -0
  38. data/ext/libmemcached-0.32/config/depcomp +630 -0
  39. data/ext/libmemcached-0.32/config/install-sh +520 -0
  40. data/ext/libmemcached-0.32/config/ltmain.sh +8406 -0
  41. data/ext/libmemcached-0.32/config/missing +376 -0
  42. data/ext/libmemcached-0.32/configure +23048 -0
  43. data/ext/libmemcached-0.32/configure.ac +122 -0
  44. data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
  45. data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
  46. data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
  47. data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
  48. data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
  49. data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
  50. data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
  51. data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
  52. data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
  53. data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
  54. data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
  55. data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
  56. data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
  57. data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
  58. data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
  59. data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
  60. data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
  61. data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
  62. data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
  63. data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
  64. data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
  65. data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
  66. data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
  67. data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
  68. data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
  69. data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
  70. data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
  71. data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
  72. data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
  73. data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
  74. data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
  75. data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
  76. data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
  77. data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
  78. data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
  79. data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
  80. data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
  81. data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
  82. data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
  83. data/ext/libmemcached-0.32/libmemcached/common.h +183 -0
  84. data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
  85. data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
  86. data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
  87. data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
  88. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +28 -0
  89. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
  90. data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
  91. data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
  92. data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
  93. data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
  94. data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
  95. data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -0
  96. data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
  97. data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
  98. data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
  99. data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +285 -0
  100. data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
  101. data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
  102. data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +361 -0
  103. data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
  104. data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
  105. data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
  106. data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
  107. data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
  108. data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
  109. data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +22 -0
  110. data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -0
  111. data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
  112. data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
  113. data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
  114. data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
  115. data/ext/libmemcached-0.32/libmemcached/memcached_io.c +547 -0
  116. data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -0
  117. data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
  118. data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
  119. data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
  120. data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
  121. data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
  122. data/ext/libmemcached-0.32/libmemcached/memcached_response.c +528 -0
  123. data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
  124. data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
  125. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
  126. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
  127. data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
  128. data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
  129. data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +454 -0
  130. data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
  131. data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
  132. data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
  133. data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
  134. data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
  135. data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
  136. data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
  137. data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
  138. data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
  139. data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
  140. data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
  141. data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
  142. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
  143. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +602 -0
  144. data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
  145. data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
  146. data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
  147. data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
  148. data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
  149. data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
  150. data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
  151. data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
  152. data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
  153. data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
  154. data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
  155. data/ext/libmemcached-0.32/m4/libtool.m4 +7360 -0
  156. data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -0
  157. data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
  158. data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
  159. data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +92 -0
  160. data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
  161. data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
  162. data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
  163. data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
  164. data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
  165. data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
  166. data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
  167. data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
  168. data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
  169. data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
  170. data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
  171. data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
  172. data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
  173. data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
  174. data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
  175. data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
  176. data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
  177. data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
  178. data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
  179. data/ext/libmemcached-0.32/support/Makefile.am +4 -0
  180. data/ext/libmemcached-0.32/support/Makefile.in +485 -0
  181. data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
  182. data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
  183. data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
  184. data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
  185. data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
  186. data/ext/libmemcached-0.32/tests/Makefile.am +105 -0
  187. data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
  188. data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
  189. data/ext/libmemcached-0.32/tests/function.c +4781 -0
  190. data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
  191. data/ext/libmemcached-0.32/tests/output.cmp +7 -0
  192. data/ext/libmemcached-0.32/tests/output.res +7 -0
  193. data/ext/libmemcached-0.32/tests/output2.res +46 -0
  194. data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
  195. data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
  196. data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
  197. data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
  198. data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
  199. data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
  200. data/ext/libmemcached-0.32/tests/server.c +118 -0
  201. data/ext/libmemcached-0.32/tests/server.h +25 -0
  202. data/ext/libmemcached-0.32/tests/start.c +16 -0
  203. data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
  204. data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
  205. data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
  206. data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
  207. data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
  208. data/ext/libmemcached-0.32/tests/test.c +137 -0
  209. data/ext/libmemcached-0.32/tests/test.h +46 -0
  210. data/ext/libmemcached-0.32/tests/udp.c +76 -0
  211. data/memcached.gemspec +4 -4
  212. data/test/unit/memcached_test.rb +30 -0
  213. metadata +213 -16
  214. data/ext/libmemcached-0.32.tar.gz +0 -0
  215. data/ext/libmemcached-1.patch +0 -270
  216. data/ext/libmemcached-10.patch +0 -12
  217. data/ext/libmemcached-2.patch +0 -116
  218. data/ext/libmemcached-3.patch +0 -8
  219. data/ext/libmemcached-4.patch +0 -40
  220. data/ext/libmemcached-5.patch +0 -832
  221. data/ext/libmemcached-6.patch +0 -20
  222. data/ext/libmemcached-7.patch +0 -2989
  223. data/ext/libmemcached-8.patch +0 -137
  224. data/ext/libmemcached-9.patch +0 -13
  225. data/ext/sasl.patch +0 -29283
@@ -0,0 +1,31 @@
1
+ #include "common.h"
2
+
3
+ /* Byte swap a 64-bit number. */
4
+ static inline uint64_t swap64(uint64_t in)
5
+ {
6
+ #ifndef BYTEORDER_BIG_ENDIAN
7
+ /* Little endian, flip the bytes around until someone makes a faster/better
8
+ * way to do this. */
9
+ uint64_t rv= 0;
10
+ uint8_t x= 0;
11
+ for(x= 0; x < 8; x++)
12
+ {
13
+ rv= (rv << 8) | (in & 0xff);
14
+ in >>= 8;
15
+ }
16
+ return rv;
17
+ #else
18
+ /* big-endian machines don't need byte swapping */
19
+ return in;
20
+ #endif
21
+ }
22
+
23
+ uint64_t ntohll(uint64_t value)
24
+ {
25
+ return swap64(value);
26
+ }
27
+
28
+ uint64_t htonll(uint64_t value)
29
+ {
30
+ return swap64(value);
31
+ }
@@ -0,0 +1,183 @@
1
+ /*
2
+ Common include file for libmemached
3
+ */
4
+
5
+ #ifndef LIBMEMCACHED_COMMON_H
6
+ #define LIBMEMCACHED_COMMON_H
7
+
8
+ #include "config.h"
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include <strings.h>
14
+ #include <ctype.h>
15
+ #include <sys/types.h>
16
+ #include <sys/socket.h>
17
+ #include <netinet/in.h>
18
+ #include <arpa/inet.h>
19
+ #include <netdb.h>
20
+ #include <unistd.h>
21
+ #include <limits.h>
22
+ #include <errno.h>
23
+ #include <fcntl.h>
24
+ #include <sys/un.h>
25
+ #include <netinet/tcp.h>
26
+ #ifdef TIME_WITH_SYS_TIME
27
+ # include <sys/time.h>
28
+ # include <time.h>
29
+ #else
30
+ # ifdef HAVE_SYS_TIME_H
31
+ # include <sys/time.h>
32
+ # else
33
+ # include <time.h>
34
+ # endif
35
+ #endif
36
+
37
+ /* Note we need the 2 concats below because arguments to ##
38
+ * are not expanded, so we need to expand __LINE__ with one indirection
39
+ * before doing the actual concatenation.
40
+ * From: http://www.pixelbeat.org/programming/gcc/static_assert.html
41
+ */
42
+ #define ASSERT_CONCAT_(a, b) a##b
43
+ #define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
44
+ #define assert_on_compile(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
45
+
46
+ /* Define this here, which will turn on the visibilty controls while we're
47
+ * building libmemcached.
48
+ */
49
+ #define BUILDING_LIBMEMCACHED 1
50
+
51
+
52
+ #include "libmemcached/memcached.h"
53
+ #include "libmemcached/memcached_watchpoint.h"
54
+
55
+ /* These are private not to be installed headers */
56
+ #include "libmemcached/memcached_io.h"
57
+ #include "libmemcached/memcached_internal.h"
58
+ #include "libmemcached/libmemcached_probes.h"
59
+ #include "libmemcached/memcached/protocol_binary.h"
60
+
61
+ /* string value */
62
+ struct memcached_continuum_item_st {
63
+ uint32_t index;
64
+ uint32_t value;
65
+ };
66
+
67
+
68
+ #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
69
+
70
+ #define likely(x) if((x))
71
+ #define unlikely(x) if((x))
72
+
73
+ #else
74
+
75
+ #define likely(x) if(__builtin_expect(!!(x), 1))
76
+ #define unlikely(x) if(__builtin_expect((x), 0))
77
+ #endif
78
+
79
+
80
+ #define MEMCACHED_BLOCK_SIZE 1024
81
+ #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
82
+ #define SMALL_STRING_LEN 1024
83
+ #define HUGE_STRING_LEN 8196
84
+
85
+
86
+ typedef enum {
87
+ MEM_NO_BLOCK= (1 << 0),
88
+ MEM_TCP_NODELAY= (1 << 1),
89
+ MEM_REUSE_MEMORY= (1 << 2),
90
+ MEM_USE_MD5= (1 << 3),
91
+ /* 4 was once Ketama */
92
+ MEM_USE_CRC= (1 << 5),
93
+ MEM_USE_CACHE_LOOKUPS= (1 << 6),
94
+ MEM_SUPPORT_CAS= (1 << 7),
95
+ MEM_BUFFER_REQUESTS= (1 << 8),
96
+ MEM_USE_SORT_HOSTS= (1 << 9),
97
+ MEM_VERIFY_KEY= (1 << 10),
98
+ /* 11 used for weighted ketama */
99
+ MEM_KETAMA_WEIGHTED= (1 << 11),
100
+ MEM_BINARY_PROTOCOL= (1 << 12),
101
+ MEM_HASH_WITH_PREFIX_KEY= (1 << 13),
102
+ MEM_NOREPLY= (1 << 14),
103
+ MEM_USE_UDP= (1 << 15),
104
+ MEM_AUTO_EJECT_HOSTS= (1 << 16)
105
+ } memcached_flags;
106
+
107
+ /* Hashing algo */
108
+
109
+ LIBMEMCACHED_LOCAL
110
+ void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result);
111
+ LIBMEMCACHED_LOCAL
112
+ uint32_t hash_crc32(const char *data,
113
+ size_t data_len);
114
+ #ifdef HAVE_HSIEH_HASH
115
+ LIBMEMCACHED_LOCAL
116
+ uint32_t hsieh_hash(const char *key, size_t key_length);
117
+ #endif
118
+ LIBMEMCACHED_LOCAL
119
+ uint32_t murmur_hash(const char *key, size_t key_length);
120
+ LIBMEMCACHED_LOCAL
121
+ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval);
122
+
123
+ LIBMEMCACHED_LOCAL
124
+ memcached_return memcached_connect(memcached_server_st *ptr);
125
+ LIBMEMCACHED_LOCAL
126
+ memcached_return memcached_response(memcached_server_st *ptr,
127
+ char *buffer, size_t buffer_length,
128
+ memcached_result_st *result);
129
+ LIBMEMCACHED_LOCAL
130
+ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death);
131
+
132
+ #define memcached_server_response_increment(A) (A)->cursor_active++
133
+ #define memcached_server_response_decrement(A) (A)->cursor_active--
134
+ #define memcached_server_response_reset(A) (A)->cursor_active=0
135
+
136
+ LIBMEMCACHED_LOCAL
137
+ memcached_return memcached_do(memcached_server_st *ptr, const void *commmand,
138
+ size_t command_length, uint8_t with_flush);
139
+ LIBMEMCACHED_LOCAL
140
+ memcached_return value_fetch(memcached_server_st *ptr,
141
+ char *buffer,
142
+ memcached_result_st *result);
143
+ LIBMEMCACHED_LOCAL
144
+ void server_list_free(memcached_st *ptr, memcached_server_st *servers);
145
+
146
+ LIBMEMCACHED_LOCAL
147
+ memcached_return memcached_key_test(const char **keys, size_t *key_length,
148
+ size_t number_of_keys);
149
+
150
+
151
+ LIBMEMCACHED_LOCAL
152
+ uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length);
153
+
154
+ #ifndef HAVE_HTONLL
155
+ LIBMEMCACHED_LOCAL
156
+ extern uint64_t ntohll(uint64_t);
157
+ LIBMEMCACHED_LOCAL
158
+ extern uint64_t htonll(uint64_t);
159
+ #endif
160
+
161
+ LIBMEMCACHED_LOCAL
162
+ memcached_return memcached_purge(memcached_server_st *ptr);
163
+
164
+ static inline memcached_return memcached_validate_key_length(size_t key_length,
165
+ bool binary) {
166
+ unlikely (key_length == 0)
167
+ return MEMCACHED_BAD_KEY_PROVIDED;
168
+
169
+ if (binary)
170
+ {
171
+ unlikely (key_length > 0xffff)
172
+ return MEMCACHED_BAD_KEY_PROVIDED;
173
+ }
174
+ else
175
+ {
176
+ unlikely (key_length >= MEMCACHED_MAX_KEY)
177
+ return MEMCACHED_BAD_KEY_PROVIDED;
178
+ }
179
+
180
+ return MEMCACHED_SUCCESS;
181
+ }
182
+
183
+ #endif /* LIBMEMCACHED_COMMON_H */
@@ -0,0 +1,86 @@
1
+ /* The crc32 functions and data was originally written by Spencer
2
+ * Garrett <srg@quick.com> and was gleaned from the PostgreSQL source
3
+ * tree via the files contrib/ltree/crc32.[ch] and from FreeBSD at
4
+ * src/usr.bin/cksum/crc32.c.
5
+ */
6
+
7
+ #include "common.h"
8
+
9
+ static const uint32_t crc32tab[256] = {
10
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
11
+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
12
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
13
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
14
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
15
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
16
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
17
+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
18
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
19
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
20
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
21
+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
22
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
23
+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
24
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
25
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
26
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
27
+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
28
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
29
+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
30
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
31
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
32
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
33
+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
34
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
35
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
36
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
37
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
38
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
39
+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
40
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
41
+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
42
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
43
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
44
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
45
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
46
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
47
+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
48
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
49
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
50
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
51
+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
52
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
53
+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
54
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
55
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
56
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
57
+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
58
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
59
+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
60
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
61
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
62
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
63
+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
64
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
65
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
66
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
67
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
68
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
69
+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
70
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
71
+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
72
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
73
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
74
+ };
75
+
76
+
77
+ uint32_t hash_crc32(const char *key, size_t key_length)
78
+ {
79
+ uint32_t x;
80
+ uint32_t crc= UINT32_MAX;
81
+
82
+ for (x= 0; x < key_length; x++)
83
+ crc= (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff];
84
+
85
+ return ~crc;
86
+ }
@@ -0,0 +1,68 @@
1
+ /* By Paul Hsieh (C) 2004, 2005. Covered under the Paul Hsieh
2
+ * derivative license.
3
+ * See: http://www.azillionmonkeys.com/qed/weblicense.html for license
4
+ * details.
5
+ * http://www.azillionmonkeys.com/qed/hash.html
6
+ */
7
+
8
+ #include "common.h"
9
+
10
+ #undef get16bits
11
+ #if (defined(__GNUC__) && defined(__i386__))
12
+ #define get16bits(d) (*((const uint16_t *) (d)))
13
+ #endif
14
+
15
+ #if !defined (get16bits)
16
+ #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
17
+ +(uint32_t)(((const uint8_t *)(d))[0]) )
18
+ #endif
19
+
20
+ uint32_t hsieh_hash(const char *key, size_t key_length)
21
+ {
22
+ uint32_t hash = 0, tmp;
23
+ int rem;
24
+
25
+ if (key_length <= 0 || key == NULL)
26
+ return 0;
27
+
28
+ rem = key_length & 3;
29
+ key_length >>= 2;
30
+
31
+ /* Main loop */
32
+ for (;key_length > 0; key_length--)
33
+ {
34
+ hash += get16bits (key);
35
+ tmp = (get16bits (key+2) << 11) ^ hash;
36
+ hash = (hash << 16) ^ tmp;
37
+ key += 2*sizeof (uint16_t);
38
+ hash += hash >> 11;
39
+ }
40
+
41
+ /* Handle end cases */
42
+ switch (rem)
43
+ {
44
+ case 3: hash += get16bits (key);
45
+ hash ^= hash << 16;
46
+ hash ^= key[sizeof (uint16_t)] << 18;
47
+ hash += hash >> 11;
48
+ break;
49
+ case 2: hash += get16bits (key);
50
+ hash ^= hash << 11;
51
+ hash += hash >> 17;
52
+ break;
53
+ case 1: hash += *key;
54
+ hash ^= hash << 10;
55
+ hash += hash >> 1;
56
+ }
57
+
58
+ /* Force "avalanching" of final 127 bits */
59
+ hash ^= hash << 3;
60
+ hash += hash >> 5;
61
+ hash ^= hash << 4;
62
+ hash += hash >> 17;
63
+ hash ^= hash << 25;
64
+ hash += hash >> 6;
65
+
66
+ return hash;
67
+ }
68
+
@@ -0,0 +1,213 @@
1
+ /*
2
+ *
3
+ * By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this
4
+ * code any way you wish, private, educational, or commercial. It's free.
5
+ * Use for hash table lookup, or anything where one collision in 2^^32 is
6
+ * acceptable. Do NOT use for cryptographic purposes.
7
+ * http://burtleburtle.net/bob/hash/index.html
8
+ *
9
+ * Modified by Brian Pontz for libmemcached
10
+ * TODO:
11
+ * Add big endian support
12
+ */
13
+
14
+ #include "common.h"
15
+
16
+ #define hashsize(n) ((uint32_t)1<<(n))
17
+ #define hashmask(n) (hashsize(n)-1)
18
+ #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
19
+
20
+ #define mix(a,b,c) \
21
+ { \
22
+ a -= c; a ^= rot(c, 4); c += b; \
23
+ b -= a; b ^= rot(a, 6); a += c; \
24
+ c -= b; c ^= rot(b, 8); b += a; \
25
+ a -= c; a ^= rot(c,16); c += b; \
26
+ b -= a; b ^= rot(a,19); a += c; \
27
+ c -= b; c ^= rot(b, 4); b += a; \
28
+ }
29
+
30
+ #define final(a,b,c) \
31
+ { \
32
+ c ^= b; c -= rot(b,14); \
33
+ a ^= c; a -= rot(c,11); \
34
+ b ^= a; b -= rot(a,25); \
35
+ c ^= b; c -= rot(b,16); \
36
+ a ^= c; a -= rot(c,4); \
37
+ b ^= a; b -= rot(a,14); \
38
+ c ^= b; c -= rot(b,24); \
39
+ }
40
+
41
+ /*
42
+ jenkins_hash() -- hash a variable-length key into a 32-bit value
43
+ k : the key (the unaligned variable-length array of bytes)
44
+ length : the length of the key, counting by bytes
45
+ initval : can be any 4-byte value
46
+ Returns a 32-bit value. Every bit of the key affects every bit of
47
+ the return value. Two keys differing by one or two bits will have
48
+ totally different hash values.
49
+
50
+ The best hash table sizes are powers of 2. There is no need to do
51
+ mod a prime (mod is sooo slow!). If you need less than 32 bits,
52
+ use a bitmask. For example, if you need only 10 bits, do
53
+ h = (h & hashmask(10));
54
+ In which case, the hash table should have hashsize(10) elements.
55
+ */
56
+
57
+ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval)
58
+ {
59
+ uint32_t a,b,c; /* internal state */
60
+ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
61
+
62
+ /* Set up the internal state */
63
+ a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
64
+
65
+ u.ptr = key;
66
+ #ifdef BYTEORDER_LITTLE_ENDIAN
67
+ if ((u.i & 0x3) == 0)
68
+ {
69
+ const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
70
+
71
+ /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
72
+ while (length > 12)
73
+ {
74
+ a += k[0];
75
+ b += k[1];
76
+ c += k[2];
77
+ mix(a,b,c);
78
+ length -= 12;
79
+ k += 3;
80
+ }
81
+
82
+ /*----------------------------- handle the last (probably partial) block */
83
+ /*
84
+ * "k[2]&0xffffff" actually reads beyond the end of the string, but
85
+ * then masks off the part it's not allowed to read. Because the
86
+ * string is aligned, the masked-off tail is in the same word as the
87
+ * rest of the string. Every machine with memory protection I've seen
88
+ * does it on word boundaries, so is OK with this. But VALGRIND will
89
+ * still catch it and complain. The masking trick does make the hash
90
+ * noticably faster for short strings (like English words).
91
+ */
92
+ switch(length)
93
+ {
94
+ case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
95
+ case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
96
+ case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
97
+ case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
98
+ case 8 : b+=k[1]; a+=k[0]; break;
99
+ case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
100
+ case 6 : b+=k[1]&0xffff; a+=k[0]; break;
101
+ case 5 : b+=k[1]&0xff; a+=k[0]; break;
102
+ case 4 : a+=k[0]; break;
103
+ case 3 : a+=k[0]&0xffffff; break;
104
+ case 2 : a+=k[0]&0xffff; break;
105
+ case 1 : a+=k[0]&0xff; break;
106
+ case 0 : return c; /* zero length strings require no mixing */
107
+ default: return c;
108
+ }
109
+
110
+ }
111
+ else if ((u.i & 0x1) == 0)
112
+ {
113
+ const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
114
+ const uint8_t *k8;
115
+
116
+ /*--------------- all but last block: aligned reads and different mixing */
117
+ while (length > 12)
118
+ {
119
+ a += k[0] + (((uint32_t)k[1])<<16);
120
+ b += k[2] + (((uint32_t)k[3])<<16);
121
+ c += k[4] + (((uint32_t)k[5])<<16);
122
+ mix(a,b,c);
123
+ length -= 12;
124
+ k += 6;
125
+ }
126
+
127
+ /*----------------------------- handle the last (probably partial) block */
128
+ k8 = (const uint8_t *)k;
129
+ switch(length)
130
+ {
131
+ case 12: c+=k[4]+(((uint32_t)k[5])<<16);
132
+ b+=k[2]+(((uint32_t)k[3])<<16);
133
+ a+=k[0]+(((uint32_t)k[1])<<16);
134
+ break;
135
+ case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
136
+ case 10: c+=k[4];
137
+ b+=k[2]+(((uint32_t)k[3])<<16);
138
+ a+=k[0]+(((uint32_t)k[1])<<16);
139
+ break;
140
+ case 9 : c+=k8[8]; /* fall through */
141
+ case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
142
+ a+=k[0]+(((uint32_t)k[1])<<16);
143
+ break;
144
+ case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
145
+ case 6 : b+=k[2];
146
+ a+=k[0]+(((uint32_t)k[1])<<16);
147
+ break;
148
+ case 5 : b+=k8[4]; /* fall through */
149
+ case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
150
+ break;
151
+ case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
152
+ case 2 : a+=k[0];
153
+ break;
154
+ case 1 : a+=k8[0];
155
+ break;
156
+ case 0 : return c; /* zero length requires no mixing */
157
+ default: return c;
158
+ }
159
+
160
+ }
161
+ else
162
+ { /* need to read the key one byte at a time */
163
+ #endif /* little endian */
164
+ const uint8_t *k = (const uint8_t *)key;
165
+
166
+ /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
167
+ while (length > 12)
168
+ {
169
+ a += k[0];
170
+ a += ((uint32_t)k[1])<<8;
171
+ a += ((uint32_t)k[2])<<16;
172
+ a += ((uint32_t)k[3])<<24;
173
+ b += k[4];
174
+ b += ((uint32_t)k[5])<<8;
175
+ b += ((uint32_t)k[6])<<16;
176
+ b += ((uint32_t)k[7])<<24;
177
+ c += k[8];
178
+ c += ((uint32_t)k[9])<<8;
179
+ c += ((uint32_t)k[10])<<16;
180
+ c += ((uint32_t)k[11])<<24;
181
+ mix(a,b,c);
182
+ length -= 12;
183
+ k += 12;
184
+ }
185
+
186
+ /*-------------------------------- last block: affect all 32 bits of (c) */
187
+ switch(length) /* all the case statements fall through */
188
+ {
189
+ case 12: c+=((uint32_t)k[11])<<24;
190
+ case 11: c+=((uint32_t)k[10])<<16;
191
+ case 10: c+=((uint32_t)k[9])<<8;
192
+ case 9 : c+=k[8];
193
+ case 8 : b+=((uint32_t)k[7])<<24;
194
+ case 7 : b+=((uint32_t)k[6])<<16;
195
+ case 6 : b+=((uint32_t)k[5])<<8;
196
+ case 5 : b+=k[4];
197
+ case 4 : a+=((uint32_t)k[3])<<24;
198
+ case 3 : a+=((uint32_t)k[2])<<16;
199
+ case 2 : a+=((uint32_t)k[1])<<8;
200
+ case 1 : a+=k[0];
201
+ break;
202
+ case 0 : return c;
203
+ default : return c;
204
+ }
205
+ #ifdef BYTEORDER_LITTLE_ENDIAN
206
+ }
207
+ #endif
208
+
209
+ final(a,b,c);
210
+ return c;
211
+ }
212
+
213
+