## 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
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"
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
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)
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();
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,
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);
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;
{
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;
/* 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;
{
memcached_string_st *string;
- string= memcached_string_create(memc, 1024*100000000000);
+ string= memcached_string_create(memc, UINT64_MAX);
assert(string == NULL);
}
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);
}