From 099d030487cb45bb61af17b07ae4361b8a3ea8c6 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 3 May 2013 04:44:02 -0400 Subject: [PATCH] Fix for memcapable (it should not be looking at the local server automatically) --- clients/memcapable.cc | 15 +++++++++++---- libmemcached-1.0/defaults.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/clients/memcapable.cc b/clients/memcapable.cc index f9145206..3e9bfabf 100644 --- a/clients/memcapable.cc +++ b/clients/memcapable.cc @@ -186,8 +186,9 @@ static memcached_socket_t connect_server(const char *hostname, const char *port) } } else - fprintf(stderr, "Failed to create socket: %s\n", - strerror(get_socket_errno())); + { + fprintf(stderr, "Failed to create socket: %s\n", strerror(get_socket_errno())); + } freeaddrinfo(ai); } @@ -2078,8 +2079,8 @@ int main(int argc, char **argv) struct test_type_st tests= { true, true }; int total= 0; int failed= 0; - const char *hostname= "localhost"; - const char *port= "11211"; + const char *hostname= NULL; + const char *port= MEMCACHED_DEFAULT_PORT_STRING; int cmd; bool prompt= false; const char *testname= NULL; @@ -2147,6 +2148,12 @@ int main(int argc, char **argv) } } + if (hostname) + { + fprintf(stderr, "No hostname was provided.\n"); + return EXIT_FAILURE; + } + initialize_sockets(); sock= connect_server(hostname, port); if (sock == INVALID_SOCKET) diff --git a/libmemcached-1.0/defaults.h b/libmemcached-1.0/defaults.h index 38c29ba3..177e18cf 100644 --- a/libmemcached-1.0/defaults.h +++ b/libmemcached-1.0/defaults.h @@ -40,6 +40,7 @@ /* Public defines */ #define MEMCACHED_DEFAULT_PORT 11211 +#define MEMCACHED_DEFAULT_PORT_STRING "11211" #define MEMCACHED_POINTS_PER_SERVER 100 #define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 #define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */ -- 2.30.2