summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clients/include.am3
-rw-r--r--clients/memcat.cc5
-rw-r--r--clients/memcp.cc2
-rw-r--r--clients/memdump.cc2
-rw-r--r--clients/memexist.cc2
-rw-r--r--clients/memflush.cc2
-rw-r--r--clients/memping.cc3
-rw-r--r--clients/memrm.cc2
-rw-r--r--clients/memstat.cc2
-rw-r--r--clients/memtouch.cc2
-rw-r--r--clients/utilities.cc10
-rw-r--r--libhashkit/digest.cc3
-rw-r--r--libmemcached-1.2/feature.h53
-rw-r--r--libmemcached-1.2/include.am1
-rw-r--r--libmemcached-1.2/memcached.h2
-rw-r--r--libmemcached/connect.cc2
-rw-r--r--libmemcached/csl/parser.yy5
-rw-r--r--libmemcached/csl/scanner.l4
-rw-r--r--libmemcached/feature.cc51
-rw-r--r--libmemcached/feature.h37
-rw-r--r--libmemcached/flag.cc4
-rw-r--r--libmemcached/hosts.cc6
-rw-r--r--libmemcached/include.am2
-rw-r--r--libmemcached/response.cc1
-rw-r--r--libmemcached/sasl.cc294
-rw-r--r--libmemcachedutil/pid.cc2
-rw-r--r--libmemcachedutil/ping.cc2
-rw-r--r--m4/ax_harden_compiler_flags.m42
28 files changed, 343 insertions, 163 deletions
diff --git a/clients/include.am b/clients/include.am
index bd38ef04..d941d7e9 100644
--- a/clients/include.am
+++ b/clients/include.am
@@ -42,7 +42,8 @@ noinst_HEADERS+= clients/ms_thread.h
noinst_HEADERS+= clients/utilities.h
noinst_LTLIBRARIES+= clients/libutilities.la
-clients_libutilities_la_SOURCES= clients/utilities.cc
+clients_libutilities_la_SOURCES=
+clients_libutilities_la_SOURCES+= clients/utilities.cc
clients_memcat_SOURCES= clients/memcat.cc
clients_memcat_LDADD= $(CLIENTS_LDADDS)
diff --git a/clients/memcat.cc b/clients/memcat.cc
index faf7310f..206eb3f5 100644
--- a/clients/memcat.cc
+++ b/clients/memcat.cc
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t)opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
@@ -186,6 +186,8 @@ int main(int argc, char *argv[])
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunreachable-code"
void options_parse(int argc, char *argv[])
{
int option_index= 0;
@@ -263,3 +265,4 @@ void options_parse(int argc, char *argv[])
}
}
}
+#pragma GCC diagnostic pop
diff --git a/clients/memcp.cc b/clients/memcp.cc
index ca245163..1b97ef4a 100644
--- a/clients/memcp.cc
+++ b/clients/memcp.cc
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memdump.cc b/clients/memdump.cc
index 38b7f020..d2bbac76 100644
--- a/clients/memdump.cc
+++ b/clients/memdump.cc
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t)opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memexist.cc b/clients/memexist.cc
index 89f2a8e9..e8db984c 100644
--- a/clients/memexist.cc
+++ b/clients/memexist.cc
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t) opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memflush.cc b/clients/memflush.cc
index 5b270175..eb8779ef 100644
--- a/clients/memflush.cc
+++ b/clients/memflush.cc
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t) opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memping.cc b/clients/memping.cc
index 81525417..b79e4d92 100644
--- a/clients/memping.cc
+++ b/clients/memping.cc
@@ -95,6 +95,8 @@ int main(int argc, char *argv[])
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunreachable-code"
void options_parse(int argc, char *argv[])
{
memcached_programs_help_st help_options[]=
@@ -198,3 +200,4 @@ void options_parse(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
}
+#pragma GCC diagnostic pop
diff --git a/clients/memrm.cc b/clients/memrm.cc
index 1f52c4b4..093db336 100644
--- a/clients/memrm.cc
+++ b/clients/memrm.cc
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t) opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memstat.cc b/clients/memstat.cc
index 93ec080c..3fb367be 100644
--- a/clients/memstat.cc
+++ b/clients/memstat.cc
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
memcached_return_t rc= memcached_server_push(memc, servers);
memcached_server_list_free(servers);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/memtouch.cc b/clients/memtouch.cc
index bb6da42f..4b1ebcdc 100644
--- a/clients/memtouch.cc
+++ b/clients/memtouch.cc
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t)opt_binary);
- if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (opt_username and libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
memcached_free(memc);
std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl;
diff --git a/clients/utilities.cc b/clients/utilities.cc
index 268b7904..c5fabd21 100644
--- a/clients/utilities.cc
+++ b/clients/utilities.cc
@@ -73,6 +73,8 @@ void close_stdio(void)
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunreachable-code"
static const char *lookup_help(memcached_options option)
{
switch (option)
@@ -106,12 +108,12 @@ static const char *lookup_help(memcached_options option)
case OPT_STAT_ARGS: return "Argument for statistics";
case OPT_SERVER_VERSION: return "Memcached daemon software version";
default:
- break;
+ break;
};
- assert(0);
- return "forgot to document this function :)";
+ return "Programmer error, function for options not implemented";
}
+#pragma GCC diagnostic pop
void help_command(const char *command_name, const char *description,
const struct option *long_options,
@@ -131,7 +133,9 @@ void help_command(const char *command_name, const char *description,
printf("\t --%s%c\n", long_options[x].name,
long_options[x].has_arg ? '=' : ' ');
if ((help_message= lookup_help(memcached_options(long_options[x].val))))
+ {
printf("\t\t%s\n", help_message);
+ }
}
printf("\n");
diff --git a/libhashkit/digest.cc b/libhashkit/digest.cc
index 23002934..4bfdee71 100644
--- a/libhashkit/digest.cc
+++ b/libhashkit/digest.cc
@@ -42,6 +42,8 @@ uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_leng
return self->base_hash.function(key, key_length, self->base_hash.context);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunreachable-code"
uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algorithm_t hash_algorithm)
{
switch (hash_algorithm)
@@ -91,3 +93,4 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo
return 1;
}
+#pragma GCC diagnostic push
diff --git a/libmemcached-1.2/feature.h b/libmemcached-1.2/feature.h
new file mode 100644
index 00000000..731a2963
--- /dev/null
+++ b/libmemcached-1.2/feature.h
@@ -0,0 +1,53 @@
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2013 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+enum libmemcached_feature_t {
+ LIBMEMCACHED_FEATURE_HAS_SASL,
+ LIBMEMCACHED_FEATURE_MAX
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_API
+bool libmemcached_has_feature(enum libmemcached_feature_t arg);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/libmemcached-1.2/include.am b/libmemcached-1.2/include.am
index 9e597d0a..11a8f0fb 100644
--- a/libmemcached-1.2/include.am
+++ b/libmemcached-1.2/include.am
@@ -27,6 +27,7 @@ nobase_include_HEADERS+= libmemcached-1.2/encoding_key.h
nobase_include_HEADERS+= libmemcached-1.2/error.h
nobase_include_HEADERS+= libmemcached-1.2/exception.hpp
nobase_include_HEADERS+= libmemcached-1.2/exist.h
+nobase_include_HEADERS+= libmemcached-1.2/feature.h
nobase_include_HEADERS+= libmemcached-1.2/fetch.h
nobase_include_HEADERS+= libmemcached-1.2/flush.h
nobase_include_HEADERS+= libmemcached-1.2/flush_buffers.h
diff --git a/libmemcached-1.2/memcached.h b/libmemcached-1.2/memcached.h
index 2a2b54a7..8afd8948 100644
--- a/libmemcached-1.2/memcached.h
+++ b/libmemcached-1.2/memcached.h
@@ -59,6 +59,8 @@
#include <libmemcached-1.2/configure.h>
#include <libmemcached-1.2/platform.h>
+#include <libmemcached-1.2/feature.h>
+
#include <libmemcached-1.2/limits.h>
#include <libmemcached-1.2/defaults.h>
diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc
index b19ba716..df052adb 100644
--- a/libmemcached/connect.cc
+++ b/libmemcached/connect.cc
@@ -407,6 +407,7 @@ static bool set_socket_options(memcached_instance_st* server)
assert(error == 0);
}
+#if defined(TCP_KEEPIDLE) && TCP_KEEPIDLE
if (TCP_KEEPIDLE)
{
if (server->root->tcp_keepidle > 0)
@@ -417,6 +418,7 @@ static bool set_socket_options(memcached_instance_st* server)
assert(error == 0);
}
}
+#endif
if (server->root->send_size > 0)
{
diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy
index dd9c720b..ac9a860b 100644
--- a/libmemcached/csl/parser.yy
+++ b/libmemcached/csl/parser.yy
@@ -65,8 +65,13 @@ class Context;
#include <libmemcached/csl/symbol.h>
#include <libmemcached/csl/scanner.h>
+#ifdef __clang__
+# pragma GCC diagnostic ignored "-Wunreachable-code"
+#endif
+
#ifndef __INTEL_COMPILER
# pragma GCC diagnostic ignored "-Wold-style-cast"
+# pragma GCC diagnostic ignored "-Wunreachable-code"
#endif
#ifndef __INTEL_COMPILER
diff --git a/libmemcached/csl/scanner.l b/libmemcached/csl/scanner.l
index bb233d6f..bc6876a8 100644
--- a/libmemcached/csl/scanner.l
+++ b/libmemcached/csl/scanner.l
@@ -42,6 +42,10 @@
#include <libmemcached/csl/parser.h>
#include <libmemcached/csl/symbol.h>
+#ifdef __clang__
+# pragma GCC diagnostic ignored "-Wunreachable-code"
+#endif
+
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wsign-compare"
diff --git a/libmemcached/feature.cc b/libmemcached/feature.cc
new file mode 100644
index 00000000..50721aec
--- /dev/null
+++ b/libmemcached/feature.cc
@@ -0,0 +1,51 @@
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2013 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <libmemcached/common.h>
+
+bool libmemcached_has_feature(enum libmemcached_feature_t arg)
+{
+ switch (arg)
+ {
+ case LIBMEMCACHED_FEATURE_HAS_SASL:
+ return LIBMEMCACHED_WITH_SASL_SUPPORT;
+
+ case LIBMEMCACHED_FEATURE_MAX:
+ break;
+ }
+
+ return false;
+}
diff --git a/libmemcached/feature.h b/libmemcached/feature.h
new file mode 100644
index 00000000..fa11fab1
--- /dev/null
+++ b/libmemcached/feature.h
@@ -0,0 +1,37 @@
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2013 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
diff --git a/libmemcached/flag.cc b/libmemcached/flag.cc
index 09b401e6..5744664f 100644
--- a/libmemcached/flag.cc
+++ b/libmemcached/flag.cc
@@ -86,7 +86,9 @@ bool memcached_flag(const memcached_st& memc, const memcached_flag_t flag)
return memcached_is_fetching_version(&memc);
}
- abort();
+ assert_msg(false, "Programmer error, unknown flag provided");
+
+ return false;
}
void memcached_flag(memcached_st& memc, const memcached_flag_t flag, const bool arg)
diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc
index 75bfbee6..16da3c18 100644
--- a/libmemcached/hosts.cc
+++ b/libmemcached/hosts.cc
@@ -221,6 +221,7 @@ static memcached_return_t update_continuum(Memcached *ptr)
float pct= (float)list[host_index].weight / (float)total_weight;
pointer_per_server= (uint32_t) ((::floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
pointer_per_hash= 4;
+#if defined(DEBUG) && DEBUG
if (DEBUG)
{
printf("ketama_weighted:%s|%d|%llu|%u\n",
@@ -229,6 +230,7 @@ static memcached_return_t update_continuum(Memcached *ptr)
(unsigned long long)list[host_index].weight,
pointer_per_server);
}
+#endif
}
@@ -255,10 +257,12 @@ static memcached_return_t update_continuum(Memcached *ptr)
memcached_literal_param("snprintf(sizeof(sort_host))"));
}
+#if defined(DEBUG) && DEBUG
if (DEBUG)
{
fprintf(stdout, "update_continuum: key is %s\n", sort_host);
}
+#endif
if (memcached_is_weighted_ketama(ptr))
{
@@ -335,6 +339,7 @@ static memcached_return_t update_continuum(Memcached *ptr)
ptr->ketama.continuum_points_counter= pointer_counter;
qsort(ptr->ketama.continuum, ptr->ketama.continuum_points_counter, sizeof(memcached_continuum_item_st), continuum_item_cmp);
+#if defined(DEBUG) && DEBUG
if (DEBUG)
{
for (uint32_t pointer_index= 0; memcached_server_count(ptr) && pointer_index < ((live_servers * MEMCACHED_POINTS_PER_SERVER) - 1); pointer_index++)
@@ -342,6 +347,7 @@ static memcached_return_t update_continuum(Memcached *ptr)
WATCHPOINT_ASSERT(ptr->ketama.continuum[pointer_index].value <= ptr->ketama.continuum[pointer_index + 1].value);
}
}
+#endif
return MEMCACHED_SUCCESS;
}
diff --git a/libmemcached/include.am b/libmemcached/include.am
index c298804f..1394137b 100644
--- a/libmemcached/include.am
+++ b/libmemcached/include.am
@@ -20,6 +20,7 @@ noinst_HEADERS+= libmemcached/continuum.hpp
noinst_HEADERS+= libmemcached/do.hpp
noinst_HEADERS+= libmemcached/encoding_key.h
noinst_HEADERS+= libmemcached/error.hpp
+noinst_HEADERS+= libmemcached/feature.hpp
noinst_HEADERS+= libmemcached/flag.hpp
noinst_HEADERS+= libmemcached/initialize_query.h
noinst_HEADERS+= libmemcached/instance.hpp
@@ -79,6 +80,7 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/do.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/dump.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/error.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/exist.cc
+libmemcached_libmemcached_la_SOURCES+= libmemcached/feature.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/fetch.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/flag.cc
libmemcached_libmemcached_la_SOURCES+= libmemcached/flush.cc
diff --git a/libmemcached/response.cc b/libmemcached/response.cc
index f382671d..f69046e8 100644
--- a/libmemcached/response.cc
+++ b/libmemcached/response.cc
@@ -827,7 +827,6 @@ static memcached_return_t binary_read_one_response(memcached_instance_st* instan
case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND:
default:
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
- break;
}
}
diff --git a/libmemcached/sasl.cc b/libmemcached/sasl.cc
index ee225868..fc69e980 100644
--- a/libmemcached/sasl.cc
+++ b/libmemcached/sasl.cc
@@ -135,10 +135,12 @@ static void sasl_startup_function(void)
memcached_return_t memcached_sasl_authenticate_connection(memcached_instance_st* server)
{
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT == 0
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
{
return MEMCACHED_NOT_SUPPORTED;
}
+#endif
if (server == NULL)
{
@@ -324,197 +326,197 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *shell,
const char *username,
const char *password)
{
- Memcached* ptr= memcached2Memcached(shell);
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL))
{
- return MEMCACHED_NOT_SUPPORTED;
- }
+ Memcached* ptr= memcached2Memcached(shell);
- if (ptr == NULL or username == NULL or password == NULL)
- {
- return MEMCACHED_INVALID_ARGUMENTS;
- }
+ if (ptr == NULL or username == NULL or password == NULL)
+ {
+ return MEMCACHED_INVALID_ARGUMENTS;
+ }
- memcached_return_t ret;
- if (memcached_failed(ret= memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)))
- {
- return memcached_set_error(*ptr, ret, MEMCACHED_AT, memcached_literal_param("Unable change to binary protocol which is required for SASL."));
- }
+ memcached_return_t ret;
+ if (memcached_failed(ret= memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)))
+ {
+ return memcached_set_error(*ptr, ret, MEMCACHED_AT, memcached_literal_param("Unable change to binary protocol which is required for SASL."));
+ }
- memcached_destroy_sasl_auth_data(ptr);
+ memcached_destroy_sasl_auth_data(ptr);
- sasl_callback_t *callbacks= libmemcached_xcalloc(ptr, 4, sasl_callback_t);
- size_t password_length= strlen(password);
- size_t username_length= strlen(username);
- char *name= (char *)libmemcached_malloc(ptr, username_length +1);
- sasl_secret_t *secret= (sasl_secret_t*)libmemcached_malloc(ptr, password_length +1 + sizeof(sasl_secret_t));
+ sasl_callback_t *callbacks= libmemcached_xcalloc(ptr, 4, sasl_callback_t);
+ size_t password_length= strlen(password);
+ size_t username_length= strlen(username);
+ char *name= (char *)libmemcached_malloc(ptr, username_length +1);
+ sasl_secret_t *secret= (sasl_secret_t*)libmemcached_malloc(ptr, password_length +1 + sizeof(sasl_secret_t));
- if (callbacks == NULL or name == NULL or secret == NULL)
- {
- libmemcached_free(ptr, callbacks);
- libmemcached_free(ptr, name);
- libmemcached_free(ptr, secret);
- return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
- }
+ if (callbacks == NULL or name == NULL or secret == NULL)
+ {
+ libmemcached_free(ptr, callbacks);
+ libmemcached_free(ptr, name);
+ libmemcached_free(ptr, secret);
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+ }
- secret->len= password_length;
- memcpy(secret->data, password, password_length);
- secret->data[password_length]= 0;
+ secret->len= password_length;
+ memcpy(secret->data, password, password_length);
+ secret->data[password_length]= 0;
- callbacks[0].id= SASL_CB_USER;
- callbacks[0].proc= (int (*)())get_username;
- callbacks[0].context= strncpy(name, username, username_length +1);
- callbacks[1].id= SASL_CB_AUTHNAME;
- callbacks[1].proc= (int (*)())get_username;
- callbacks[1].context= name;
- callbacks[2].id= SASL_CB_PASS;
- callbacks[2].proc= (int (*)())get_password;
- callbacks[2].context= secret;
- callbacks[3].id= SASL_CB_LIST_END;
+ callbacks[0].id= SASL_CB_USER;
+ callbacks[0].proc= (int (*)())get_username;
+ callbacks[0].context= strncpy(name, username, username_length +1);
+ callbacks[1].id= SASL_CB_AUTHNAME;
+ callbacks[1].proc= (int (*)())get_username;
+ callbacks[1].context= name;
+ callbacks[2].id= SASL_CB_PASS;
+ callbacks[2].proc= (int (*)())get_password;
+ callbacks[2].context= secret;
+ callbacks[3].id= SASL_CB_LIST_END;
- ptr->sasl.callbacks= callbacks;
- ptr->sasl.is_allocated= true;
+ ptr->sasl.callbacks= callbacks;
+ ptr->sasl.is_allocated= true;
- return MEMCACHED_SUCCESS;
+ return MEMCACHED_SUCCESS;
+ }
+ return MEMCACHED_NOT_SUPPORTED;
}
memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *shell)
{
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL))
{
- return MEMCACHED_NOT_SUPPORTED;
- }
+ Memcached* ptr= memcached2Memcached(shell);
+ if (ptr == NULL)
+ {
+ return MEMCACHED_INVALID_ARGUMENTS;
+ }
- Memcached* ptr= memcached2Memcached(shell);
- if (ptr == NULL)
- {
- return MEMCACHED_INVALID_ARGUMENTS;
- }
+ if (ptr->sasl.callbacks == NULL)
+ {
+ return MEMCACHED_SUCCESS;
+ }
- if (ptr->sasl.callbacks == NULL)
- {
- return MEMCACHED_SUCCESS;
- }
+ if (ptr->sasl.is_allocated)
+ {
+ libmemcached_free(ptr, ptr->sasl.callbacks[0].context);
+ libmemcached_free(ptr, ptr->sasl.callbacks[2].context);
+ libmemcached_free(ptr, (void*)ptr->sasl.callbacks);
+ ptr->sasl.is_allocated= false;
+ }
- if (ptr->sasl.is_allocated)
- {
- libmemcached_free(ptr, ptr->sasl.callbacks[0].context);
- libmemcached_free(ptr, ptr->sasl.callbacks[2].context);
- libmemcached_free(ptr, (void*)ptr->sasl.callbacks);
- ptr->sasl.is_allocated= false;
- }
+ ptr->sasl.callbacks= NULL;
- ptr->sasl.callbacks= NULL;
+ return MEMCACHED_SUCCESS;
+ }
- return MEMCACHED_SUCCESS;
+ return MEMCACHED_NOT_SUPPORTED;
}
memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st *source)
{
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL))
{
- return MEMCACHED_NOT_SUPPORTED;
- }
-
- if (clone == NULL or source == NULL)
- {
- return MEMCACHED_INVALID_ARGUMENTS;
- }
-
- if (source->sasl.callbacks == NULL)
- {
- return MEMCACHED_SUCCESS;
- }
-
- /* Hopefully we are using our own callback mechanisms.. */
- if (source->sasl.callbacks[0].id == SASL_CB_USER &&
- source->sasl.callbacks[0].proc == (int (*)())get_username &&
- source->sasl.callbacks[1].id == SASL_CB_AUTHNAME &&
- source->sasl.callbacks[1].proc == (int (*)())get_username &&
- source->sasl.callbacks[2].id == SASL_CB_PASS &&
- source->sasl.callbacks[2].proc == (int (*)())get_password &&
- source->sasl.callbacks[3].id == SASL_CB_LIST_END)
- {
- sasl_secret_t *secret= (sasl_secret_t *)source->sasl.callbacks[2].context;
- return memcached_set_sasl_auth_data(clone,
- (const char*)source->sasl.callbacks[0].context,
- (const char*)secret->data);
- }
+ if (clone == NULL or source == NULL)
+ {
+ return MEMCACHED_INVALID_ARGUMENTS;
+ }
- /*
- * But we're not. It may work if we know what the user tries to pass
- * into the list, but if we don't know the ID we don't know how to handle
- * the context...
- */
- ptrdiff_t total= 0;
+ if (source->sasl.callbacks == NULL)
+ {
+ return MEMCACHED_SUCCESS;
+ }
- while (source->sasl.callbacks[total].id != SASL_CB_LIST_END)
- {
- switch (source->sasl.callbacks[total].id)
+ /* Hopefully we are using our own callback mechanisms.. */
+ if (source->sasl.callbacks[0].id == SASL_CB_USER &&
+ source->sasl.callbacks[0].proc == (int (*)())get_username &&
+ source->sasl.callbacks[1].id == SASL_CB_AUTHNAME &&
+ source->sasl.callbacks[1].proc == (int (*)())get_username &&
+ source->sasl.callbacks[2].id == SASL_CB_PASS &&
+ source->sasl.callbacks[2].proc == (int (*)())get_password &&
+ source->sasl.callbacks[3].id == SASL_CB_LIST_END)
{
- case SASL_CB_USER:
- case SASL_CB_AUTHNAME:
- case SASL_CB_PASS:
- break;
- default:
- /* I don't know how to deal with this... */
- return MEMCACHED_NOT_SUPPORTED;
+ sasl_secret_t *secret= (sasl_secret_t *)source->sasl.callbacks[2].context;
+ return memcached_set_sasl_auth_data(clone,
+ (const char*)source->sasl.callbacks[0].context,
+ (const char*)secret->data);
}
- ++total;
- }
+ /*
+ * But we're not. It may work if we know what the user tries to pass
+ * into the list, but if we don't know the ID we don't know how to handle
+ * the context...
+ */
+ ptrdiff_t total= 0;
- sasl_callback_t *callbacks= libmemcached_xcalloc(clone, total +1, sasl_callback_t);
- if (callbacks == NULL)
- {
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- }
- memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
+ while (source->sasl.callbacks[total].id != SASL_CB_LIST_END)
+ {
+ switch (source->sasl.callbacks[total].id)
+ {
+ case SASL_CB_USER:
+ case SASL_CB_AUTHNAME:
+ case SASL_CB_PASS:
+ break;
+ default:
+ /* I don't know how to deal with this... */
+ return MEMCACHED_NOT_SUPPORTED;
+ }
- /* Now update the context... */
- for (ptrdiff_t x= 0; x < total; ++x)
- {
- if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
+ ++total;
+ }
+
+ sasl_callback_t *callbacks= libmemcached_xcalloc(clone, total +1, sasl_callback_t);
+ if (callbacks == NULL)
{
- callbacks[x].context= (sasl_callback_t*)libmemcached_malloc(clone, strlen((const char*)source->sasl.callbacks[x].context));
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
+ memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
- if (callbacks[x].context == NULL)
+ /* Now update the context... */
+ for (ptrdiff_t x= 0; x < total; ++x)
+ {
+ if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
{
- /* Failed to allocate memory, clean up previously allocated memory */
- for (ptrdiff_t y= 0; y < x; ++y)
+ callbacks[x].context= (sasl_callback_t*)libmemcached_malloc(clone, strlen((const char*)source->sasl.callbacks[x].context));
+
+ if (callbacks[x].context == NULL)
{
- libmemcached_free(clone, clone->sasl.callbacks[y].context);
+ /* Failed to allocate memory, clean up previously allocated memory */
+ for (ptrdiff_t y= 0; y < x; ++y)
+ {
+ libmemcached_free(clone, clone->sasl.callbacks[y].context);
+ }
+
+ libmemcached_free(clone, callbacks);
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
-
- libmemcached_free(clone, callbacks);
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ strncpy((char*)callbacks[x].context, (const char*)source->sasl.callbacks[x].context, sizeof(callbacks[x].context));
}
- strncpy((char*)callbacks[x].context, (const char*)source->sasl.callbacks[x].context, sizeof(callbacks[x].context));
- }
- else
- {
- sasl_secret_t *src= (sasl_secret_t *)source->sasl.callbacks[x].context;
- sasl_secret_t *n= (sasl_secret_t*)libmemcached_malloc(clone, src->len + 1 + sizeof(*n));
- if (n == NULL)
+ else
{
- /* Failed to allocate memory, clean up previously allocated memory */
- for (ptrdiff_t y= 0; y < x; ++y)
+ sasl_secret_t *src= (sasl_secret_t *)source->sasl.callbacks[x].context;
+ sasl_secret_t *n= (sasl_secret_t*)libmemcached_malloc(clone, src->len + 1 + sizeof(*n));
+ if (n == NULL)
{
- libmemcached_free(clone, clone->sasl.callbacks[y].context);
+ /* Failed to allocate memory, clean up previously allocated memory */
+ for (ptrdiff_t y= 0; y < x; ++y)
+ {
+ libmemcached_free(clone, clone->sasl.callbacks[y].context);
+ }
+
+ libmemcached_free(clone, callbacks);
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
-
- libmemcached_free(clone, callbacks);
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ memcpy(n, src, src->len + 1 + sizeof(*n));
+ callbacks[x].context= n;
}
- memcpy(n, src, src->len + 1 + sizeof(*n));
- callbacks[x].context= n;
}
- }
- clone->sasl.callbacks= callbacks;
- clone->sasl.is_allocated= true;
+ clone->sasl.callbacks= callbacks;
+ clone->sasl.is_allocated= true;
- return MEMCACHED_SUCCESS;
+ return MEMCACHED_SUCCESS;
+ }
+
+ return MEMCACHED_NOT_SUPPORTED;
}
#else
diff --git a/libmemcachedutil/pid.cc b/libmemcachedutil/pid.cc
index 34656118..5c787ce2 100644
--- a/libmemcachedutil/pid.cc
+++ b/libmemcachedutil/pid.cc
@@ -105,7 +105,7 @@ pid_t libmemcached_util_getpid2(const char *hostname, in_port_t port, const char
if (not ret)
ret= &unused;
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
*ret= MEMCACHED_NOT_SUPPORTED;
return pid;
diff --git a/libmemcachedutil/ping.cc b/libmemcachedutil/ping.cc
index a867c56b..392339b7 100644
--- a/libmemcachedutil/ping.cc
+++ b/libmemcachedutil/ping.cc
@@ -92,7 +92,7 @@ bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *u
if (not ret)
ret= &unused;
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (libmemcached_has_feature(LIBMEMCACHED_FEATURE_HAS_SASL) == false)
{
*ret= MEMCACHED_NOT_SUPPORTED;
return false;
diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4
index d4fccad6..829d3a98 100644
--- a/m4/ax_harden_compiler_flags.m4
+++ b/m4/ax_harden_compiler_flags.m4
@@ -197,7 +197,7 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
_APPEND_COMPILE_FLAGS_ERROR([-Wsizeof-pointer-memaccess])
_APPEND_COMPILE_FLAGS_ERROR([-Wpacked])
# _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
- _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
+# _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
AS_IF([test "x$ax_enable_debug" = xno],
[AS_IF([test "x$ac_cv_vcs_checkout" = xyes],