+ACLOCAL_AMFLAGS = -I config
INCLUDES =
SUBDIRS = docs libmemcached libmemcachedutil tests support clients
EXTRA_dist = README.FIRST
Return the number of rows set.
*/
-#include <stdio.h>
+#include "libmemcached/common.h"
+
#include "execute.h"
unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
+#include "libmemcached/common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include "libmemcached/common.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
--- /dev/null
+# serial 6 -*- Autoconf -*-
+# Enable extensions on systems that normally disable them.
+
+# Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
+# Autoconf. Perhaps we can remove this once we can assume Autoconf
+# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
+# enough in this area it's likely we'll need to redefine
+# AC_USE_SYSTEM_EXTENSIONS for quite some time.
+
+# AC_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+# Remember that #undef in AH_VERBATIM gets replaced with #define by
+# AC_DEFINE. The goal here is to define all known feature-enabling
+# macros, then, if reports of conflicts are made, disable macros that
+# cause problems on some platforms (such as __EXTENSIONS__).
+AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
+[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
+ if test "$MINIX" = yes; then
+ AC_DEFINE([_POSIX_SOURCE], [1],
+ [Define to 1 if you need to in order for `stat' and other
+ things to work.])
+ AC_DEFINE([_POSIX_1_SOURCE], [2],
+ [Define to 2 if the system does not provide POSIX.1 features
+ except with this defined.])
+ AC_DEFINE([_MINIX], [1],
+ [Define to 1 if on MINIX.])
+ fi
+
+ dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
+ dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
+ dnl provided.
+ case "$host_os" in
+ hpux*)
+ AC_DEFINE([_XOPEN_SOURCE], [500],
+ [Define to 500 only on HP-UX.])
+ ;;
+ esac
+
+ AH_VERBATIM([__EXTENSIONS__],
+[/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+])
+ AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
+ [ac_cv_safe_to_define___extensions__],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+# define __EXTENSIONS__ 1
+ ]AC_INCLUDES_DEFAULT])],
+ [ac_cv_safe_to_define___extensions__=yes],
+ [ac_cv_safe_to_define___extensions__=no])])
+ test $ac_cv_safe_to_define___extensions__ = yes &&
+ AC_DEFINE([__EXTENSIONS__])
+ AC_DEFINE([_ALL_SOURCE])
+ AC_DEFINE([_GNU_SOURCE])
+ AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
+ AC_DEFINE([_TANDEM_SOURCE])
+])# AC_USE_SYSTEM_EXTENSIONS
+
+# gl_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],
+ [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])])
VERSION=$MEMCACHED_RELEASE
AM_INIT_AUTOMAKE($PACKAG$, $VERSION, nostdinc no-define -Wall -Werror)
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CC_C99
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(floorf, m)
+
sinclude(config/pod2man.m4)
sinclude(config/debug.m4)
sinclude(config/dtrace.m4)
sinclude(config/hsieh.m4)
sinclude(config/util.m4)
+dnl This is likely subverted by vpath builds. How do we find the original
+dnl source dir in the configure step of a vpath build?
+if test -d ".hg"
+then
+ building_from_hg=yes
+else
+ building_from_hg=no
+fi
+
# We only support GCC and Sun's forte at the moment
if test "$GCC" = "yes"
then
- #CFLAGS="-W -std=iso9899:1999 -Wall -Wextra -Wstrict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -O3 $CFLAGS"
- CFLAGS="-W -Wall -Wextra -Wno-strict-aliasing -pedantic -Werror -O3 -ggdb $CFLAGS"
+ if test "$building_from_hg" = "yes"
+ then
+ CFLAGS="-Werror $CFLAGS"
+ CXXFLAGS="-Werror $CXXFLAGS"
+ fi
+
+ CFLAGS="-W -std=iso9899:1999 -Wall -Wextra -Wno-strict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -O3 -ggdb $CFLAGS"
+ CXXFLAGS="-W -Wall -Wextra -Wno-strict-aliasing -pedantic -Wundef -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wconversion -Wmissing-declarations -Wredundant-decls -O3 -ggdb $CXXFLAGS"
if test "$ENABLE_DEBUG" = "yes"
then
*/
+#include "common.h"
+
#include <string.h>
#include <sys/types.h>
public:
- Memcached()
+ Memcached() : memc(), result()
{
memcached_create(&memc);
}
- Memcached(memcached_st *clone)
+ Memcached(memcached_st *clone) : memc(), result()
{
memcached_clone(&memc, clone);
}
{
return memcached_set(&memc, key, strlen(key),
value, value_length,
- (time_t)0, (uint32_t)0);
+ time_t(0), uint32_t(0));
}
memcached_return set_by_key(const char *master_key, const char *key,
return memcached_set_by_key(&memc, master_key, strlen(master_key),
key, strlen(key),
value, value_length,
- (time_t)0,
- (uint32_t)0 );
+ time_t(0),
+ uint32_t(0) );
}
memcached_return
increment(const char *key, unsigned int offset, uint64_t *value)
memcached_return add(const char *key, const char *value, size_t value_length)
{
- return memcached_add(&memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
+ return memcached_add(&memc, key, strlen(key), value, value_length, 0, 0);
}
memcached_return add_by_key(const char *master_key, const char *key,
const char *value, size_t value_length)
return memcached_add_by_key(&memc, master_key, strlen(master_key),
key, strlen(key),
value, value_length,
- (time_t)0, (uint32_t)0);
+ 0, 0);
}
memcached_return replace(const char *key, const char *value,
{
return memcached_replace(&memc, key, strlen(key),
value, value_length,
- (time_t)0, (uint32_t)0);
+ 0, 0);
}
memcached_return replace_by_key(const char *master_key, const char *key,
const char *value, size_t value_length)
{
return memcached_replace_by_key(&memc, master_key, strlen(master_key),
key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
+ value, value_length, 0, 0);
}
memcached_return prepend(const char *key, const char *value,
size_t value_length)
{
return memcached_prepend(&memc, key, strlen(key),
- value, value_length,
- (time_t)0,
- (uint32_t)0);
+ value, value_length, 0, 0);
}
memcached_return prepend_by_key(const char *master_key, const char *key,
const char *value, size_t value_length)
return memcached_prepend_by_key(&memc, master_key, strlen(master_key),
key, strlen(key),
value, value_length,
- (time_t)0,
- (uint32_t)0);
+ 0,
+ 0);
}
memcached_return append(const char *key, const char *value,
size_t value_length)
{
return memcached_append(&memc, key, strlen(key),
- value, value_length,
- (time_t)0,
- (uint32_t)0);
+ value, value_length, 0, 0);
}
memcached_return append_by_key(const char *master_key, const char *key,
const char *value, size_t value_length)
return memcached_append_by_key(&memc,
master_key, strlen(master_key),
key, strlen(key),
- value, value_length,
- (time_t)0,
- (uint32_t)0);
+ value, value_length, 0, 0);
}
memcached_return cas(const char *key, const char *value,
size_t value_length, uint64_t cas)
{
return memcached_cas(&memc, key, strlen(key),
- value, value_length,
- (time_t)0,
- (uint32_t)0,
- cas);
+ value, value_length, 0, 0, cas);
}
memcached_return cas_by_key(const char *master_key, const char *key,
const char *value, size_t value_length,
master_key, strlen(master_key),
key, strlen(key),
value, value_length,
- (time_t)0,
- (uint32_t)0,
- cas);
+ 0, 0, cas);
}
// using 'remove' vs. 'delete' since 'delete' is a keyword
memcached_return remove(const char *key)
{
- return memcached_delete (&memc, key, strlen(key), (time_t)0);
+ return memcached_delete (&memc, key, strlen(key), 0);
}
memcached_return delete_by_key(const char *master_key, const char *key)
{
return memcached_delete_by_key(&memc, master_key, strlen(master_key),
- key, strlen(key), (time_t)0);
+ key, strlen(key), 0);
}
~Memcached()
{
/*
Sample test application.
*/
+#include "libmemcached/common.h"
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "server.h"
-#include "../libmemcached/common.h"
#include "../clients/generator.h"
#include "../clients/execute.h"
/*
Sample test application.
*/
+#include "libmemcached/common.h"
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "server.h"
-#include "../clients/generator.h"
-#include "../clients/execute.h"
+#include "clients/generator.h"
+#include "clients/execute.h"
#ifndef INT64_MAX
#define INT64_MAX LONG_MAX
From Andrei on IRC
*/
-test_return user_supplied_bug19(memcached_st *memc)
+static test_return user_supplied_bug19(memcached_st *memc)
{
memcached_st *m;
memcached_server_st *s;
}
/* CAS test from Andei */
-test_return user_supplied_bug20(memcached_st *memc)
+static test_return user_supplied_bug20(memcached_st *memc)
{
memcached_return status;
memcached_result_st *result, result_obj;
}
#include "ketama_test_cases.h"
-test_return user_supplied_bug18(memcached_st *trash)
+static test_return user_supplied_bug18(memcached_st *trash)
{
memcached_return rc;
int value;
return 0;
}
-test_return auto_eject_hosts(memcached_st *trash)
+static test_return auto_eject_hosts(memcached_st *trash)
{
(void) trash;
return post_udp_op_check(memc,expected_ids);
}
-test_return udp_delete_test(memcached_st *memc)
+static test_return udp_delete_test(memcached_st *memc)
{
unsigned int x= 0;
unsigned int num_iters= 1025; //request id rolls over at 1024
return udp_delete_test(memc);
}
-test_return udp_verbosity_test(memcached_st *memc)
+static test_return udp_verbosity_test(memcached_st *memc)
{
memcached_return rc;
uint16_t *expected_ids= get_udp_request_ids(memc);
return post_udp_op_check(memc,expected_ids);
}
-test_return udp_quit_test(memcached_st *memc)
+static test_return udp_quit_test(memcached_st *memc)
{
uint16_t *expected_ids= get_udp_request_ids(memc);
memcached_quit(memc);
return post_udp_op_check(memc, expected_ids);
}
-test_return udp_flush_test(memcached_st *memc)
+static test_return udp_flush_test(memcached_st *memc)
{
memcached_return rc;
uint16_t *expected_ids= get_udp_request_ids(memc);
return post_udp_op_check(memc,expected_ids);
}
-test_return udp_incr_test(memcached_st *memc)
+static test_return udp_incr_test(memcached_st *memc)
{
memcached_return rc;
char *key= "incr";
return post_udp_op_check(memc, expected_ids);
}
-test_return udp_decr_test(memcached_st *memc)
+static test_return udp_decr_test(memcached_st *memc)
{
memcached_return rc;
char *key= "decr";
}
-test_return udp_stat_test(memcached_st *memc)
+static test_return udp_stat_test(memcached_st *memc)
{
memcached_stat_st * rv= NULL;
memcached_return rc;
return post_udp_op_check(memc, expected_ids);
}
-test_return udp_version_test(memcached_st *memc)
+static test_return udp_version_test(memcached_st *memc)
{
memcached_return rc;
uint16_t *expected_ids = get_udp_request_ids(memc);
return post_udp_op_check(memc, expected_ids);
}
-test_return udp_get_test(memcached_st *memc)
+static test_return udp_get_test(memcached_st *memc)
{
memcached_return rc;
char *key= "foo";
return post_udp_op_check(memc, expected_ids);
}
-test_return udp_mixed_io_test(memcached_st *memc)
+static test_return udp_mixed_io_test(memcached_st *memc)
{
test_st current_op;
test_st mixed_io_ops [] ={
return TEST_SUCCESS;
}
-test_return hsieh_avaibility_test (memcached_st *memc)
+static test_return hsieh_avaibility_test (memcached_st *memc)
{
memcached_return expected_rc= MEMCACHED_FAILURE;
#ifdef HAVE_HSIEH_HASH
#include "test.h"
-extern "C" test_return basic_test(memcached_st *memc)
+extern "C" {
+ test_return basic_test(memcached_st *memc);
+ uint8_t increment_test(memcached_st *memc);
+ test_return basic_master_key_test(memcached_st *memc);
+ void *world_create(void);
+ void world_destroy(void *p);
+}
+
+test_return basic_test(memcached_st *memc)
{
Memcached foo(memc);
const char *value_set= "This is some data";
return TEST_SUCCESS;
}
-extern "C" uint8_t increment_test(memcached_st *memc)
+uint8_t increment_test(memcached_st *memc)
{
Memcached mcach(memc);
memcached_return rc;
return 0;
}
-extern "C" test_return basic_master_key_test(memcached_st *memc)
+test_return basic_master_key_test(memcached_st *memc)
{
Memcached foo(memc);
const char *value_set= "Data for server A";
return construct;
}
-extern "C" void world_destroy(void *p)
+void world_destroy(void *p)
{
- server_startup_st *construct= (server_startup_st *)p;
- memcached_server_st *servers= (memcached_server_st *)construct->servers;
+ server_startup_st *construct= static_cast<server_startup_st *>(p);
+ memcached_server_st *servers=
+ static_cast<memcached_server_st *>(construct->servers);
memcached_server_list_free(servers);
server_shutdown(construct);
#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
+#include "libmemcached/libmemcached_config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
+#include <signal.h>
#include <libmemcached/memcached.h>
#include <unistd.h>
-#include "libmemcached/libmemcached_config.h"
#include "server.h"
void server_startup(server_startup_st *construct)
int count;
int status;
+ sprintf(buffer, "/tmp/%umemc.pid", x);
+ if (access(buffer, F_OK) == 0)
+ {
+ FILE *fp= fopen(buffer, "r");
+ remove(buffer);
+
+ if (fp != NULL)
+ {
+ if (fgets(buffer, sizeof(buffer), fp) != NULL)
+ {
+ pid_t pid = atol(buffer);
+ if (pid != 0)
+ kill(pid, SIGTERM);
+ }
+
+ fclose(fp);
+ }
+ }
+
if (x == 0)
{
sprintf(buffer, "%s -d -P /tmp/%umemc.pid -t 1 -p %u -U %u -m 128",
char buffer[1024]; /* Nothing special for number */
sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x);
system(buffer);
-
sprintf(buffer, "/tmp/%umemc.pid", x);
unlink(buffer);
}