aclocal.m4
autom4te.cache
autoscan.log
+build-aux/
clients/memaslap
clients/memcapable
clients/memcat
libtest/version.h
libtest/wait
libtool
+m4/.git
m4/libtool.m4
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
+man/*.1
+man/*.3
+man/*.8
memcached/.git
memcached/.gitignore
memcached/memcached
tests/var/
tmp_chroot
unittests/unittests
-m4/.git
-man/*.1
-man/*.3
-man/*.8
+1.0.12
+* Added memcached_result_take_value().
+
1.0.11 Sun Sep 16 20:32:13 EDT 2012
* Removed custom version of memcached.
* Updated hardening rules.
$@ $ARGS
}
+parse_command_line_options() {
+
+ if ! options=$(getopt -o c --long configure -n 'bootstrap' -- "$@"); then
+ exit 1
+ fi
+
+ eval set -- "$options"
+
+ while [ $# -gt 0 ]; do
+ case $1 in
+ -c | --configure )
+ CONFIGURE_OPTION="yes" ; shift;;
+ -- )
+ shift; break;;
+ -* )
+ echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
+ *)
+ break;;
+ esac
+ done
+}
+
+
+
bootstrap() {
+ parse_command_line_options $@
determine_target_platform
if [ -d .git ]; then
run $AUTORECONF $AUTORECONF_FLAGS || die "Cannot execute $AUTORECONF $AUTORECONF_FLAGS"
configure_target_platform
+
+ if [ "$CONFIGURE_OPTION" == "yes" ]; then
+ exit
+ fi
# Backwards compatibility
if [ -n "$VALGRIND" ]; then
export -n VCS_CHECKOUT
export -n PLATFORM
export -n TARGET_PLATFORM
+CONFIGURE_OPTION=no
VCS_CHECKOUT=
PLATFORM=unknown
TARGET_PLATFORM=unknown
-bootstrap
+bootstrap $@
[AC_MSG_WARN([Unable to find libevent])])
AM_CONDITIONAL(HAVE_LIBEVENT, test "x${ax_cv_have_LIBEVENT}" = "xyes")
-AX_CHECK_SOCK_CLOEXEC([AC_DEFINE([HAVE_SOCK_CLOEXEC], [1], [Check for SOCK_CLOEXEC.])],
- [AC_DEFINE([HAVE_SOCK_CLOEXEC], [0], [Check for SOCK_CLOEXEC.])])
-
AX_UUID_GENERATE_TIME_SAFE
.. c:function:: const char *memcached_result_value (memcached_result_st *ptr)
+.. c:function:: char *memcached_result_take_value (memcached_result_st *ptr)
+
.. c:function:: size_t memcached_result_length (const memcached_result_st *ptr)
.. c:function:: uint32_t memcached_result_flags (const memcached_result_st *result)
:c:func:`memcached_result_value` returns the result value associated with the
current result object.
+:c:func:`memcached_result_take_value` returns and hands over the result value
+associated with the current result object. You must call free() to release this
+value, unless you have made use of a custom allocator. Use of a custom
+allocator requires that you create your own custom free() to release it.
+
:c:func:`memcached_result_length` returns the result length associated with
the current result object.
LIBMEMCACHED_API
const char *memcached_result_value(const memcached_result_st *self);
+LIBMEMCACHED_API
+char *memcached_result_take_value(memcached_result_st *self);
+
LIBMEMCACHED_API
size_t memcached_result_length(const memcached_result_st *self);
#include <sys/time.h>
#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC 0
+# define SOCK_CLOEXEC 0
+#endif
+
+#ifndef SOCK_NONBLOCK
+# define SOCK_NONBLOCK 0
+#endif
+
+#ifndef FD_CLOEXEC
+# define FD_CLOEXEC 0
#endif
static memcached_return_t connect_poll(org::libmemcached::Instance* server)
#else
int flags;
- do
- {
- flags= fcntl(server->fd, F_GETFL, 0);
- } while (flags == -1 && (errno == EINTR || errno == EAGAIN));
-
- if (flags == -1)
- {
- memcached_set_errno(*server, errno, NULL);
- }
- else if ((flags & O_NONBLOCK) == 0)
+ if (SOCK_NONBLOCK == 0)
{
- int rval;
-
do
{
- rval= fcntl(server->fd, F_SETFL, flags | O_NONBLOCK);
- } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
+ flags= fcntl(server->fd, F_GETFL, 0);
+ } while (flags == -1 && (errno == EINTR || errno == EAGAIN));
- if (rval == -1)
+ if (flags == -1)
{
memcached_set_errno(*server, errno, NULL);
}
+ else if ((flags & O_NONBLOCK) == 0)
+ {
+ int rval;
+
+ do
+ {
+ rval= fcntl(server->fd, F_SETFL, flags | O_NONBLOCK);
+ } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
+
+ if (rval == -1)
+ {
+ memcached_set_errno(*server, errno, NULL);
+ }
+ }
}
#endif
}
assert(error == 0);
}
-
/* libmemcached will always use nonblocking IO to avoid write deadlocks */
set_socket_nonblocking(server);
}
#ifndef WIN32
WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET);
- if ((server->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+ int type= SOCK_STREAM;
+ if (SOCK_CLOEXEC)
+ {
+ type|= SOCK_CLOEXEC;
+ }
+
+ if (SOCK_NONBLOCK)
+ {
+ type|= SOCK_NONBLOCK;
+ }
+
+ if ((server->fd= socket(AF_UNIX, type, 0)) < 0)
{
memcached_set_errno(*server, errno, NULL);
return MEMCACHED_CONNECTION_FAILURE;
}
int type= server->address_info_next->ai_socktype;
- if (HAVE_SOCK_CLOEXEC)
+ if (SOCK_CLOEXEC)
{
type|= SOCK_CLOEXEC;
}
+ if (SOCK_NONBLOCK)
+ {
+ type|= SOCK_NONBLOCK;
+ }
+
if ((server->fd= socket(server->address_info_next->ai_family,
type,
server->address_info_next->ai_protocol)) < 0)
return memcached_set_errno(*server, get_socket_errno(), NULL);
}
- if (HAVE_SOCK_CLOEXEC == 0)
+ // If SOCK_CLOEXEC exists then we don't need to call the following
+ if (SOCK_CLOEXEC == 0)
{
-#ifdef FD_CLOEXEC
- int rval;
- do
+ if (FD_CLOEXEC)
{
- rval= fcntl (server->fd, F_SETFD, FD_CLOEXEC);
- } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
-#endif
+ int rval;
+ do
+ {
+ rval= fcntl (server->fd, F_SETFD, FD_CLOEXEC);
+ } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
+ }
}
set_socket_options(server);
return memcached_string_length(sptr);
}
+char *memcached_result_take_value(memcached_result_st *self)
+{
+ memcached_string_st *sptr= &self->value;
+ return memcached_string_take_value(sptr);
+}
+
uint32_t memcached_result_flags(const memcached_result_st *self)
{
return self->item_flags;
+++ /dev/null
-# Author?
-# AX_CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
-#
-
-#serial 2
-
-AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [
- AC_CACHE_CHECK([whether SOCK_CLOEXEC is supported], [ax_cv_sock_cloexec], [
- AC_LANG_PUSH([C])
- AC_RUN_IFELSE([
- AC_LANG_PROGRAM([
-
- /* SOCK_CLOEXEC test */
-#include <sys/types.h>
-#include <sys/socket.h>
-
- ], [
- int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
- return (s == -1);
- ])],
- [ax_cv_sock_cloexec=yes],
- [ax_cv_sock_cloexec=no],
- [AC_MSG_WARN([test program execution failed])])
- ])
-
- AS_IF([test x"ax_cv_sock_cloexec" = xyes], [AC_MSG_RESULT([yes]) ; $1], AC_MSG_RESULT([no]) ; $2)
- ])
uint64_t cas_value= memcached_result_cas(results);
test_true(cas_value);
+ char* take_value= memcached_result_take_value(results);
+ test_strcmp(__func__, take_value);
+ free(take_value);
+
memcached_result_free(results);
// Bad cas value, sanity check