vinted-memcached 1.8.0
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.
- checksums.yaml +7 -0
- data/BENCHMARKS +142 -0
- data/CHANGELOG +176 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +45 -0
- data/LICENSE +184 -0
- data/Manifest +209 -0
- data/README.rdoc +124 -0
- data/Rakefile +134 -0
- data/TODO +1 -0
- data/ext/extconf-make.rb +25 -0
- data/ext/extconf.rb +78 -0
- data/ext/libmemcached-0.32/AUTHORS +7 -0
- data/ext/libmemcached-0.32/COPYING +32 -0
- data/ext/libmemcached-0.32/ChangeLog +303 -0
- data/ext/libmemcached-0.32/INSTALL +302 -0
- data/ext/libmemcached-0.32/Makefile.am +36 -0
- data/ext/libmemcached-0.32/Makefile.in +911 -0
- data/ext/libmemcached-0.32/NEWS +1 -0
- data/ext/libmemcached-0.32/README +33 -0
- data/ext/libmemcached-0.32/THANKS +14 -0
- data/ext/libmemcached-0.32/TODO +11 -0
- data/ext/libmemcached-0.32/aclocal.m4 +2108 -0
- data/ext/libmemcached-0.32/clients/Makefile.am +80 -0
- data/ext/libmemcached-0.32/clients/Makefile.in +773 -0
- data/ext/libmemcached-0.32/clients/client_options.h +32 -0
- data/ext/libmemcached-0.32/clients/execute.c +64 -0
- data/ext/libmemcached-0.32/clients/execute.h +5 -0
- data/ext/libmemcached-0.32/clients/generator.c +74 -0
- data/ext/libmemcached-0.32/clients/generator.h +20 -0
- data/ext/libmemcached-0.32/clients/memcat.c +178 -0
- data/ext/libmemcached-0.32/clients/memcp.c +251 -0
- data/ext/libmemcached-0.32/clients/memdump.c +170 -0
- data/ext/libmemcached-0.32/clients/memerror.c +80 -0
- data/ext/libmemcached-0.32/clients/memflush.c +143 -0
- data/ext/libmemcached-0.32/clients/memrm.c +160 -0
- data/ext/libmemcached-0.32/clients/memslap.c +441 -0
- data/ext/libmemcached-0.32/clients/memstat.c +326 -0
- data/ext/libmemcached-0.32/clients/utilities.c +207 -0
- data/ext/libmemcached-0.32/clients/utilities.h +41 -0
- data/ext/libmemcached-0.32/config/compile +143 -0
- data/ext/libmemcached-0.32/config/config.guess +1561 -0
- data/ext/libmemcached-0.32/config/config.rpath +666 -0
- data/ext/libmemcached-0.32/config/config.sub +1686 -0
- data/ext/libmemcached-0.32/config/depcomp +630 -0
- data/ext/libmemcached-0.32/config/install-sh +520 -0
- data/ext/libmemcached-0.32/config/ltmain.sh +9636 -0
- data/ext/libmemcached-0.32/config/missing +376 -0
- data/ext/libmemcached-0.32/config.h.in +254 -0
- data/ext/libmemcached-0.32/configure +23843 -0
- data/ext/libmemcached-0.32/configure.ac +120 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +111 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +1069 -0
- data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
- data/ext/libmemcached-0.32/libmemcached/common.h +189 -0
- data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
- data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
- data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +30 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +82 -0
- data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +385 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.c +153 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.h +305 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +290 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +371 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +146 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.c +114 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.h +20 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.c +494 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.c +594 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_response.c +529 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +437 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_touch.c +60 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_touch.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +604 -0
- data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
- data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
- data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
- data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
- data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
- data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
- data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
- data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
- data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
- data/ext/libmemcached-0.32/m4/libtool.m4 +7831 -0
- data/ext/libmemcached-0.32/m4/ltoptions.m4 +369 -0
- data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
- data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
- data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +98 -0
- data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
- data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
- data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
- data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
- data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
- data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
- data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
- data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
- data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
- data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
- data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
- data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
- data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
- data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
- data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
- data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
- data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
- data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
- data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
- data/ext/libmemcached-0.32/support/Makefile.am +4 -0
- data/ext/libmemcached-0.32/support/Makefile.in +487 -0
- data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
- data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
- data/ext/libmemcached-0.32/tests/Makefile.am +113 -0
- data/ext/libmemcached-0.32/tests/Makefile.in +762 -0
- data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
- data/ext/libmemcached-0.32/tests/function.c +4904 -0
- data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
- data/ext/libmemcached-0.32/tests/output.cmp +7 -0
- data/ext/libmemcached-0.32/tests/output.res +7 -0
- data/ext/libmemcached-0.32/tests/output2.res +46 -0
- data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
- data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
- data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
- data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
- data/ext/libmemcached-0.32/tests/server.c +118 -0
- data/ext/libmemcached-0.32/tests/server.h +25 -0
- data/ext/libmemcached-0.32/tests/start.c +16 -0
- data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
- data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
- data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
- data/ext/libmemcached-0.32/tests/test.c +137 -0
- data/ext/libmemcached-0.32/tests/test.h +46 -0
- data/ext/libmemcached-0.32/tests/udp.c +76 -0
- data/ext/rlibmemcached.i +258 -0
- data/ext/rlibmemcached_wrap.c +13917 -0
- data/lib/memcached/auth.rb +16 -0
- data/lib/memcached/behaviors.rb +78 -0
- data/lib/memcached/exceptions.rb +84 -0
- data/lib/memcached/experimental.rb +48 -0
- data/lib/memcached/marshal_codec.rb +10 -0
- data/lib/memcached/memcached.rb +732 -0
- data/lib/memcached/rails.rb +250 -0
- data/lib/memcached.rb +33 -0
- data/memcached.gemspec +0 -0
- data/test/profile/benchmark.rb +280 -0
- data/test/profile/c_profiler.rb +14 -0
- data/test/profile/exercise.rb +185 -0
- data/test/profile/rb_profiler.rb +21 -0
- data/test/profile/valgrind.rb +10 -0
- data/test/setup.rb +30 -0
- data/test/teardown.rb +0 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/binding_test.rb +8 -0
- data/test/unit/memcached_experimental_test.rb +272 -0
- data/test/unit/memcached_test.rb +1487 -0
- data/test/unit/rails_test.rb +330 -0
- metadata +336 -0
|
@@ -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,189 @@
|
|
|
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
|
+
|
|
140
|
+
LIBMEMCACHED_LOCAL
|
|
141
|
+
memcached_return memcached_vdo(memcached_server_st *ptr,
|
|
142
|
+
const struct libmemcached_io_vector_st *vector, size_t count,
|
|
143
|
+
uint8_t with_flush);
|
|
144
|
+
|
|
145
|
+
LIBMEMCACHED_LOCAL
|
|
146
|
+
memcached_return value_fetch(memcached_server_st *ptr,
|
|
147
|
+
char *buffer,
|
|
148
|
+
memcached_result_st *result);
|
|
149
|
+
LIBMEMCACHED_LOCAL
|
|
150
|
+
void server_list_free(memcached_st *ptr, memcached_server_st *servers);
|
|
151
|
+
|
|
152
|
+
LIBMEMCACHED_LOCAL
|
|
153
|
+
memcached_return memcached_key_test(const char **keys, size_t *key_length,
|
|
154
|
+
size_t number_of_keys);
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
LIBMEMCACHED_LOCAL
|
|
158
|
+
uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length);
|
|
159
|
+
|
|
160
|
+
#ifndef HAVE_HTONLL
|
|
161
|
+
LIBMEMCACHED_LOCAL
|
|
162
|
+
extern uint64_t ntohll(uint64_t);
|
|
163
|
+
LIBMEMCACHED_LOCAL
|
|
164
|
+
extern uint64_t htonll(uint64_t);
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
LIBMEMCACHED_LOCAL
|
|
168
|
+
memcached_return memcached_purge(memcached_server_st *ptr);
|
|
169
|
+
|
|
170
|
+
static inline memcached_return memcached_validate_key_length(size_t key_length,
|
|
171
|
+
bool binary) {
|
|
172
|
+
unlikely (key_length == 0)
|
|
173
|
+
return MEMCACHED_BAD_KEY_PROVIDED;
|
|
174
|
+
|
|
175
|
+
if (binary)
|
|
176
|
+
{
|
|
177
|
+
unlikely (key_length > 0xffff)
|
|
178
|
+
return MEMCACHED_BAD_KEY_PROVIDED;
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
{
|
|
182
|
+
unlikely (key_length >= MEMCACHED_MAX_KEY)
|
|
183
|
+
return MEMCACHED_BAD_KEY_PROVIDED;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return MEMCACHED_SUCCESS;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#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
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
libmemcached_2 { global: *; };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
provider libmemcached {
|
|
2
|
+
probe memcached_delete_start();
|
|
3
|
+
probe memcached_delete_end();
|
|
4
|
+
probe memcached_increment_with_initial_start();
|
|
5
|
+
probe memcached_increment_with_initial_end();
|
|
6
|
+
probe memcached_decrement_with_initial_start();
|
|
7
|
+
probe memcached_decrement_with_initial_end();
|
|
8
|
+
probe memcached_increment_start();
|
|
9
|
+
probe memcached_increment_end();
|
|
10
|
+
probe memcached_decrement_start();
|
|
11
|
+
probe memcached_decrement_end();
|
|
12
|
+
probe memcached_flush_start();
|
|
13
|
+
probe memcached_flush_end();
|
|
14
|
+
probe memcached_set_start();
|
|
15
|
+
probe memcached_set_end();
|
|
16
|
+
probe memcached_add_start();
|
|
17
|
+
probe memcached_add_end();
|
|
18
|
+
probe memcached_replace_start();
|
|
19
|
+
probe memcached_replace_end();
|
|
20
|
+
probe memcached_get_start();
|
|
21
|
+
probe memcached_get_end();
|
|
22
|
+
probe memcached_touch_start();
|
|
23
|
+
probe memcached_touch_end();
|
|
24
|
+
probe memcached_mget_start();
|
|
25
|
+
probe memcached_mget_end();
|
|
26
|
+
probe memcached_connect_start();
|
|
27
|
+
probe memcached_connect_end();
|
|
28
|
+
probe memcached_server_add_start();
|
|
29
|
+
probe memcached_server_add_end();
|
|
30
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file contains the definition of the various probes supported by
|
|
3
|
+
* libmemcached. Currently it only support DTRACE, but just create an
|
|
4
|
+
* implementation of the following macros to create your own sort of
|
|
5
|
+
* probing :)
|
|
6
|
+
*/
|
|
7
|
+
#ifndef LIBMEMCACHED_PROBES_H
|
|
8
|
+
#define LIBMEMCACHED_PROBES_H
|
|
9
|
+
|
|
10
|
+
#ifdef HAVE_DTRACE
|
|
11
|
+
/*
|
|
12
|
+
* Create the DTrace probes on the system using it (to support both Solaris
|
|
13
|
+
* and MacOS X
|
|
14
|
+
*/
|
|
15
|
+
#include "dtrace_probes.h"
|
|
16
|
+
|
|
17
|
+
#else
|
|
18
|
+
/*
|
|
19
|
+
* Provide dummy macros so that we don't need to clutter the code with
|
|
20
|
+
* ifdefs when we want to use the probes.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#define LIBMEMCACHED_MEMCACHED_ADD_END()
|
|
24
|
+
#define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() (0)
|
|
25
|
+
#define LIBMEMCACHED_MEMCACHED_ADD_START()
|
|
26
|
+
#define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() (0)
|
|
27
|
+
#define LIBMEMCACHED_MEMCACHED_CONNECT_END()
|
|
28
|
+
#define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() (0)
|
|
29
|
+
#define LIBMEMCACHED_MEMCACHED_CONNECT_START()
|
|
30
|
+
#define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() (0)
|
|
31
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_END()
|
|
32
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() (0)
|
|
33
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_START()
|
|
34
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() (0)
|
|
35
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END()
|
|
36
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END_ENABLED() (0)
|
|
37
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START()
|
|
38
|
+
#define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START_ENABLED() (0)
|
|
39
|
+
#define LIBMEMCACHED_MEMCACHED_DELETE_END()
|
|
40
|
+
#define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() (0)
|
|
41
|
+
#define LIBMEMCACHED_MEMCACHED_DELETE_START()
|
|
42
|
+
#define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() (0)
|
|
43
|
+
#define LIBMEMCACHED_MEMCACHED_FLUSH_END()
|
|
44
|
+
#define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() (0)
|
|
45
|
+
#define LIBMEMCACHED_MEMCACHED_FLUSH_START()
|
|
46
|
+
#define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() (0)
|
|
47
|
+
#define LIBMEMCACHED_MEMCACHED_GET_END()
|
|
48
|
+
#define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() (0)
|
|
49
|
+
#define LIBMEMCACHED_MEMCACHED_GET_START()
|
|
50
|
+
#define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() (0)
|
|
51
|
+
#define LIBMEMCACHED_MEMCACHED_TOUCH_END()
|
|
52
|
+
#define LIBMEMCACHED_MEMCACHED_TOUCH_END_ENABLED() (0)
|
|
53
|
+
#define LIBMEMCACHED_MEMCACHED_TOUCH_START()
|
|
54
|
+
#define LIBMEMCACHED_MEMCACHED_TOUCH_START_ENABLED() (0)
|
|
55
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_END()
|
|
56
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() (0)
|
|
57
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_START()
|
|
58
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() (0)
|
|
59
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END()
|
|
60
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END_ENABLED() (0)
|
|
61
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START()
|
|
62
|
+
#define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START_ENABLED() (0)
|
|
63
|
+
#define LIBMEMCACHED_MEMCACHED_MGET_END()
|
|
64
|
+
#define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() (0)
|
|
65
|
+
#define LIBMEMCACHED_MEMCACHED_MGET_START()
|
|
66
|
+
#define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() (0)
|
|
67
|
+
#define LIBMEMCACHED_MEMCACHED_REPLACE_END()
|
|
68
|
+
#define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() (0)
|
|
69
|
+
#define LIBMEMCACHED_MEMCACHED_REPLACE_START()
|
|
70
|
+
#define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() (0)
|
|
71
|
+
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END()
|
|
72
|
+
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() (0)
|
|
73
|
+
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START()
|
|
74
|
+
#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() (0)
|
|
75
|
+
#define LIBMEMCACHED_MEMCACHED_SET_END()
|
|
76
|
+
#define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() (0)
|
|
77
|
+
#define LIBMEMCACHED_MEMCACHED_SET_START()
|
|
78
|
+
#define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() (0)
|
|
79
|
+
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
#endif /* LIBMEMCACHED_PROBES_H */
|