TESTS += ${check_PROGRAMS}
XFAIL_TESTS += ${bin_PROGRAMS}
+if ! BUILD_WIN32
+
merge-clean:
@find ./ | $(GREP) \.gcda | xargs rm -f
@find ./ | $(GREP) \.gcno | xargs rm -f
@echo "Files that need to be either removed or checked in:"
@bzr unknowns
-clean-local:
- -rm -rf docs/_build docs/doctrees
+clean-local: clean-libtest-check clean-docs-check
+
lcov: lcov-clean check
@echo
@rm -rf lcov */lcov.out
@find . -name '*.gcno' | xargs rm -f
@find . -name '*.gcda' | xargs rm -f
+endif
DISTCLEANFILES+= config/top.h
-clean-local: clean-libtest-check clean-docs-check
-
maintainer-clean-local:
find . -type f -name '*~' -exec rm -f '{}' \;
-rm -f @PACKAGE@-*.rpm
# Arguments for configure
local BUILD_CONFIGURE_ARG=
- # Set ENV DEBUG in order to enable debugging
+ # If ENV DEBUG is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
+ # Set ENV ASSERT in order to enable assert
if $DEBUG; then
- BUILD_CONFIGURE_ARG='--enable-debug'
+ BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
+ elif [[ -n "$VCS_CHECKOUT" ]]; then
+ BUILD_CONFIGURE_ARG+=' --enable-assert'
fi
- # Set ENV ASSERT in order to enable assert
- if [[ -n "$ASSERT" ]]; then
- local ASSERT_ARG=
- ASSERT_ARG='--enable-assert'
- BUILD_CONFIGURE_ARG="$ASSERT_ARG $BUILD_CONFIGURE_ARG"
+ if [[ -n "$CONFIGURE_ARG" ]]; then
+ BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG"
fi
- if [[ -n "$CONFIGURE_ARG" ]]; then
- BUILD_CONFIGURE_ARG= "$BUILD_CONFIGURE_ARG $CONFIGURE_ARG"
+ if [[ -n "$PREFIX_ARG" ]]; then
+ BUILD_CONFIGURE_ARG+=" $PREFIX_ARG"
fi
ret=1;
# If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
case $HOST_OS in
*-darwin-*)
- CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG $PREFIX_ARG"
+ CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
ret=$?
;;
rhel-5*)
command_exists 'gcc44' || die "Could not locate gcc44"
- CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG $PREFIX_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG $PREFIX_ARG"
+ CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
ret=$?
;;
*)
- $CONFIGURE $BUILD_CONFIGURE_ARG $PREFIX_ARG
+ $CONFIGURE $BUILD_CONFIGURE_ARG
ret=$?
;;
esac
if [ $ret -ne 0 ]; then
- die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG $PREFIX_ARG"
+ die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG"
fi
if [ ! -f 'Makefile' ]; then
die "OLD_CONFIGURE_ARG($OLD_CONFIGURE_ARG) was set on push, programmer error!"
fi
+ if [[ -n "$OLD_PREFIX" ]]; then
+ die "OLD_PREFIX($OLD_PREFIX) was set on push, programmer error!"
+ fi
+
if [[ -n "$OLD_MAKE" ]]; then
die "OLD_MAKE($OLD_MAKE) was set on push, programmer error!"
fi
CONFIGURE_ARG=$OLD_CONFIGURE_ARG
fi
+ if [[ -n "$OLD_PREFIX" ]]; then
+ PREFIX_ARG=$OLD_PREFIX
+ fi
+
if [[ -n "$OLD_MAKE" ]]; then
MAKE=$OLD_MAKE
fi
OLD_CONFIGURE=
OLD_CONFIGURE_ARG=
+ OLD_PREFIX=
OLD_MAKE=
OLD_TESTS_ENVIRONMENT=
export -n CC CXX
}
-function push_PREFIX_ARG ()
-{
- if [[ -n "$OLD_PREFIX_ARG" ]]; then
- die "OLD_PREFIX_ARG was set on push, programmer error!"
- fi
-
- if [[ -n "$PREFIX_ARG" ]]; then
- OLD_PREFIX_ARG=$PREFIX_ARG
- PREFIX_ARG=
- fi
-
- if [[ -n "$1" ]]; then
- PREFIX_ARG="--prefix=$1"
- fi
-}
-
-function pop_PREFIX_ARG ()
-{
- if [[ -n "$OLD_PREFIX_ARG" ]]; then
- PREFIX_ARG=$OLD_PREFIX_ARG
- OLD_PREFIX_ARG=
- else
- PREFIX_ARG=
- fi
-}
-
-function push_TESTS_ENVIRONMENT ()
-{
- if [[ -n "$OLD_TESTS_ENVIRONMENT" ]]; then
- die "OLD_TESTS_ENVIRONMENT was set on push, programmer error!"
- fi
-
- if [[ -n "$TESTS_ENVIRONMENT" ]]; then
- OLD_TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT
- TESTS_ENVIRONMENT=
- fi
-}
-
-function pop_TESTS_ENVIRONMENT ()
-{
- TESTS_ENVIRONMENT=
- if [[ -n "$OLD_TESTS_ENVIRONMENT" ]]; then
- TESTS_ENVIRONMENT=$OLD_TESTS_ENVIRONMENT
- OLD_TESTS_ENVIRONMENT=
- fi
-}
-
function safe_pushd ()
{
pushd $1 &> /dev/null ;
return 1
fi
+ save_BUILD
+
# If we are required to run configure, do so now
run_configure_if_required
- push_TESTS_ENVIRONMENT
-
# If we don't have a configure, then most likely we will be missing libtool
assert_file 'configure'
if [[ -f 'libtool' ]]; then
make_target 'check' || return 1
- pop_TESTS_ENVIRONMENT
+ restore_BUILD
}
function make_install_system ()
{
local INSTALL_LOCATION=$(mktemp -d /tmp/XXXXXXXXXX)
- push_PREFIX_ARG $INSTALL_LOCATION
+
+ save_BUILD
+ PREFIX_ARG="--prefix=$INSTALL_LOCATION"
if [ ! -d $INSTALL_LOCATION ] ; then
die "ASSERT temp directory not found '$INSTALL_LOCATION'"
run_configure #install_buid_dir
- push_TESTS_ENVIRONMENT
-
make_target 'install'
make_target 'installcheck'
make_target 'uninstall'
- pop_TESTS_ENVIRONMENT
- pop_PREFIX_ARG
-
rm -r -f $INSTALL_LOCATION
make 'distclean'
die "ASSERT Makefile should not exist"
fi
+ restore_BUILD
safe_popd
}
function make_gdb ()
{
+ save_BUILD
+
if command_exists 'gdb'; then
run_configure_if_required
- push_TESTS_ENVIRONMENT
-
# Set ENV GDB_COMMAND
if [[ -z "$GDB_COMMAND" ]]; then
setup_gdb_command
rm 'gdb.txt'
fi
- pop_TESTS_ENVIRONMENT
-
if [ -f '.gdb_history' ]; then
rm '.gdb_history'
fi
echo 'gdb was not present'
return 1
fi
+
+ restore_BUILD
}
# $1 target to compile
VCS_CHECKOUT=svn
elif [[ -d '.hg' ]]; then
VCS_CHECKOUT=hg
+ else
+ VCS_CHECKOUT=
fi
if [[ -n "$VCS_CHECKOUT" ]]; then
# Set ENV PREFIX in order to set --prefix for ./configure
if [[ -n "$PREFIX" ]]; then
- push_PREFIX_ARG $PREFIX
+ PREFIX_ARG="--prefix=$PREFIX"
fi
# We should always have a target by this point
local OLD_CONFIGURE=
local OLD_CONFIGURE_ARG=
+ local OLD_PREFIX=
local OLD_MAKE=
local OLD_TESTS_ENVIRONMENT=
export AUTOM4TE
export AUTOMAKE
export AUTORECONF
+export CONFIGURE_ARG
export DEBUG
export GNU_BUILD_FLAGS
export LIBTOOLIZE
export LIBTOOLIZE_OPTIONS
export MAKE
+export PREFIX_ARG
export TESTS_ENVIRONMENT
export VERBOSE
export WARNINGS
*/
static memcached_socket_t set_noblock(void)
{
-#ifdef WIN32
+#if defined(_WIN32)
u_long arg = 1;
if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR)
{
void initialize_sockets(void)
{
/* Define the function for all platforms to avoid #ifdefs in each program */
-#if defined(WIN32) && WIN32
+#if defined(_WIN32)
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)
{
fprintf(stderr, "Socket Initialization Error. Program aborted\n");
exit(EXIT_FAILURE);
}
-#endif
+#endif // #if defined(_WIN32)
}
# LibmemcacheD
-# Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
+# Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
# Copyright (C) 2006-2010 Brian Aker, Monty Taylor, Trond Norbye
# All rights reserved.
#
ENABLE_DEPRECATED
# Checks for programs.
+AC_PROG_AWK
+AC_PROG_SED
+AC_PROG_MKDIR_P
AC_CHECK_PROGS([LEX],['flex'],[:])
AC_CHECK_PROGS([YACC],['bison'],[:])
AX_PROG_SPHINX_BUILD
+AX_PROG_MEMCACHED
# Checks for libraries.
AC_SEARCH_LIBS([getopt_long],[gnugetopt])
])
CHECK_FOR_PTHREAD_AND_SASL
-
# backtrace(), others require shared builds
-AS_IF([test "x$enable_shared" = "xyes"],
- [AC_DEFINE([HAVE_SHARED_ENABLED],[1],[Enable code which requires shared library support. Like backtrace().])])
+AC_DEFUN([__ENABLE_SHARED],
+ [AC_REQUIRE([AX_PLATFORM])
+ AS_IF([test "x${TARGET_WINDOWS}" = "xtrue"],[enable_shared=no])
+ AS_IF([test "x$enable_shared" = "xyes"],
+ [AC_DEFINE([HAVE_SHARED_ENABLED],[1],[Enable code which requires shared library support. Like backtrace().])])])
AM_CONDITIONAL([SHARED_ENABLED],[test "x$enable_shared" = "xyes"])
PANDORA_ENABLE_DTRACE
#include <string.h>
#include <sys/types.h>
+#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
+
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
typedef const unsigned char *CONST_POINTER;
#pragma once
-#if defined(WIN32) || defined(__MINGW32__)
+#if defined(_WIN32)
# include <winsock2.h>
# include <ws2tcpip.h>
typedef int memcached_socket_t;
-#endif /* WIN32 */
+#endif /* _WIN32 */
# include <dlfcn.h>
#endif
-#if defined(WIN32) || defined(__MINGW32__)
+#if defined(_WIN32)
# include "libmemcached/windows.hpp"
#endif
int local_errno= get_socket_errno(); // We cache in case closesocket() modifies errno
switch (local_errno)
{
-#ifdef TARGET_OS_LINUX
+#ifdef __linux__
case ERESTART:
#endif
case EINTR:
default: // This should not happen
break;
-#if 0
- if (fds[0].revents & POLLERR)
- {
- int err;
- socklen_t len= sizeof(err);
- if (getsockopt(server->fd, SOL_SOCKET, SO_ERROR, (char*)&err, &len) == 0)
- {
- if (err == 0)
- {
- // This should never happen, if it does? Punt.
- continue;
- }
- local_errno= err;
- }
- }
-#endif
}
assert_msg(server->fd != INVALID_SOCKET, "poll() was passed an invalid file descriptor");
}
}
- return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_literal_param("(number_of == 0)"));
}
-#if 0
- server->revents(fds[0].revents);
-#endif
-
assert (number_of == 1);
if (fds[0].revents & POLLERR or
static inline void set_socket_nonblocking(org::libmemcached::Instance* server)
{
-#ifdef WIN32
+#if defined(_WIN32)
u_long arg= 1;
if (ioctlsocket(server->fd, FIONBIO, &arg) == SOCKET_ERROR)
{
#if defined(_WIN32)
#else
-#if defined(SO_NOSIGPIPE)
+# if defined(SO_NOSIGPIPE)
if (SO_NOSIGPIPE)
{
int set= 1;
#endif
}
}
-#endif // SO_NOSIGPIPE
+# endif // SO_NOSIGPIPE
#endif // _WIN32
if (server->root->flags.no_block)
static memcached_return_t unix_socket_connect(org::libmemcached::Instance* server)
{
-#ifndef WIN32
+#ifndef _WIN32
WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET);
do {
if (timeout_error_occured and server->state < MEMCACHED_SERVER_STATE_IN_PROGRESS)
{
- return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT,
+ memcached_literal_param("if (timeout_error_occured and server->state < MEMCACHED_SERVER_STATE_IN_PROGRESS)"));
}
return memcached_set_error(*server, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); /* The last error should be from connect() */
%parse-param { class Context *context }
%parse-param { yyscan_t *scanner }
%pure-parser
-%require "2.4"
+%require "2.5"
%start begin
%verbose
#include <libmemcached/csl/scanner.h>
#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wold-style-cast"
+# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
#ifndef __INTEL_COMPILER
-#ifndef __clang__
-#pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
+# ifndef __clang__
+# pragma GCC diagnostic ignored "-Wlogical-op"
+# pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
+# endif
#endif
int conf_lex(YYSTYPE* lvalp, void* scanner);
vector[0].length= UDP_DATAGRAM_HEADER_LENGTH;
msg.msg_iov= (struct iovec*)vector;
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+#ifdef __APPLE__
msg.msg_iovlen= int(count);
#else
msg.msg_iovlen= count;
*
* Libmemcached library
*
- * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
flags, error);
}
-static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr,
- const char *group_key,
- size_t group_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode);
+static memcached_return_t __mget_by_key_real(memcached_st *ptr,
+ const char *group_key,
+ size_t group_key_length,
+ const char * const *keys,
+ const size_t *key_length,
+ size_t number_of_keys,
+ const bool mget_mode);
char *memcached_get_by_key(memcached_st *shell,
const char *group_key,
size_t group_key_length,
}
/* Request the key */
- *error= memcached_mget_by_key_real(ptr, group_key, group_key_length,
- (const char * const *)&key, &key_length,
- 1, false);
+ *error= __mget_by_key_real(ptr, group_key, group_key_length,
+ (const char * const *)&key, &key_length,
+ 1, false);
if (ptr)
{
assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");
}
static memcached_return_t binary_mget_by_key(memcached_st *ptr,
- uint32_t master_server_key,
- bool is_group_key_set,
+ const uint32_t master_server_key,
+ const bool is_group_key_set,
+ const char * const *keys,
+ const size_t *key_length,
+ const size_t number_of_keys,
+ const bool mget_mode);
+
+static memcached_return_t __mget_by_key_real(memcached_st *ptr,
+ const char *group_key,
+ const size_t group_key_length,
const char * const *keys,
const size_t *key_length,
size_t number_of_keys,
- bool mget_mode);
-
-static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr,
- const char *group_key,
- size_t group_key_length,
- const char * const *keys,
- const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode)
+ const bool mget_mode)
{
bool failures_occured_in_sending= false;
const char *get_command= "get";
size_t number_of_keys)
{
Memcached* ptr= memcached2Memcached(shell);
- return memcached_mget_by_key_real(ptr, group_key, group_key_length, keys,
- key_length, number_of_keys, true);
+ return __mget_by_key_real(ptr, group_key, group_key_length, keys, key_length, number_of_keys, true);
}
memcached_return_t memcached_mget_execute(memcached_st *ptr,
rc= memcached_mget_by_key(ptr, group_key, group_key_length, keys,
key_length, number_of_keys);
ptr->callbacks= original_callbacks;
+
return rc;
}
static memcached_return_t simple_binary_mget(memcached_st *ptr,
- uint32_t master_server_key,
+ const uint32_t master_server_key,
bool is_group_key_set,
const char * const *keys,
const size_t *key_length,
- size_t number_of_keys, bool mget_mode)
+ const size_t number_of_keys, const bool mget_mode)
{
memcached_return_t rc= MEMCACHED_NOTFOUND;
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
}
- memcached_return_t vk;
- vk= memcached_validate_key_length(key_length[x],
- ptr->flags.binary_protocol);
- if (vk != MEMCACHED_SUCCESS)
{
- if (x > 0)
+ memcached_return_t vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol);
+ if (vk != MEMCACHED_SUCCESS)
{
- memcached_io_reset(instance);
- }
+ if (x > 0)
+ {
+ memcached_io_reset(instance);
+ }
- return vk;
+ return vk;
+ }
}
request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace)));
for (uint32_t x= 0; x < memcached_server_count(ptr); ++x)
{
org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, x);
- initialize_binary_request(instance, request.message.header);
if (instance->response_count())
{
- if (memcached_io_write(instance) == false)
- {
- memcached_instance_response_reset(instance);
- memcached_io_reset(instance);
- rc= MEMCACHED_SOME_ERRORS;
- }
-
- if (memcached_io_write(instance, request.bytes,
- sizeof(request.bytes), true) == -1)
+ initialize_binary_request(instance, request.message.header);
+ if ((memcached_io_write(instance) == false) or
+ (memcached_io_write(instance, request.bytes, sizeof(request.bytes), true) == -1))
{
memcached_instance_response_reset(instance);
memcached_io_reset(instance);
}
}
-
return rc;
}
bool* dead_servers,
const char *const *keys,
const size_t *key_length,
- size_t number_of_keys)
+ const size_t number_of_keys)
{
memcached_return_t rc= MEMCACHED_NOTFOUND;
uint32_t start= 0;
for (uint32_t x= 0; x < number_of_keys; ++x)
{
if (hash[x] == memcached_server_count(ptr))
+ {
continue; /* Already successfully sent */
+ }
- uint32_t server= hash[x] + replica;
+ uint32_t server= hash[x] +replica;
/* In case of randomized reads */
if (randomize_read and ((server + start) <= (hash[x] + ptr->number_of_replicas)))
}
static memcached_return_t binary_mget_by_key(memcached_st *ptr,
- uint32_t master_server_key,
+ const uint32_t master_server_key,
bool is_group_key_set,
const char * const *keys,
const size_t *key_length,
- size_t number_of_keys,
- bool mget_mode)
+ const size_t number_of_keys,
+ const bool mget_mode)
{
if (ptr->number_of_replicas == 0)
{
noinst_HEADERS+= libmemcached/version.hpp
noinst_HEADERS+= libmemcached/virtual_bucket.h
noinst_HEADERS+= libmemcached/watchpoint.h
+noinst_HEADERS+= libmemcached/windows.hpp
lib_LTLIBRARIES+= libmemcached/libmemcached.la
EXTRA_libmemcached_libmemcached_la_DEPENDENCIES=
if BUILD_WIN32
libmemcached_libmemcached_la_CFLAGS+= -DBUILDING_HASHKIT
libmemcached_libmemcached_la_CXXFLAGS+= -DBUILDING_HASHKIT
-libmemcached_libmemcached_la_LIBADD+= -lmingw64
-libmemcached_libmemcached_la_LIBADD+= -lws2_64
+libmemcached_libmemcached_la_LIBADD+= -lmingw32
+libmemcached_libmemcached_la_LIBADD+= -lws2_32
endif
libmemcached_libmemcached_la_SOURCES+= libmemcached/instance.cc
#include <libmemcached/common.h>
#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
+# include <sys/socket.h>
#endif
void initialize_binary_request(org::libmemcached::Instance* server, protocol_binary_request_header& header)
if (instance->root->poll_timeout == 0) // Mimic 0 causes timeout behavior (not all platforms do this)
{
- return memcached_set_error(*instance, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ return memcached_set_error(*instance, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_literal_param("poll_timeout() was set to zero"));
}
size_t loop_max= 5;
if (active_fd == 0)
{
- return memcached_set_error(*instance, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ return memcached_set_error(*instance, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_literal_param("No active_fd were found"));
}
// Only an error should result in this code being called.
#include "libmemcached/common.h"
-#if defined(WIN32) || defined(__MINGW32__)
+#if defined(_WIN32)
#include "libmemcached/poll.h"
#include <sys/time.h>
{
if (fds[x].events & (POLLIN | POLLOUT))
{
-#ifndef WIN32
+#ifndef _WIN32
if (fds[x].fd > maxfd)
{
maxfd= fds[x].fd;
return ret;
}
-#endif // defined(WIN32) || defined(__MINGW32__)
+#endif // defined(_WIN32)
#pragma once
-#if defined(WIN32) || defined(__MINGW32__)
+#if defined(_WIN32)
#include <winsock2.h>
typedef struct pollfd
{
-#ifdef WIN32
+#if defined(_WIN32)
SOCKET fd;
#else
int fd;
}
#endif
-#endif // defined(WIN32) || defined(__MINGW32__)
+#endif // defined(_WIN32)
}
break;
+ case PROTOCOL_BINARY_CMD_TOUCH:
+ {
+ rc= MEMCACHED_SUCCESS;
+ if (bodylen == 4) // The four byte read is a bug?
+ {
+ char touch_buffer[4]; // @todo document this number
+ rc= memcached_safe_read(instance, touch_buffer, sizeof(touch_buffer));
+#if 0
+ fprintf(stderr, "%s:%d %d %d %d %d %.*s(%d)\n", __FILE__, __LINE__,
+ int(touch_buffer[0]),
+ int(touch_buffer[1]),
+ int(touch_buffer[2]),
+ int(touch_buffer[3]),
+ int(bodylen), touch_buffer, int(bodylen));
+#endif
+ }
+ return memcached_set_error(*instance, rc, MEMCACHED_AT);
+ }
+
case PROTOCOL_BINARY_CMD_FLUSH:
case PROTOCOL_BINARY_CMD_QUIT:
case PROTOCOL_BINARY_CMD_SET:
case PROTOCOL_BINARY_CMD_APPEND:
case PROTOCOL_BINARY_CMD_PREPEND:
case PROTOCOL_BINARY_CMD_DELETE:
- case PROTOCOL_BINARY_CMD_TOUCH:
{
- if (bodylen != 0)
- {
- char touch_buffer[32]; // @todo document this number
- rc= memcached_safe_read(instance, buffer, sizeof(touch_buffer));
- }
+ WATCHPOINT_ASSERT(bodylen == 0);
return MEMCACHED_SUCCESS;
}
--- /dev/null
+/*
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * 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
+
+#ifdef __cplusplus
+# include <cerrno>
+#else
+# include <errno.h>
+#endif
+
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+
+#ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+#endif
+
+#ifdef __MINGW32__
+# if(_WIN32_WINNT >= 0x0501)
+# else
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+# endif /* _WIN32_WINNT >= 0x0501 */
+#endif /* __MINGW32__ */
+
+#if defined(HAVE_WINSOCK2_H) && HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
+
+#if defined(HAVE_WS2TCPIP_H) && HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+
+#if defined(HAVE_IO_H) && HAVE_IO_H
+# include <io.h>
+#endif
+
+struct sockaddr_un
+{
+ short int sun_family;
+ char sun_path[108];
+};
+
+static inline int translate_windows_error()
+{
+ int local_errno= WSAGetLastError();
+
+ switch(local_errno) {
+ case WSAEINVAL:
+ local_errno= EINPROGRESS;
+ break;
+ case WSAEALREADY:
+ case WSAEWOULDBLOCK:
+ local_errno= EAGAIN;
+ break;
+
+ case WSAECONNREFUSED:
+ local_errno= ECONNREFUSED;
+ break;
+
+ case WSAENETUNREACH:
+ local_errno= ENETUNREACH;
+ break;
+
+ case WSAETIMEDOUT:
+ local_errno= ETIMEDOUT;
+ break;
+
+ case WSAECONNRESET:
+ local_errno= ECONNRESET;
+ break;
+
+ case WSAEADDRINUSE:
+ local_errno= EADDRINUSE;
+ break;
+
+ case WSAEOPNOTSUPP:
+ local_errno= EOPNOTSUPP;
+ break;
+
+ case WSAENOPROTOOPT:
+ local_errno= ENOPROTOOPT;
+ break;
+
+ default:
+ break;
+ }
+
+ return local_errno;
+}
#pragma once
-#ifndef WIN32
-#include <netdb.h>
+#ifndef _WIN32
+# include <netdb.h>
#endif
#include <sys/types.h>
}
}
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+#ifdef __APPLE__
struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
#else
struct timeval it_value= { tv_sec, tv_usec };
# include <arpa/inet.h>
#endif
-#if defined(WIN32) || defined(__MINGW32__)
+#if defined(_WIN32)
# include "win32/wrappers.h"
# define get_socket_errno() WSAGetLastError()
#else
void dream(time_t tv_sec, long tv_nsec)
{
-#ifdef WIN32
+#if defined(_WIN32)
if (tv_sec == 0 and tv_nsec)
{
tv_sec++;
# include <string.h>
#endif
-#ifdef _WIN32
+#if defined(_WIN32)
# include <malloc.h>
#else
# include <alloca.h>
+++ /dev/null
-#serial 2
-
-AC_DEFUN([YATL_MEMCACHED],
- [AX_WITH_PROG(MEMCACHED_BINARY, [memcached])
- AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"],
- [AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
- AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$ac_cv_path_MEMCACHED_BINARY", [Name of the memcached binary used in make test])],
- [AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
- AC_DEFINE([MEMCACHED_BINARY], ["memcached/memcached"], [Name of the memcached binary used in make test])
- ])
- ])
AC_CONFIG_FILES([libtest/version.h])
m4_include([libtest/m4/mysql.m4])
-m4_include([libtest/m4/memcached.m4])
AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY],[0],[If Memcached binary with sasl support is available])
YATL_MYSQL
-YATL_MEMCACHED
AC_CONFIG_FILES([libtest/yatlcon.h])
+# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
# ===========================================================================
# https://github.com/BrianAker/ddm4/
# ===========================================================================
# ? _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long]) -- Don't turn on for
# compatibility issues memcached_stat_st
-#serial 7
+#serial 8
AC_DEFUN([_WARNINGS_AS_ERRORS],
[AC_CACHE_CHECK([if all warnings into errors],[ac_cv_warnings_as_errors],
# Everything above this does the heavy lifting, while what follows does the specifics.
AC_DEFUN([_HARDEN_LINKER_FLAGS],
- [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
- #_APPEND_LINK_FLAGS_ERROR([-pie])
- AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
- [AX_APPEND_LINK_FLAGS([-Werror])])
+ [
+ AS_IF([test "$CC" != "clang"],
+ [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
+#_APPEND_LINK_FLAGS_ERROR([-pie])
+ AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
+ [AX_APPEND_LINK_FLAGS([-Werror])])])
])
AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
AS_IF([test "x$ax_enable_debug" = xyes],
[CFLAGS=''
+ _APPEND_COMPILE_FLAGS_ERROR([-H])
_APPEND_COMPILE_FLAGS_ERROR([-ggdb])
_APPEND_COMPILE_FLAGS_ERROR([-g])
_APPEND_COMPILE_FLAGS_ERROR([-O0])],
_APPEND_COMPILE_FLAGS_ERROR([-O2])])
AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
- [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
- [_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+ [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
+ [_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+
+ AS_IF([test "$CC" = "clang"],
+ [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
- _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
_APPEND_COMPILE_FLAGS_ERROR([-std=c99])
# Anything below this comment please keep sorted.
- _APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
# _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunsuffixed-float-constants])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wjump-misses-init])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
_APPEND_COMPILE_FLAGS_ERROR([-Waddress])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wvarargs])
_APPEND_COMPILE_FLAGS_ERROR([-Warray-bounds])
_APPEND_COMPILE_FLAGS_ERROR([-Wbad-function-cast])
# Not in use -Wc++-compat
_APPEND_COMPILE_FLAGS_ERROR([-Wfloat-equal])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat=2])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wformat-y2k])
_APPEND_COMPILE_FLAGS_ERROR([-Wlogical-op])
_APPEND_COMPILE_FLAGS_ERROR([-Wmaybe-uninitialized])
_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-field-initializers])
_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-prototypes])
_APPEND_COMPILE_FLAGS_ERROR([-Wnested-externs])
_APPEND_COMPILE_FLAGS_ERROR([-Wnormalized=id])
- _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-definition])
_APPEND_COMPILE_FLAGS_ERROR([-Woverride-init])
_APPEND_COMPILE_FLAGS_ERROR([-Wpointer-arith])
_APPEND_COMPILE_FLAGS_ERROR([-Wpointer-sign])
_APPEND_COMPILE_FLAGS_ERROR([-Wstrict-overflow=1])
_APPEND_COMPILE_FLAGS_ERROR([-Wstrict-prototypes])
_APPEND_COMPILE_FLAGS_ERROR([-Wswitch-enum])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wtrampolines])
_APPEND_COMPILE_FLAGS_ERROR([-Wundef])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
+ _APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-variable])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunused-parameter])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunused-local-typedefs])
_APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
_APPEND_COMPILE_FLAGS_ERROR([-floop-parallelize-all])
_APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
[_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
#_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
#_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+ #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
])])])])
AS_IF([test "x$ax_enable_debug" = xyes],
[CXXFLAGS=''
+ _APPEND_COMPILE_FLAGS_ERROR([-H])
_APPEND_COMPILE_FLAGS_ERROR([-ggdb])
_APPEND_COMPILE_FLAGS_ERROR([-g])
_APPEND_COMPILE_FLAGS_ERROR([-O0])],
_APPEND_COMPILE_FLAGS_ERROR([-O2])])
AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
- [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
- [_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+ [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
+ [_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
+
+ AS_IF([test "$CXX" = "clang++"],
+ [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
- _APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
# Anything below this comment please keep sorted.
- _APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
# _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wvarargs])
_APPEND_COMPILE_FLAGS_ERROR([-Waddress])
_APPEND_COMPILE_FLAGS_ERROR([-Warray-bounds])
_APPEND_COMPILE_FLAGS_ERROR([-Wchar-subscripts])
_APPEND_COMPILE_FLAGS_ERROR([-Wctor-dtor-privacy])
_APPEND_COMPILE_FLAGS_ERROR([-Wfloat-equal])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat=2])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wformat-y2k])
_APPEND_COMPILE_FLAGS_ERROR([-Wmaybe-uninitialized])
_APPEND_COMPILE_FLAGS_ERROR([-Wmissing-field-initializers])
_APPEND_COMPILE_FLAGS_ERROR([-Wlogical-op])
_APPEND_COMPILE_FLAGS_ERROR([-Wsign-compare])
_APPEND_COMPILE_FLAGS_ERROR([-Wstrict-overflow=1])
_APPEND_COMPILE_FLAGS_ERROR([-Wswitch-enum])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wtrampolines])
_APPEND_COMPILE_FLAGS_ERROR([-Wundef])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
+ _APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
_APPEND_COMPILE_FLAGS_ERROR([-Wc++11-compat])
+# _APPEND_COMPILE_FLAGS_ERROR([-Weffc++])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
+# _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-cast])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-variable])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunused-parameter])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wunused-local-typedefs])
_APPEND_COMPILE_FLAGS_ERROR([-Wwrite-strings])
_APPEND_COMPILE_FLAGS_ERROR([-Wformat-security])
_APPEND_COMPILE_FLAGS_ERROR([-floop-parallelize-all])
[_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
#_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
#_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+ #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
])])])])
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 4
+#serial 5
AC_DEFUN([AX_LIBEVENT],
[AC_PREREQ([2.63])dnl
[AX_SAVE_FLAGS
LIBS="-levent $LIBS"
AC_LANG_PUSH([C])
- AC_RUN_IFELSE([AC_LANG_PROGRAM([
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/time.h>
#include <stdlib.h>
#include <event.h>
- ],[
+ ]],[[
struct event_base *tmp_event= event_init();
event_base_free(tmp_event);
- ])],
+ ]])],
[ax_cv_libevent=yes],
[ax_cv_libevent=no],
[AC_MSG_WARN([test program execution failed])])
[AX_SAVE_FLAGS
LIBS="-levent $LIBS"
AC_LANG_PUSH([C])
- AC_RUN_IFELSE([AC_LANG_PROGRAM([
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/time.h>
#include <stdlib.h>
#include <event2/event.h>
- ],[
- struct event_base *tmp_event= event_init();
- event_base_free(tmp_event);
- ])],
+ ]],[[
+ struct event_base *___event_base= event_base_new();
+ event_base_free(___event_base);
+ ]])],
[ax_cv_libevent2=yes],
[ax_cv_libevent2=no],
[AC_MSG_WARN([test program execution failed])])
[AX_SAVE_FLAGS
LIBS="-levent $LIBS"
AC_LANG_PUSH([C])
- AC_RUN_IFELSE([AC_LANG_PROGRAM([
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/time.h>
#include <stdlib.h>
#include <event2/event.h>
#include <event2/http.h>
- ],[
- struct event_base *libbase= event_base_new();
- struct evhttp *libsrvr= evhttp_new(libbase);
- ])],
+ ]],[[
+ struct event_base *___event_base= event_base_new();
+ struct evhttp *___evhttp= evhttp_new(___event_base);
+ evhttp_free(___evhttp);
+ event_base_free(___event_base);
+ ]])],
[ax_cv_libevent2_evhttp=yes],
[ax_cv_libevent2_evhttp=no],
[AC_MSG_WARN([test program execution failed])])
--- /dev/null
+# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+# ===========================================================================
+# https://github.com/BrianAker/ddm4/
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_MEMCACHED
+#
+# DESCRIPTION
+#
+# Check for memcached and list version
+#
+# LICENSE
+#
+# Copyright (C) 2013 Brian Aker
+# All rights reserved.
+#
+# 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.
+
+#serial 3
+
+AC_DEFUN([AX_PROG_MEMCACHED],
+ [AX_WITH_PROG([MEMCACHED_BINARY],[memcached])
+ AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"],
+ [AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
+ AC_DEFINE_UNQUOTED([MEMCACHED_BINARY],"$ac_cv_path_MEMCACHED_BINARY",[Name of the memcached binary used in make test])
+ ax_memcached_version=`$MEMCACHED_BINARY -h | sed 1q | awk '{print \$ 2 }' | sed 's|[\-a-z0-9]*$||' | awk -F. '{printf "%d.%d.%d", $[]1, $[]2, $[]3}'`
+ AC_MSG_RESULT([memcached version "$ax_memcached_version"])
+ AC_DEFINE_UNQUOTED([MEMCACHED_VERSION],"$ax_memcached_version",[Memcached binary version])
+ ])
+ ])
AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])],
[*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])],
[*darwin*],
- [TARGET_OSX="true"
- AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])],
+ [TARGET_OSX="true"],
[*linux*],
[TARGET_LINUX="true"
AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])])
{"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test},
{"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test},
{"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test},
+ {"MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST", true, (test_callback_fn*)MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST },
{"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY},
{0, 0, 0}
};
return TEST_SUCCESS;
}
+test_return_t MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST(memcached_st *original_memc)
+{
+ test_skip(true, memcached_behavior_get(original_memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+
+ memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL");
+ test_true(memc);
+
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 8));
+
+ keys_st keys(20480);
+
+ /* First add all of the items.. */
+ char blob[1024] = {0};
+
+ for (size_t x= 0; x < keys.size(); ++x)
+ {
+ uint64_t query_id= memcached_query_id(memc);
+ memcached_return_t rc= memcached_add(memc,
+ keys.key_at(x), keys.length_at(x),
+ blob, sizeof(blob),
+ 0, 0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
+ test_compare(query_id +1, memcached_query_id(memc));
+ }
+
+ /* Try to get all of them with a large multiget */
+ size_t counter= 0;
+ memcached_execute_fn callbacks[]= { &callback_counter };
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget_execute(memc,
+ keys.keys_ptr(), keys.lengths_ptr(),
+ keys.size(), callbacks, &counter, 1));
+
+ {
+ uint64_t query_id= memcached_query_id(memc);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
+ test_compare(query_id, memcached_query_id(memc));
+
+ /* Verify that we got all of the items */
+ test_compare(keys.size(), counter);
+ }
+
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
#define REGRESSION_BINARY_VS_BLOCK_COUNT 20480
static pairs_st *global_pairs= NULL;
{
memcached_st *memc= memcached_create(NULL);
test_true(memc);
- test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "10.2.3.4", 11211));
+ test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "10.2.251.4", 11211));
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 3000);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1000);
test_return_t memcached_stat_execute_test(memcached_st *memc);
test_return_t mget_end(memcached_st *memc);
test_return_t mget_execute(memcached_st *original_memc);
+test_return_t MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH_TEST(memcached_st *original_memc);
test_return_t mget_result_alloc_test(memcached_st *memc);
test_return_t mget_result_function(memcached_st *memc);
test_return_t mget_result_test(memcached_st *memc);
static test_return_t pre_touch(memcached_st *memc)
{
test_compare(MEMCACHED_SUCCESS, memcached_version(memc));
- test_skip(true, libmemcached_util_version_check(memc, 1, 4, 8));
+ test_skip(true, libmemcached_util_version_check(memc, 1, 4, 15));
return TEST_SUCCESS;
}
test_return_t test_memcached_touch(memcached_st *memc)
{
-
test_skip(TEST_SUCCESS, pre_touch(memc));
size_t len;
free(value);
}
- test_compare(MEMCACHED_SUCCESS,
- memcached_touch(memc, test_literal_param(__func__), 60 *60));
+ rc= memcached_touch(memc, test_literal_param(__func__), 60 *60);
+ ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
rc= memcached_touch(memc, test_literal_param(__func__), 60 *60 *24 *60);
- test_compare(MEMCACHED_SUCCESS, rc);
+ ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
- test_compare(MEMCACHED_NOTFOUND,
- memcached_exist(memc, test_literal_param(__func__)));
+ rc= memcached_exist(memc, test_literal_param(__func__));
+ ASSERT_EQ_(MEMCACHED_NOTFOUND, rc, "%s", memcached_last_error_message(memc));
return TEST_SUCCESS;
}
test_return_t test_memcached_touch_by_key(memcached_st *memc)
{
-
test_skip(TEST_SUCCESS, pre_touch(memc));
size_t len;
free(value);
}
- test_compare(MEMCACHED_SUCCESS,
- memcached_touch_by_key(memc,
- test_literal_param("grouping_key"),
- test_literal_param(__func__),
- 60 *60));
+ rc= memcached_touch_by_key(memc,
+ test_literal_param("grouping_key"),
+ test_literal_param(__func__),
+ 60 *60);
+ ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
- test_compare(MEMCACHED_SUCCESS,
- memcached_touch_by_key(memc,
- test_literal_param("grouping_key"),
- test_literal_param(__func__),
- 60 *60 *24 *60));
- test_compare(MEMCACHED_NOTFOUND,
- memcached_exist_by_key(memc, test_literal_param("grouping_key"),test_literal_param(__func__)));
+ rc= memcached_touch_by_key(memc,
+ test_literal_param("grouping_key"),
+ test_literal_param(__func__),
+ 60 *60 *24 *60);
+ ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
+
+ rc= memcached_exist_by_key(memc, test_literal_param("grouping_key"),test_literal_param(__func__));
+ ASSERT_EQ_(MEMCACHED_NOTFOUND, rc, "%s", memcached_last_error_message(memc));
return TEST_SUCCESS;
}
size_t vlen;
Expected expected_ids;
get_udp_request_ids(memc, expected_ids);
- test_null(memcached_get(memc, test_literal_param("foo"), &vlen, (uint32_t)0, &rc));
+ test_null(memcached_get(memc, test_literal_param("foo"), &vlen, NULL, &rc));
test_compare(MEMCACHED_NOT_SUPPORTED, rc);
return post_udp_op_check(memc, expected_ids);