From: Date: Thu, 25 Oct 2007 18:00:04 +0000 (-0700) Subject: Updated to build on OSX (will now require updated autoconf) X-Git-Tag: 0_7~12 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=375ad7d822a4bbc121a79ce7e927385d6be7f754;p=m6w6%2Flibmemcached Updated to build on OSX (will now require updated autoconf) New --enable-debug option for configure WATCHPOINT are now compiled out (so safe to leave in code). Cleaned up case in connect where wrong answer might be sent. Cleaned up warnings in code around variable which might not have been initialized. Fixed usert test 3 (aka it was not using memory correctly) --- diff --git a/config/bootstrap b/config/bootstrap index ab2e114a..cc463d86 100755 --- a/config/bootstrap +++ b/config/bootstrap @@ -24,11 +24,11 @@ run() { ## jump out if one of the programs returns 'false' set -e -## on macosx glibtoolize, others have libtool +## We do not currently support glibtoolize if test x$LIBTOOLIZE = x; then - if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then - LIBTOOLIZE=glibtoolize - elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then +# if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then +# LIBTOOLIZE=glibtoolize + if test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then LIBTOOLIZE=libtoolize-1.5 elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then LIBTOOLIZE=libtoolize diff --git a/configure.in b/configure.in index b6b849d4..7a95f8cb 100644 --- a/configure.in +++ b/configure.in @@ -8,12 +8,18 @@ AC_PROG_LIBTOOL LIBTOOL="$LIBTOOL --preserve-dup-deps" AC_SUBST(LIBTOOL)dnl +sinclude(config/debug.m4) sinclude(config/dtrace.m4) # We only support GCC and Sun's forte at the moment if test "$GCC" = "yes" then - CFLAGS="-Wall -ggdb" + if test "$ENABLE_DEBUG" = "yes" + then + CFLAGS="-Wall -ggdb" + else + CFLAGS="-Wall -O3" + fi else CFLAGS="-Xa -xstrconst -mt -D_FORTEC_ -fast -m64" LDFLAGS="-lsocket -lnsl" diff --git a/include/memcached.h b/include/memcached.h index 64afedc0..d8d471a8 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -211,11 +211,19 @@ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat, memcached_return *error); /* Some personal debugging functions */ +#ifdef HAVE_DEBUG #define WATCHPOINT printf("\nWATCHPOINT %s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout); #define WATCHPOINT_ERROR(A) printf("\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); #define WATCHPOINT_STRING(A) printf("\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); #define WATCHPOINT_NUMBER(A) printf("\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); #define WATCHPOINT_ERRNO(A) printf("\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));A= 0;fflush(stdout); +#else +#define WATCHPOINT +#define WATCHPOINT_ERROR(A) +#define WATCHPOINT_STRING(A) +#define WATCHPOINT_NUMBER(A) +#define WATCHPOINT_ERRNO(A) +#endif #ifdef __cplusplus diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index 34613ddd..abf15676 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -95,7 +95,7 @@ test_connect: memcached_return memcached_connect(memcached_st *ptr, unsigned int server_key) { - memcached_return rc; + memcached_return rc= MEMCACHED_NO_SERVERS; LIBMEMCACHED_MEMCACHED_CONNECT_START(); if (ptr->connected == ptr->number_of_hosts) @@ -112,7 +112,15 @@ memcached_return memcached_connect(memcached_st *ptr, unsigned int server_key) unsigned int x; for (x= 0; x < ptr->number_of_hosts; x++) - rc= memcached_real_connect(ptr, x); + { + memcached_return possible_rc; + + possible_rc= memcached_real_connect(ptr, x); + rc= MEMCACHED_SUCCESS; + + if (possible_rc != MEMCACHED_SUCCESS) + rc= MEMCACHED_SOME_ERRORS; + } } LIBMEMCACHED_MEMCACHED_CONNECT_END(); diff --git a/lib/memcached_get.c b/lib/memcached_get.c index 8b85fb9a..3ddeff88 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -125,6 +125,9 @@ read_error: return NULL; } +/* + What happens if no servers exist? +*/ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, size_t *value_length, uint16_t *flags, @@ -133,7 +136,7 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; char *buf_ptr= buffer; unsigned int server_key; - char *value; + char *value= NULL; LIBMEMCACHED_MEMCACHED_GET_START(); server_key= memcached_generate_hash(ptr, key, key_length); @@ -198,19 +201,18 @@ memcached_return memcached_mget(memcached_st *ptr, char **keys, size_t *key_length, unsigned int number_of_keys) { - char buffer[HUGE_STRING_LEN]; unsigned int x; - memcached_return rc; + memcached_return rc= MEMCACHED_NOTFOUND; char *cursor_key_exec; LIBMEMCACHED_MEMCACHED_MGET_START(); - ptr->cursor_server= 0; - memset(buffer, 0, HUGE_STRING_LEN); + + if (number_of_keys == 0) + return MEMCACHED_NOTFOUND; cursor_key_exec= (char *)malloc(sizeof(char) * ptr->number_of_hosts); memset(cursor_key_exec, 0, sizeof(char) * ptr->number_of_hosts); - for (x= 0; x < number_of_keys; x++) { unsigned int server_key; diff --git a/lib/memcached_string.c b/lib/memcached_string.c index b79fc161..47dac67e 100644 --- a/lib/memcached_string.c +++ b/lib/memcached_string.c @@ -76,15 +76,20 @@ memcached_return memcached_string_append(memcached_st *ptr, memcached_string_st { memcached_return rc; + WATCHPOINT; rc= memcached_string_check(string, length); + WATCHPOINT; if (rc != MEMCACHED_SUCCESS) return rc; + WATCHPOINT; assert(string->string); assert(string->end >= string->string && string->end <= string->string + string->current_size); + WATCHPOINT; memcpy(string->end, value, length); + WATCHPOINT; string->end+= length; return MEMCACHED_SUCCESS; diff --git a/tests/test.c b/tests/test.c index 60c6211a..7a0919fb 100644 --- a/tests/test.c +++ b/tests/test.c @@ -641,7 +641,7 @@ void user_supplied_bug3(memcached_st *memc) /* Turn this into a help function */ { - char *return_key; + char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *return_value; size_t return_value_length; @@ -683,7 +683,7 @@ void string_alloc_with_size_toobig(memcached_st *memc) { memcached_string_st *string; - string= memcached_string_create(memc, 1024*100000000000); + string= memcached_string_create(memc, UINT64_MAX); assert(string == NULL); } @@ -726,7 +726,9 @@ void string_alloc_append_toobig(memcached_st *memc) rc= memcached_string_append(memc, string, buffer, SMALL_STRING_LEN); assert(rc == MEMCACHED_SUCCESS); } - rc= memcached_string_append(memc, string, buffer, 1024*100000000000); + WATCHPOINT; + rc= memcached_string_append(memc, string, buffer, UINT64_MAX); + WATCHPOINT; assert(rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE); memcached_string_free(memc, string); }