#include "poll/poll.h"
#endif
-#include <assert.h>
+#include <cassert>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pthread.h>
#include <signal.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include <unistd.h>
*
*/
-#include "config.h"
+#include <config.h>
+#include <cstdio>
+#include <cstring>
+#include <getopt.h>
#include <iostream>
-#include <stdio.h>
-#include <inttypes.h>
-#include <string.h>
#include <unistd.h>
-#include <getopt.h>
#include <libmemcached/memcached.h>
#include "utilities.h"
#include "config.h"
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <unistd.h>
+#include <cerrno>
+#include <climits>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdlib>
+#include <cstring>
+#include <fcntl.h>
#include <getopt.h>
-#include <sys/types.h>
+#include <iostream>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <strings.h>
-#include <string.h>
#include <sys/types.h>
-#include <stdlib.h>
-#include <limits.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <libmemcached/memcached.h>
#include <config.h>
#include <cstdio>
+#include <cstring>
#include <iostream>
#include <libmemcached/memcached.h>
#include <sys/types.h>
#include <unistd.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
#include <libmemcached/memcached.h>
#include <libmemcached/watchpoint.h>
#include <libmemcached/is.h>
return MEMCACHED_SUCCESS;
}
+extern "C" {
+
static void sasl_shutdown_function()
{
sasl_done();
}
-static int sasl_startup_state= SASL_OK;
+static volatile int sasl_startup_state= SASL_OK;
+pthread_mutex_t sasl_startup_state_LOCK= PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t sasl_startup_once= PTHREAD_ONCE_INIT;
static void sasl_startup_function(void)
{
}
}
+} // extern "C"
+
memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *server)
{
if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
return memcached_set_errno(*server, pthread_error, MEMCACHED_AT);
}
+ (void)pthread_mutex_lock(&sasl_startup_state_LOCK);
if (sasl_startup_state != SASL_OK)
{
const char *sasl_error_msg= sasl_errstring(sasl_startup_state, NULL, NULL);
return memcached_set_error(*server, MEMCACHED_AUTH_PROBLEM, MEMCACHED_AT,
memcached_string_make_from_cstr(sasl_error_msg));
}
+ (void)pthread_mutex_unlock(&sasl_startup_state_LOCK);
sasl_conn_t *conn;
int ret;
#pragma once
+#ifndef WIN32
+#include <netdb.h>
+#endif
+
enum memcached_server_state_t {
MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
static test_return_t test_success_equals_one_test(void *)
{
test_skip(HAVE_LIBMEMCACHED, true);
+#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
test_zero(MEMCACHED_SUCCESS);
+#endif
return TEST_SUCCESS;
}
static test_return_t _compare_memcached_return_t_test(void *)
{
test_skip(HAVE_LIBMEMCACHED, true);
+#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
test_compare(MEMCACHED_SUCCESS, MEMCACHED_SUCCESS);
+#endif
return TEST_SUCCESS;
}
static test_return_t _compare_gearman_return_t_test(void *)
{
test_skip(HAVE_LIBGEARMAN, true);
+#if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN
+ test_compare(GEARMAN_SUCCESS, GEARMAN_SUCCESS);
+#endif
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
+static test_return_t binary_increment_with_prefix_test(memcached_st *orig_memc)
+{
+ memcached_st *memc= memcached_clone(NULL, orig_memc);
+
+ test_skip(TEST_SUCCESS, pre_binary(memc));
+
+ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)"namespace:"));
+
+ memcached_return_t rc;
+ rc= memcached_set(memc,
+ test_literal_param("number"),
+ test_literal_param("0"),
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+
+ uint64_t new_number;
+ test_compare(MEMCACHED_SUCCESS, memcached_increment(memc,
+ test_literal_param("number"),
+ 1, &new_number));
+ test_compare(uint64_t(1), new_number);
+
+ test_compare(MEMCACHED_SUCCESS, memcached_increment(memc,
+ test_literal_param("number"),
+ 1, &new_number));
+ test_compare(uint64_t(2), new_number);
+
+ return TEST_SUCCESS;
+}
static test_return_t quit_test(memcached_st *memc)
{
{"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
{"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
{"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test },
+ {"binary_increment_with_prefix", 1, (test_callback_fn*)binary_increment_with_prefix_test },
{"quit", false, (test_callback_fn*)quit_test },
{"mget", true, (test_callback_fn*)mget_test },
{"mget_result", true, (test_callback_fn*)mget_result_test },