memcached 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +206 -12
- data/Rakefile +32 -1
- data/ext/extconf.rb +10 -35
- 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 +828 -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 +1852 -0
- data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
- data/ext/libmemcached-0.32/clients/Makefile.in +770 -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.h.in +252 -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 +8406 -0
- data/ext/libmemcached-0.32/config/missing +376 -0
- data/ext/libmemcached-0.32/configure +23048 -0
- data/ext/libmemcached-0.32/configure.ac +122 -0
- data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
- data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
- data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
- data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
- data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
- data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
- data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
- data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
- data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
- data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
- data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
- data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
- data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
- data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
- data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
- data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
- data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
- data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
- data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
- data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
- data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
- data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
- data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
- data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
- data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
- data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
- data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
- data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
- data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
- data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
- data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
- data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
- data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
- data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
- data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
- data/ext/libmemcached-0.32/libmemcached/common.h +183 -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 +28 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
- data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -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 +285 -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 +361 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -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 +22 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -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 +547 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -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 +528 -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 +454 -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_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 +602 -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 +7360 -0
- data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -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 +92 -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 +485 -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 +105 -0
- data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
- data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
- data/ext/libmemcached-0.32/tests/function.c +4781 -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/memcached.gemspec +4 -4
- data/test/unit/memcached_test.rb +30 -0
- metadata +213 -16
- data/ext/libmemcached-0.32.tar.gz +0 -0
- data/ext/libmemcached-1.patch +0 -270
- data/ext/libmemcached-10.patch +0 -12
- data/ext/libmemcached-2.patch +0 -116
- data/ext/libmemcached-3.patch +0 -8
- data/ext/libmemcached-4.patch +0 -40
- data/ext/libmemcached-5.patch +0 -832
- data/ext/libmemcached-6.patch +0 -20
- data/ext/libmemcached-7.patch +0 -2989
- data/ext/libmemcached-8.patch +0 -137
- data/ext/libmemcached-9.patch +0 -13
- data/ext/sasl.patch +0 -29283
@@ -0,0 +1,22 @@
|
|
1
|
+
#include "common.h"
|
2
|
+
#include "memcached_io.h"
|
3
|
+
|
4
|
+
memcached_return memcached_flush_buffers(memcached_st *mem)
|
5
|
+
{
|
6
|
+
memcached_return ret= MEMCACHED_SUCCESS;
|
7
|
+
|
8
|
+
for (uint32_t x= 0; x < mem->number_of_hosts; ++x)
|
9
|
+
if (mem->hosts[x].write_buffer_offset != 0)
|
10
|
+
{
|
11
|
+
if (mem->hosts[x].fd == -1 &&
|
12
|
+
(ret= memcached_connect(&mem->hosts[x])) != MEMCACHED_SUCCESS)
|
13
|
+
{
|
14
|
+
WATCHPOINT_ERROR(ret);
|
15
|
+
return ret;
|
16
|
+
}
|
17
|
+
if (memcached_io_write(&mem->hosts[x], NULL, 0, 1) == -1)
|
18
|
+
ret= MEMCACHED_SOME_ERRORS;
|
19
|
+
}
|
20
|
+
|
21
|
+
return ret;
|
22
|
+
}
|
@@ -0,0 +1,495 @@
|
|
1
|
+
#include "common.h"
|
2
|
+
#include "memcached_io.h"
|
3
|
+
|
4
|
+
/*
|
5
|
+
What happens if no servers exist?
|
6
|
+
*/
|
7
|
+
char *memcached_get(memcached_st *ptr, const char *key,
|
8
|
+
size_t key_length,
|
9
|
+
size_t *value_length,
|
10
|
+
uint32_t *flags,
|
11
|
+
memcached_return *error)
|
12
|
+
{
|
13
|
+
return memcached_get_by_key(ptr, NULL, 0, key, key_length,
|
14
|
+
GET_LEN_ARG_UNSPECIFIED, value_length,
|
15
|
+
flags, error);
|
16
|
+
}
|
17
|
+
|
18
|
+
char *memcached_get_len(memcached_st *ptr,
|
19
|
+
const char *key, size_t key_length,
|
20
|
+
uint32_t user_spec_len,
|
21
|
+
size_t *value_length,
|
22
|
+
uint32_t *flags,
|
23
|
+
memcached_return *error)
|
24
|
+
{
|
25
|
+
return memcached_get_by_key(ptr, NULL, 0, key, key_length,
|
26
|
+
user_spec_len, value_length,
|
27
|
+
flags, error);
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
char *memcached_get_by_key(memcached_st *ptr,
|
32
|
+
const char *master_key,
|
33
|
+
size_t master_key_length,
|
34
|
+
const char *key, size_t key_length,
|
35
|
+
uint32_t user_spec_len,
|
36
|
+
size_t *value_length,
|
37
|
+
uint32_t *flags,
|
38
|
+
memcached_return *error)
|
39
|
+
{
|
40
|
+
char *value;
|
41
|
+
size_t dummy_length;
|
42
|
+
uint32_t dummy_flags;
|
43
|
+
memcached_return dummy_error;
|
44
|
+
|
45
|
+
unlikely (ptr->flags & MEM_USE_UDP)
|
46
|
+
{
|
47
|
+
*error= MEMCACHED_NOT_SUPPORTED;
|
48
|
+
return NULL;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* Request the key */
|
52
|
+
*error= memcached_mget_by_key(ptr,
|
53
|
+
master_key,
|
54
|
+
master_key_length,
|
55
|
+
(const char **)&key, &key_length, 1,
|
56
|
+
user_spec_len);
|
57
|
+
|
58
|
+
value= memcached_fetch(ptr, NULL, NULL,
|
59
|
+
value_length, flags, error);
|
60
|
+
/* This is for historical reasons */
|
61
|
+
if (*error == MEMCACHED_END)
|
62
|
+
*error= MEMCACHED_NOTFOUND;
|
63
|
+
|
64
|
+
if (value == NULL)
|
65
|
+
{
|
66
|
+
if (ptr->get_key_failure && *error == MEMCACHED_NOTFOUND)
|
67
|
+
{
|
68
|
+
memcached_return rc;
|
69
|
+
|
70
|
+
memcached_result_reset(&ptr->result);
|
71
|
+
rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result);
|
72
|
+
|
73
|
+
/* On all failure drop to returning NULL */
|
74
|
+
if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED)
|
75
|
+
{
|
76
|
+
if (rc == MEMCACHED_BUFFERED)
|
77
|
+
{
|
78
|
+
uint64_t latch; /* We use latch to track the state of the original socket */
|
79
|
+
latch= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS);
|
80
|
+
if (latch == 0)
|
81
|
+
memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
|
82
|
+
|
83
|
+
rc= memcached_set(ptr, key, key_length,
|
84
|
+
memcached_result_value(&ptr->result),
|
85
|
+
memcached_result_length(&ptr->result),
|
86
|
+
0, memcached_result_flags(&ptr->result));
|
87
|
+
|
88
|
+
if (rc == MEMCACHED_BUFFERED && latch == 0)
|
89
|
+
memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0);
|
90
|
+
}
|
91
|
+
else
|
92
|
+
{
|
93
|
+
rc= memcached_set(ptr, key, key_length,
|
94
|
+
memcached_result_value(&ptr->result),
|
95
|
+
memcached_result_length(&ptr->result),
|
96
|
+
0, memcached_result_flags(&ptr->result));
|
97
|
+
}
|
98
|
+
|
99
|
+
if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED)
|
100
|
+
{
|
101
|
+
*error= rc;
|
102
|
+
*value_length= memcached_result_length(&ptr->result);
|
103
|
+
*flags= memcached_result_flags(&ptr->result);
|
104
|
+
return memcached_string_c_copy(&ptr->result.value);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
return NULL;
|
110
|
+
}
|
111
|
+
|
112
|
+
(void)memcached_fetch(ptr, NULL, NULL,
|
113
|
+
&dummy_length, &dummy_flags,
|
114
|
+
&dummy_error);
|
115
|
+
WATCHPOINT_ASSERT(dummy_length == 0);
|
116
|
+
|
117
|
+
return value;
|
118
|
+
}
|
119
|
+
|
120
|
+
memcached_return memcached_mget(memcached_st *ptr,
|
121
|
+
const char **keys, size_t *key_length,
|
122
|
+
size_t number_of_keys)
|
123
|
+
{
|
124
|
+
return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys,
|
125
|
+
GET_LEN_ARG_UNSPECIFIED);
|
126
|
+
}
|
127
|
+
|
128
|
+
memcached_return memcached_mget_len(memcached_st *ptr,
|
129
|
+
const char **keys, size_t *key_length,
|
130
|
+
size_t number_of_keys, uint32_t user_spec_len)
|
131
|
+
{
|
132
|
+
return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys,
|
133
|
+
user_spec_len);
|
134
|
+
}
|
135
|
+
|
136
|
+
static memcached_return binary_mget_by_key(memcached_st *ptr,
|
137
|
+
unsigned int master_server_key,
|
138
|
+
bool is_master_key_set,
|
139
|
+
const char **keys, size_t *key_length,
|
140
|
+
size_t number_of_keys);
|
141
|
+
|
142
|
+
static bool user_specified_length_is_valid(uint32_t user_spec_len)
|
143
|
+
{
|
144
|
+
assert_on_compile(GET_LEN_ARG_UNSPECIFIED == -1U);
|
145
|
+
return (user_spec_len > 0 && user_spec_len < GET_LEN_ARG_UNSPECIFIED);
|
146
|
+
}
|
147
|
+
|
148
|
+
memcached_return memcached_mget_by_key(memcached_st *ptr,
|
149
|
+
const char *master_key,
|
150
|
+
size_t master_key_length,
|
151
|
+
const char **keys,
|
152
|
+
size_t *key_length,
|
153
|
+
size_t number_of_keys,
|
154
|
+
uint32_t user_spec_len)
|
155
|
+
{
|
156
|
+
unsigned int x;
|
157
|
+
const char *get_command;
|
158
|
+
uint8_t get_command_length;
|
159
|
+
memcached_return rc= MEMCACHED_NOTFOUND;
|
160
|
+
unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */
|
161
|
+
bool is_master_key_set= false;
|
162
|
+
bool use_cas = (ptr->flags & MEM_SUPPORT_CAS);
|
163
|
+
bool length_specified = (user_spec_len != GET_LEN_ARG_UNSPECIFIED);
|
164
|
+
|
165
|
+
unlikely (ptr->flags & MEM_USE_UDP)
|
166
|
+
return MEMCACHED_NOT_SUPPORTED;
|
167
|
+
|
168
|
+
LIBMEMCACHED_MEMCACHED_MGET_START();
|
169
|
+
ptr->cursor_server= 0;
|
170
|
+
|
171
|
+
if (number_of_keys == 0)
|
172
|
+
return MEMCACHED_NOTFOUND;
|
173
|
+
|
174
|
+
if (ptr->number_of_hosts == 0)
|
175
|
+
return MEMCACHED_NO_SERVERS;
|
176
|
+
|
177
|
+
if ((ptr->flags & MEM_VERIFY_KEY) && (memcached_key_test(keys, key_length, number_of_keys) == MEMCACHED_BAD_KEY_PROVIDED))
|
178
|
+
return MEMCACHED_BAD_KEY_PROVIDED;
|
179
|
+
|
180
|
+
if (master_key && master_key_length)
|
181
|
+
{
|
182
|
+
if ((ptr->flags & MEM_VERIFY_KEY) && (memcached_key_test((const char **)&master_key, &master_key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
|
183
|
+
return MEMCACHED_BAD_KEY_PROVIDED;
|
184
|
+
master_server_key= memcached_generate_hash(ptr, master_key, master_key_length);
|
185
|
+
is_master_key_set= true;
|
186
|
+
}
|
187
|
+
|
188
|
+
if (length_specified) {
|
189
|
+
if (ptr->flags & MEM_BINARY_PROTOCOL)
|
190
|
+
return MEMCACHED_NOT_SUPPORTED;
|
191
|
+
|
192
|
+
if (!user_specified_length_is_valid(user_spec_len))
|
193
|
+
return MEMCACHED_FAILURE;
|
194
|
+
}
|
195
|
+
|
196
|
+
/*
|
197
|
+
Here is where we pay for the non-block API. We need to remove any data sitting
|
198
|
+
in the queue before we start our get.
|
199
|
+
|
200
|
+
It might be optimum to bounce the connection if count > some number.
|
201
|
+
*/
|
202
|
+
for (x= 0; x < ptr->number_of_hosts; x++)
|
203
|
+
{
|
204
|
+
if (memcached_server_response_count(&ptr->hosts[x]))
|
205
|
+
{
|
206
|
+
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
|
207
|
+
|
208
|
+
if (ptr->flags & MEM_NO_BLOCK)
|
209
|
+
(void)memcached_io_write(&ptr->hosts[x], NULL, 0, 1);
|
210
|
+
|
211
|
+
while(memcached_server_response_count(&ptr->hosts[x]))
|
212
|
+
(void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
if (ptr->flags & MEM_BINARY_PROTOCOL)
|
217
|
+
return binary_mget_by_key(ptr, master_server_key, is_master_key_set, keys,
|
218
|
+
key_length, number_of_keys);
|
219
|
+
|
220
|
+
if (length_specified) {
|
221
|
+
if (use_cas)
|
222
|
+
{
|
223
|
+
get_command= "gets_len ";
|
224
|
+
get_command_length= 9;
|
225
|
+
} else {
|
226
|
+
get_command= "get_len ";
|
227
|
+
get_command_length= 8;
|
228
|
+
}
|
229
|
+
} else {
|
230
|
+
if (use_cas)
|
231
|
+
{
|
232
|
+
get_command= "gets ";
|
233
|
+
get_command_length= 5;
|
234
|
+
} else {
|
235
|
+
get_command= "get ";
|
236
|
+
get_command_length= 4;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
/*
|
241
|
+
If a server fails we warn about errors and start all over with sending keys
|
242
|
+
to the server.
|
243
|
+
*/
|
244
|
+
for (x= 0; x < number_of_keys; x++)
|
245
|
+
{
|
246
|
+
unsigned int server_key;
|
247
|
+
|
248
|
+
if (is_master_key_set)
|
249
|
+
server_key= master_server_key;
|
250
|
+
else
|
251
|
+
server_key= memcached_generate_hash(ptr, keys[x], key_length[x]);
|
252
|
+
|
253
|
+
if (memcached_server_response_count(&ptr->hosts[server_key]) == 0)
|
254
|
+
{
|
255
|
+
rc= memcached_connect(&ptr->hosts[server_key]);
|
256
|
+
|
257
|
+
if (rc != MEMCACHED_SUCCESS)
|
258
|
+
continue;
|
259
|
+
|
260
|
+
if ((memcached_io_write(&ptr->hosts[server_key], get_command, get_command_length, 0)) == -1)
|
261
|
+
{
|
262
|
+
rc= MEMCACHED_SOME_ERRORS;
|
263
|
+
continue;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (length_specified) {
|
267
|
+
char len[GET_LEN_BUFSZ];
|
268
|
+
if (snprintf(len, GET_LEN_BUFSZ, "%d ", user_spec_len) < 0 ||
|
269
|
+
(memcached_io_write(&ptr->hosts[server_key], len, strlen(len), 0) == -1))
|
270
|
+
{
|
271
|
+
rc= MEMCACHED_SOME_ERRORS;
|
272
|
+
continue;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
WATCHPOINT_ASSERT(ptr->hosts[server_key].cursor_active == 0);
|
277
|
+
memcached_server_response_increment(&ptr->hosts[server_key]);
|
278
|
+
WATCHPOINT_ASSERT(ptr->hosts[server_key].cursor_active == 1);
|
279
|
+
}
|
280
|
+
|
281
|
+
/* Only called when we have a prefix key */
|
282
|
+
if (ptr->prefix_key[0] != 0)
|
283
|
+
{
|
284
|
+
if ((memcached_io_write(&ptr->hosts[server_key], ptr->prefix_key, ptr->prefix_key_length, 0)) == -1)
|
285
|
+
{
|
286
|
+
memcached_server_response_reset(&ptr->hosts[server_key]);
|
287
|
+
rc= MEMCACHED_SOME_ERRORS;
|
288
|
+
continue;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
if ((memcached_io_write(&ptr->hosts[server_key], keys[x], key_length[x], 0)) == -1)
|
293
|
+
{
|
294
|
+
memcached_server_response_reset(&ptr->hosts[server_key]);
|
295
|
+
rc= MEMCACHED_SOME_ERRORS;
|
296
|
+
continue;
|
297
|
+
}
|
298
|
+
|
299
|
+
if ((memcached_io_write(&ptr->hosts[server_key], " ", 1, 0)) == -1)
|
300
|
+
{
|
301
|
+
memcached_server_response_reset(&ptr->hosts[server_key]);
|
302
|
+
rc= MEMCACHED_SOME_ERRORS;
|
303
|
+
continue;
|
304
|
+
}
|
305
|
+
|
306
|
+
ptr->last_server_key = server_key;
|
307
|
+
}
|
308
|
+
|
309
|
+
/*
|
310
|
+
Should we muddle on if some servers are dead?
|
311
|
+
*/
|
312
|
+
for (x= 0; x < ptr->number_of_hosts; x++)
|
313
|
+
{
|
314
|
+
if (memcached_server_response_count(&ptr->hosts[x]))
|
315
|
+
{
|
316
|
+
/* We need to do something about non-connnected hosts in the future */
|
317
|
+
if ((memcached_io_write(&ptr->hosts[x], "\r\n", 2, 1)) == -1)
|
318
|
+
{
|
319
|
+
rc= MEMCACHED_SOME_ERRORS;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
LIBMEMCACHED_MEMCACHED_MGET_END();
|
325
|
+
return rc;
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
char *memcached_get_from_last(memcached_st *ptr,
|
330
|
+
const char *key,
|
331
|
+
size_t key_length,
|
332
|
+
size_t *value_length,
|
333
|
+
uint32_t *flags,
|
334
|
+
memcached_return *error)
|
335
|
+
{
|
336
|
+
memcached_return rc = MEMCACHED_NOTFOUND;
|
337
|
+
char *value = NULL;
|
338
|
+
|
339
|
+
if (memcached_server_response_count(&ptr->hosts[ptr->last_server_key]) == 0) {
|
340
|
+
*error = memcached_connect(&ptr->hosts[ptr->last_server_key]);
|
341
|
+
|
342
|
+
if (*error != MEMCACHED_SUCCESS) {
|
343
|
+
return value;
|
344
|
+
}
|
345
|
+
|
346
|
+
if ((memcached_io_write(&ptr->hosts[ptr->last_server_key], "get ", 4, 0)) == -1) {
|
347
|
+
*error = MEMCACHED_SOME_ERRORS;
|
348
|
+
return value;
|
349
|
+
}
|
350
|
+
WATCHPOINT_ASSERT(ptr->hosts[ptr->last_server_key].cursor_active == 0);
|
351
|
+
memcached_server_response_increment(&ptr->hosts[ptr->last_server_key]);
|
352
|
+
WATCHPOINT_ASSERT(ptr->hosts[ptr->last_server_key].cursor_active == 1);
|
353
|
+
}
|
354
|
+
|
355
|
+
/* Only called when we have a prefix key */
|
356
|
+
if (ptr->prefix_key[0] != 0) {
|
357
|
+
if ((memcached_io_write(&ptr->hosts[ptr->last_server_key], ptr->prefix_key, ptr->prefix_key_length, 0)) == -1) {
|
358
|
+
memcached_server_response_reset(&ptr->hosts[ptr->last_server_key]);
|
359
|
+
*error = MEMCACHED_SOME_ERRORS;
|
360
|
+
return value;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
if ((memcached_io_write(&ptr->hosts[ptr->last_server_key], key, key_length, 0)) == -1) {
|
365
|
+
memcached_server_response_reset(&ptr->hosts[ptr->last_server_key]);
|
366
|
+
*error = MEMCACHED_SOME_ERRORS;
|
367
|
+
return value;
|
368
|
+
}
|
369
|
+
|
370
|
+
if ((memcached_io_write(&ptr->hosts[ptr->last_server_key], "\r\n", 2, 1)) == -1) {
|
371
|
+
memcached_server_response_reset(&ptr->hosts[ptr->last_server_key]);
|
372
|
+
*error = MEMCACHED_SOME_ERRORS;
|
373
|
+
return value;
|
374
|
+
}
|
375
|
+
|
376
|
+
value = memcached_fetch(ptr, NULL, NULL, value_length, flags, error);
|
377
|
+
|
378
|
+
/* This is for historical reasons */
|
379
|
+
if (*error == MEMCACHED_END)
|
380
|
+
*error = MEMCACHED_NOTFOUND;
|
381
|
+
|
382
|
+
if (value != NULL) {
|
383
|
+
size_t dummy_length;
|
384
|
+
uint32_t dummy_flags;
|
385
|
+
memcached_return dummy_error;
|
386
|
+
|
387
|
+
(void)memcached_fetch(ptr, NULL, NULL,
|
388
|
+
&dummy_length, &dummy_flags,
|
389
|
+
&dummy_error);
|
390
|
+
WATCHPOINT_ASSERT(dummy_length == 0);
|
391
|
+
}
|
392
|
+
|
393
|
+
return value;
|
394
|
+
}
|
395
|
+
|
396
|
+
static memcached_return binary_mget_by_key(memcached_st *ptr,
|
397
|
+
unsigned int master_server_key,
|
398
|
+
bool is_master_key_set,
|
399
|
+
const char **keys, size_t *key_length,
|
400
|
+
size_t number_of_keys)
|
401
|
+
{
|
402
|
+
memcached_return rc= MEMCACHED_NOTFOUND;
|
403
|
+
uint32_t x;
|
404
|
+
|
405
|
+
int flush= number_of_keys == 1;
|
406
|
+
|
407
|
+
/*
|
408
|
+
If a server fails we warn about errors and start all over with sending keys
|
409
|
+
to the server.
|
410
|
+
*/
|
411
|
+
for (x= 0; x < number_of_keys; x++)
|
412
|
+
{
|
413
|
+
unsigned int server_key;
|
414
|
+
|
415
|
+
if (is_master_key_set)
|
416
|
+
server_key= master_server_key;
|
417
|
+
else
|
418
|
+
server_key= memcached_generate_hash(ptr, keys[x], key_length[x]);
|
419
|
+
|
420
|
+
if (memcached_server_response_count(&ptr->hosts[server_key]) == 0)
|
421
|
+
{
|
422
|
+
rc= memcached_connect(&ptr->hosts[server_key]);
|
423
|
+
if (rc != MEMCACHED_SUCCESS)
|
424
|
+
continue;
|
425
|
+
}
|
426
|
+
|
427
|
+
protocol_binary_request_getk request= {.bytes= {0}};
|
428
|
+
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
429
|
+
if (number_of_keys == 1)
|
430
|
+
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
|
431
|
+
else
|
432
|
+
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;
|
433
|
+
|
434
|
+
memcached_return vk;
|
435
|
+
vk= memcached_validate_key_length(ptr->prefix_key_length + key_length[x],
|
436
|
+
ptr->flags & MEM_BINARY_PROTOCOL);
|
437
|
+
unlikely (vk != MEMCACHED_SUCCESS)
|
438
|
+
{
|
439
|
+
if (x > 0)
|
440
|
+
memcached_io_reset(&ptr->hosts[server_key]);
|
441
|
+
return vk;
|
442
|
+
}
|
443
|
+
|
444
|
+
request.message.header.request.keylen= htons((uint16_t)(ptr->prefix_key_length + key_length[x]));
|
445
|
+
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
446
|
+
request.message.header.request.bodylen= htonl((uint32_t) (ptr->prefix_key_length + key_length[x]));
|
447
|
+
|
448
|
+
if ((memcached_io_write(&ptr->hosts[server_key], request.bytes,
|
449
|
+
sizeof(request.bytes), 0) == -1) ||
|
450
|
+
(memcached_io_write(&ptr->hosts[server_key], ptr->prefix_key,
|
451
|
+
ptr->prefix_key_length, 0) == -1) ||
|
452
|
+
(memcached_io_write(&ptr->hosts[server_key], keys[x],
|
453
|
+
key_length[x], (char) flush) == -1))
|
454
|
+
{
|
455
|
+
memcached_server_response_reset(&ptr->hosts[server_key]);
|
456
|
+
rc= MEMCACHED_SOME_ERRORS;
|
457
|
+
continue;
|
458
|
+
}
|
459
|
+
memcached_server_response_increment(&ptr->hosts[server_key]);
|
460
|
+
if ((x > 0 && x == ptr->io_key_prefetch) &&
|
461
|
+
memcached_flush_buffers(ptr) != MEMCACHED_SUCCESS)
|
462
|
+
rc= MEMCACHED_SOME_ERRORS;
|
463
|
+
}
|
464
|
+
|
465
|
+
/*
|
466
|
+
* Send a noop command to flush the buffers
|
467
|
+
*/
|
468
|
+
protocol_binary_request_noop request= {.bytes= {0}};
|
469
|
+
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
470
|
+
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
|
471
|
+
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
472
|
+
|
473
|
+
for (x= 0; x < ptr->number_of_hosts; x++) {
|
474
|
+
if (memcached_server_response_count(&ptr->hosts[x]))
|
475
|
+
{
|
476
|
+
if (memcached_io_write(&ptr->hosts[x], NULL, 0, 1) == -1)
|
477
|
+
{
|
478
|
+
memcached_server_response_reset(&ptr->hosts[x]);
|
479
|
+
memcached_io_reset(&ptr->hosts[x]);
|
480
|
+
rc= MEMCACHED_SOME_ERRORS;
|
481
|
+
}
|
482
|
+
|
483
|
+
if (memcached_io_write(&ptr->hosts[x], request.bytes,
|
484
|
+
sizeof(request.bytes), 1) == -1)
|
485
|
+
{
|
486
|
+
memcached_server_response_reset(&ptr->hosts[x]);
|
487
|
+
memcached_io_reset(&ptr->hosts[x]);
|
488
|
+
rc= MEMCACHED_SOME_ERRORS;
|
489
|
+
}
|
490
|
+
memcached_server_response_increment(&ptr->hosts[x]);
|
491
|
+
}
|
492
|
+
}
|
493
|
+
|
494
|
+
return rc;
|
495
|
+
}
|