0.41
* Added --file for memcat.
+ * Added limemcached_ping() to libmemcached_util
0.40 Thu Apr 22 19:01:25 PDT 2010
* Placed retry logic in for busted resolvers
if BUILD_LIBMEMCACHEDUTIL
nobase_include_HEADERS+= \
libmemcached/memcached_util.h \
+ libmemcached/util/ping.h \
libmemcached/util/pool.h
lib_LTLIBRARIES+= libmemcached/libmemcachedutil.la
endif
-libmemcached_libmemcachedutil_la_SOURCES= libmemcached/util/pool.c
+libmemcached_libmemcachedutil_la_SOURCES= \
+ libmemcached/util/ping.c \
+ libmemcached/util/pool.c
libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0
libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
*
* Summary: Connection pool library.
*
- * Author: Trond Norbye
+ * Author: Trond Norbye, Brian Aker
*
*/
#ifndef __LIBMEMCACHED__MEMCACHED_UTIL_H__
#define __LIBMEMCACHED__MEMCACHED_UTIL_H__
+#include <libmemcached/util/ping.h>
#include <libmemcached/util/pool.h>
#endif /* __LIBMEMCACHED__MEMCACHED_UTIL_H__ */
+/* LibMemcached
+ * Copyright (C) 2010 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ * Summary: connects to a host, and makes sure it is alive.
+ *
+ */
+
/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
#include "libmemcached/common.h"
#include "libmemcached/memcached_util.h"
char *hostname = memc->hosts[server_idx].hostname;
in_port_t port = memc->hosts[server_idx].port;
fprintf(fp, "key %s is on host /%s:%u\n", key, hostname, port);
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, host_index);
}
fclose(fp);
#endif
test_true(memcached_pool_destroy(pool) == memc);
return TEST_SUCCESS;
}
+
+static test_return_t ping_test(memcached_st *memc)
+{
+ memcached_return_t rc;
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, 0);
+
+ // Test both the version that returns a code, and the one that does not.
+ test_true(libmemcached_ping(memcached_server_name(instance),
+ memcached_server_port(instance), NULL));
+
+ test_true(libmemcached_ping(memcached_server_name(instance),
+ memcached_server_port(instance), &rc));
+
+ test_true(rc == MEMCACHED_SUCCESS);
+
+ return TEST_SUCCESS;
+}
#endif
static test_return_t replication_set_test(memcached_st *memc)
{"analyzer", 1, (test_callback_fn)analyzer_test},
#ifdef HAVE_LIBMEMCACHEDUTIL
{"connectionpool", 1, (test_callback_fn)connection_pool_test },
+ {"ping", 1, (test_callback_fn)ping_test },
#endif
{"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect},
{"verbosity", 1, (test_callback_fn)test_verbosity},
#define test_fail(A) \
do \
{ \
- fprintf(stderr, "\nFailed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
- create_core(); \
- return TEST_FAILURE; \
+ if (1) { \
+ fprintf(stderr, "\nFailed in %s:%d: %s\n", __FILE__, __LINE__, #A);\
+ create_core(); \
+ return TEST_FAILURE; \
+ } \
} while (0)
#define test_true(A) \