clients_memslap_SOURCES = clients/memslap.cc
clients_memslap_SOURCES+= clients/generator.cc clients/execute.cc
-clients_memslap_CXXFLAGS = ${PTHREAD_CFLAGS}
+clients_memslap_CXXFLAGS= @PTHREAD_CFLAGS@
clients_memslap_LDADD= $(CLIENTS_LDADDS)
-clients_memslap_LDADD+= $(PTHREAD_LIBS)
+clients_memslap_LDADD+= @PTHREAD_LIBS@
clients_memaslap_SOURCES=
clients_memaslap_SOURCES+= clients/memaslap.c
clients_memaslap_SOURCES+= clients/ms_thread.c
clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc
-clients_memaslap_LDADD= $(LTLIBEVENT) $(CLIENTS_LDADDS)
+clients_memaslap_LDADD=
+clients_memaslap_LDADD+= @LIBEVENT_LDFLAGS@
+clients_memaslap_LDADD+= $(CLIENTS_LDADDS)
clients_memcapable_SOURCES=
clients_memcapable_SOURCES+= clients/memcapable.cc
static void ms_print_memslap_stats(struct timeval *start_time,
struct timeval *end_time);
static void ms_monitor_slap_mode(void);
-void ms_help_command(const char *command_name, const char *description);
+
+/**
+ * output the help information
+ *
+ * @param command_name, the string of this process
+ * @param description, description of this process
+ * @param long_options, global options array
+ */
+static __attribute__((noreturn)) void ms_help_command(const char *command_name, const char *description)
+{
+ char *help_message= NULL;
+
+ printf("%s v%u.%u\n", command_name, 1U, 0U);
+ printf(" %s\n\n", description);
+ printf(
+ "Usage:\n"
+ " memslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n"
+ "Options:\n");
+
+ for (int x= 0; long_options[x].name; x++)
+ {
+ printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name,
+ long_options[x].has_arg ? '=' : ' ');
+
+ if ((help_message= (char *)ms_lookup_help(long_options[x].val)) != NULL)
+ {
+ printf(" %s\n", help_message);
+ }
+ }
+
+ printf(
+ "\nExamples:\n"
+ " memslap -s 127.0.0.1:11211 -S 5s\n"
+ " memslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n"
+ " memslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n"
+ " memslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n"
+ " memslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n"
+ " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n"
+ " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n");
+
+ exit(0);
+} /* ms_help_command */
/* initialize the global locks */
} /* ms_lookup_help */
-/**
- * output the help information
- *
- * @param command_name, the string of this process
- * @param description, description of this process
- * @param long_options, global options array
- */
-void ms_help_command(const char *command_name, const char *description)
-{
- char *help_message= NULL;
-
- printf("%s v%u.%u\n", command_name, 1U, 0U);
- printf(" %s\n\n", description);
- printf(
- "Usage:\n"
- " memslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n"
- "Options:\n");
-
- for (int x= 0; long_options[x].name; x++)
- {
- printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name,
- long_options[x].has_arg ? '=' : ' ');
-
- if ((help_message= (char *)ms_lookup_help(long_options[x].val)) != NULL)
- {
- printf(" %s\n", help_message);
- }
- }
-
- printf(
- "\nExamples:\n"
- " memslap -s 127.0.0.1:11211 -S 5s\n"
- " memslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n"
- " memslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n"
- " memslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n"
- " memslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n"
- " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n"
- " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n");
-
- exit(0);
-} /* ms_help_command */
-
-
/* used to parse the time string */
static int64_t ms_parse_time()
{
max= avg - 1;
}
}
+ (void)last_good;
} /* ms_maximize_sndbuf */
break;
}
}
+ (void)packets;
return wbytes == 0 ? -1 : wbytes;
} /* ms_sort_udp_packet */
atomic_add_size(&ms_stats.cmd_get, 1);
}
+ (void)item;
+
return EXIT_SUCCESS;
} /* ms_mcd_mlget */
pthread_mutex_lock(&ms_global.quit_mutex);
fprintf(stderr, "Segmentation fault occurred.\nStack trace:\n");
+#if 0
pandora_print_callstack(stderr);
+#endif
fprintf(stderr, "End of stack trace\n");
pthread_mutex_unlock(&ms_global.quit_mutex);
abort();
[AC_DEFINE([AX_ENABLE_BACKTRACE],[1],[Support for backtrace().])])
PANDORA_ENABLE_DTRACE
+HAVE_GCC_ATOMICS
AX_ENDIAN
AX_ASSERT
AX_HARDEN_COMPILER_FLAGS
example_memcached_light_LDADD+= libmemcached/libmemcachedprotocol.la
example_memcached_light_LDFLAGS+= @LIBEVENT_LDFLAGS@
-
-include example/t/include.am
+++ /dev/null
-# vim:ft=automake
-# Copyright (C) 2012 Data Differential
-# All rights reserved.
-#
-# Use and distribution licensed under the BSD license. See
-# the COPYING file in the parent directory for full text.
-#
-# included from Top Level Makefile.am
-# All paths should be given relative to the root
-
-MEMCACHED_LIGHT_TESTS_LDADDS= \
- libmemcached/libmemcached.la \
- libmemcached/libmemcachedutil.la \
- libtest/libtest.la
-
-example_t_memcached_light_CXXFLAGS=
-example_t_memcached_light_DEPENDENCIES=
-example_t_memcached_light_LDADD=
-example_t_memcached_light_SOURCES=
-
-example_t_memcached_light_SOURCES+= example/t/memcached_light.cc
-example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc
-example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc
-example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc
-example_t_memcached_light_CXXFLAGS+= $(AM_CXXFLAGS)
-example_t_memcached_light_DEPENDENCIES+= $(MEMCACHED_LIGHT_TESTS_LDADDS)
-example_t_memcached_light_DEPENDENCIES+= example/memcached_light
-example_t_memcached_light_LDADD+= $(MEMCACHED_LIGHT_TESTS_LDADDS)
-example_t_memcached_light_LDADD+= $(LIBUUID_LDFLAGS)
-check_PROGRAMS+= example/t/memcached_light
-noinst_PROGRAMS+= example/t/memcached_light
-
-test-memcached_light: example/t/memcached_light example/memcached_light
- @example/t/memcached_light
-
-gdb-memcached_light: example/t/memcached_light example/memcached_light
- @$(DEBUG_COMMAND) example/t/memcached_light
-
-valgrind-memcached_light: example/t/memcached_light example/memcached_light
- $(VALGRIND_COMMAND) example/t/memcached_light
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Test memcat
- *
- * Copyright (C) 2011 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.
- *
- */
-
-
-/*
- Test that we are cycling the servers we are creating during testing.
-*/
-
-#include <mem_config.h>
-
-#include <libtest/test.hpp>
-#include <libmemcached-1.0/memcached.h>
-
-#include "tests/libmemcached-1.0/memcached_get.h"
-
-using namespace libtest;
-
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#endif
-
-static std::string executable("example/memcached_light");
-
-static test_return_t help_TEST(void *)
-{
- const char *args[]= { "--help", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t verbose_TEST(void *)
-{
- const char *args[]= { "--help", "--verbose", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t daemon_TEST(void *)
-{
- const char *args[]= { "--help", "--daemon", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t protocol_TEST(void *)
-{
- const char *args[]= { "--help", "--protocol", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t version_TEST(void *)
-{
- const char *args[]= { "--help", "--version", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t port_TEST(void *)
-{
- const char *args[]= { "--help", "--port=9090", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pid_file_TEST(void *)
-{
- const char *args[]= { "--help", "--pid-file=/tmp/foo.pid", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t log_file_TEST(void *)
-{
- const char *args[]= { "--help", "--log-file=/tmp/foo.log", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t max_connections_file_TEST(void *)
-{
- const char *args[]= { "--help", "--max-connections=/tmp/foo.max_connections", 0 };
-
- test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
-
- return TEST_SUCCESS;
-}
-
-typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *);
-
-static test_return_t _runner_default(libmemcached_test_callback_fn func, void *object)
-{
- if (func)
- {
- test_true(object);
- test_return_t ret;
- try {
- ret= func((memcached_st*)object);
- }
- catch (std::exception& e)
- {
- libtest::Error << e.what();
- return TEST_FAILURE;
- }
-
- return ret;
- }
-
- return TEST_SUCCESS;
-}
-
-class MemcachedLightRunner : public libtest::Runner {
-public:
- test_return_t run(test_callback_fn* func, void *object)
- {
- return _runner_default(libmemcached_test_callback_fn(func), object);
- }
-};
-
-test_st cmdline_option_TESTS[] ={
- {"--help", true, help_TEST },
- {"--verbose", true, verbose_TEST },
- {"--daemon", true, daemon_TEST },
- {"--protocol", true, protocol_TEST },
- {"--version", true, version_TEST },
- {"--port", true, port_TEST },
- {"--pid-file", true, pid_file_TEST },
- {"--log-file", true, log_file_TEST },
- {"--max-connections", true, max_connections_file_TEST },
- {0, 0, 0}
-};
-
-/* Clean the server before beginning testing */
-test_st basic_TESTS[] ={
-#if 0
- {"memcached_get()", true, (test_callback_fn*)get_test },
- {"memcached_get() test 2", false, (test_callback_fn*)get_test2 },
- {"memcached_get() test 3", false, (test_callback_fn*)get_test3 },
- {"memcached_get() test 4", false, (test_callback_fn*)get_test4 },
- {"memcached_get() test 5", false, (test_callback_fn*)get_test5 },
-#endif
- {0, 0, 0}
-};
-
-collection_st collection[] ={
- {"command line options", 0, 0, cmdline_option_TESTS },
- {"basic", 0, 0, basic_TESTS },
- {0, 0, 0, 0}
-};
-
-static void *world_create(server_startup_st& servers, test_return_t& error)
-{
- if (access(executable.c_str(), X_OK) != 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
- if (HAVE_MEMCACHED_LIGHT_BINARY == 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
- if (server_startup(servers, "memcached-light", libtest::default_port(), 0, NULL) == 0)
- {
- error= TEST_FAILURE;
- return NULL;
- }
-
-
- char buffer[1024];
- int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(libtest::default_port()));
- fatal_assert(length > 0);
-
- memcached_st *memc= memcached(buffer, length);
-
- fatal_assert(memc);
-
- return (void*)memc;
-}
-
-static bool world_destroy(void *object)
-{
- memcached_st *memc= (memcached_st*)object;
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-
-void get_world(libtest::Framework* world)
-{
- world->create(world_create);
- world->destroy(world_destroy);
- world->collections(collection);
- world->set_runner(new MemcachedLightRunner);
-}
-
*
*/
-#include <libmemcached/common.h>
+#include "mem_config.h"
+#include "libmemcached/byteorder.h"
/* Byte swap a 64-bit number. */
#ifndef swap64
return PROTOCOL_BINARY_RESPONSE_EINTERNAL;
}
- size_t len= sizeof(protocol_binary_response_header) + memcached_htonl(response->response.bodylen);
+ size_t len= sizeof(protocol_binary_response_header) + htonl(response->response.bodylen);
size_t offset= 0;
char *ptr= (void*)response;
#pragma once
-#include "config.h"
+#include "mem_config.h"
#include <assert.h>
#include <libmemcachedprotocol-0.0/handler.h>
libmemcached_libmemcachedprotocol_la_CFLAGS+= ${AM_CFLAGS}
libmemcached_libmemcachedprotocol_la_CFLAGS+= ${NO_CONVERSION}
libmemcached_libmemcachedprotocol_la_CFLAGS+= -DBUILDING_LIBMEMCACHED
-libmemcached_libmemcachedprotocol_la_CFLAGS+= ${PTHREAD_CFLAGS}
+libmemcached_libmemcachedprotocol_la_CFLAGS+= @PTHREAD_CFLAGS@
libmemcached_libmemcachedprotocol_la_CXXFLAGS=
libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${AM_CXXFLAGS}
libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED
-libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${PTHREAD_CFLAGS}
+libmemcached_libmemcachedprotocol_la_CXXFLAGS+= @PTHREAD_CFLAGS@
-libmemcached_libmemcachedprotocol_la_LIBADD= ${PTHREAD_LIBS}
+libmemcached_libmemcachedprotocol_la_LIBADD=
+libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LDFLAGS@
+libmemcached_libmemcachedprotocol_la_LIBADD+= @PTHREAD_LIBS@
libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS}
libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION}
lib_LTLIBRARIES+= libmemcached/libmemcachedutil.la
-noinst_HEADERS+= \
- libmemcachedutil/common.h
+noinst_HEADERS+= libmemcachedutil/common.h
libmemcached_libmemcachedutil_la_SOURCES= \
libmemcached/backtrace.cc \
${AM_CXXFLAGS} \
${NO_CONVERSION} \
-DBUILDING_LIBMEMCACHED
-libmemcached_libmemcachedutil_la_CXXFLAGS+= ${PTHREAD_CFLAGS}
+libmemcached_libmemcachedutil_la_CXXFLAGS+= @PTHREAD_CFLAGS@
libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
-libmemcached_libmemcachedutil_la_LIBADD+= ${PTHREAD_LIBS}
+libmemcached_libmemcachedutil_la_LIBADD+= @PTHREAD_LIBS@
libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
--- /dev/null
+# serial 1
+#
+AC_DEFUN([HAVE_GCC_ATOMICS],
+ [AC_CACHE_CHECK([whether the compiler provides atomic builtins],
+ [ax_cv_gcc_atomic_builtins],
+ [AX_SAVE_FLAGS
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([],
+ [[
+ int foo= -10; int bar= 10;
+ if (!__sync_fetch_and_add(&foo, bar) || foo)
+ {
+ return -1;
+ }
+ bar= __sync_lock_test_and_set(&foo, bar);
+ if (bar || foo != 10)
+ {
+ return -1;
+ }
+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
+ if (bar)
+ {
+ return -1;
+ }
+ ]])],
+ [ax_cv_gcc_atomic_builtins=yes],
+ [ax_cv_gcc_atomic_builtins=no],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ AX_RESTORE_FLAGS
+ ])
+
+ AS_IF([test "x$ax_cv_gcc_atomic_builtins" = "xyes"],
+ [AC_DEFINE([HAVE_GCC_ATOMIC_BUILTINS],[1],
+ [Define to 1 if compiler provides atomic builtins.])
+ ])
+ ])