#include <unistd.h>
#include <libmemcached-1.0/memcached.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
#include <libmemcached/memcached/protocol_binary.h>
#include <libmemcached/byteorder.h>
#include <clients/utilities.h>
AX_COMPILER_VENDOR
AC_CXX_HEADER_STDCXX_98
-AX_TLS
AC_FUNC_ALLOCA
AC_FUNC_ERROR_AT_LINE
AM_CFLAGS="$AM_CFLAGS $NO_WERROR"
AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR"
])
-DETECT_EAGAIN
SOCKET_SEND_FLAGS
AC_CONFIG_FILES([
#include <event.h>
#include <libmemcachedprotocol-0.0/handler.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
#include <example/byteorder.h>
#include "example/storage.h"
#include "example/memcached_light.h"
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * LibMemcached
- *
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
- * Copyright (C) 2006-2009 Brian Aker
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * * The names of its contributors may not be used to endorse or
- * promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#pragma once
-
-
-/* To hide the platform differences between MS Windows and Unix, I am
- * going to use the Microsoft way and #define the Microsoft-specific
- * functions to the unix way. Microsoft use a separate subsystem for sockets,
- * but Unix normally just use a filedescriptor on the same functions. It is
- * a lot easier to map back to the unix way with macros than going the other
- * way without side effect ;-)
- */
-#ifdef WIN32
-#include "win32/wrappers.h"
-#define get_socket_errno() WSAGetLastError()
-#else
-#define INVALID_SOCKET -1
-#define SOCKET_ERROR -1
-#define closesocket(a) close(a)
-#define get_socket_errno() errno
-#endif
-
-#ifdef __cplusplus
-static inline void memcached_close_socket(int& socket_fd)
-{
- closesocket(socket_fd);
- socket_fd= INVALID_SOCKET;
-}
-#endif
-
-#ifndef HAVE_MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-#ifndef HAVE_MSG_DONTWAIT
-#define MSG_DONTWAIT 0
-#endif
-
-#ifndef HAVE_MSG_MORE
-#define MSG_MORE 0
-#endif
-
-
#include <libmemcached/io.hpp>
#include <libmemcached/udp.hpp>
#include <libmemcached/do.hpp>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
#include <libmemcached/connect.hpp>
#include <libmemcached/allocators.hpp>
#include <libmemcached/hash.hpp>
timeout_error_occured= true;
break;
+ case EAGAIN:
+#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
+#endif
case EINPROGRESS: // nonblocking mode - first return
case EALREADY: // nonblocking mode - subsequent returns
{
libmemcached/assert.hpp \
libmemcached/backtrace.hpp \
libmemcached/byteorder.h \
- libmemcached/close_socket.hpp \
libmemcached/common.h \
libmemcached/connect.hpp \
libmemcached/continuum.hpp \
libmemcached/response.h \
libmemcached/server.hpp \
libmemcached/server_instance.h \
+ libmemcached/socket.hpp \
libmemcached/string.hpp \
libmemcached/udp.hpp \
libmemcached/virtual_bucket.h \
case EINTR:
continue;
+#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
-#ifdef USE_EAGAIN
- case EAGAIN:
#endif
+ case EAGAIN:
#ifdef TARGET_OS_LINUX
case ERESTART:
#endif
{
case ENOBUFS:
continue;
+
+#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
-#ifdef USE_EAGAIN
- case EAGAIN:
#endif
+ case EAGAIN:
{
/*
* We may be blocked on write because the input buffer
continue;
case ETIMEDOUT: // OSX
+#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
-#ifdef USE_EAGAIN
- case EAGAIN:
#endif
+ case EAGAIN:
#ifdef TARGET_OS_LINUX
case ERESTART:
#endif
continue;
case ETIMEDOUT: // OSX
+#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
-#ifdef USE_EAGAIN
- case EAGAIN:
#endif
+ case EAGAIN:
#ifdef TARGET_OS_LINUX
case ERESTART:
#endif
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * LibMemcached
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+
+/* To hide the platform differences between MS Windows and Unix, I am
+ * going to use the Microsoft way and #define the Microsoft-specific
+ * functions to the unix way. Microsoft use a separate subsystem for sockets,
+ * but Unix normally just use a filedescriptor on the same functions. It is
+ * a lot easier to map back to the unix way with macros than going the other
+ * way without side effect ;-)
+ */
+#ifdef WIN32
+#include "win32/wrappers.h"
+#define get_socket_errno() WSAGetLastError()
+#else
+#define INVALID_SOCKET -1
+#define SOCKET_ERROR -1
+#define closesocket(a) close(a)
+#define get_socket_errno() errno
+#endif
+
+#ifdef __cplusplus
+static inline void memcached_close_socket(int& socket_fd)
+{
+ closesocket(socket_fd);
+ socket_fd= INVALID_SOCKET;
+}
+#endif
+
+#ifndef HAVE_MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
+#ifndef HAVE_MSG_DONTWAIT
+#define MSG_DONTWAIT 0
+#endif
+
+#ifndef HAVE_MSG_MORE
+#define MSG_MORE 0
+#endif
+
+
#pragma once
#include "config.h"
-#if !defined(__cplusplus)
-# include <stdbool.h>
-#endif
#include <assert.h>
#include <libmemcachedprotocol-0.0/handler.h>
#include <libmemcachedprotocol/cache.h>
#include <libmemcached/byteorder.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
/*
* I don't really need the following two functions as function pointers
memcached_return_t rc= MEMCACHED_SUCCESS;
if (has_socket())
{
- local_pid= libmemcached_util_getpid(socket().c_str(), 0, &rc);
+ if (socket().empty())
+ {
+ return -1;
+ }
+
+ local_pid= libmemcached_util_getpid(socket().c_str(), port(), &rc);
}
else
{
+++ /dev/null
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_tls.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_TLS([action-if-found], [action-if-not-found])
-#
-# DESCRIPTION
-#
-# Provides a test for the compiler support of thread local storage (TLS)
-# extensions. Defines TLS if it is found. Currently knows about GCC/ICC
-# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
-# supports either.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
-# Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 10
-
-AC_DEFUN([AX_TLS], [
- AC_MSG_CHECKING(for thread local storage (TLS) class)
- AC_CACHE_VAL(ac_cv_tls, [
- ax_tls_keywords="__thread __declspec(thread) none"
- for ax_tls_keyword in $ax_tls_keywords; do
- AS_CASE([$ax_tls_keyword],
- [none], [ac_cv_tls=none ; break],
- [AC_TRY_COMPILE(
- [#include <stdlib.h>
- static void
- foo(void) {
- static ] $ax_tls_keyword [ int bar;
- exit(1);
- }],
- [],
- [ac_cv_tls=$ax_tls_keyword ; break],
- ac_cv_tls=none
- )])
- done
- ])
- AC_MSG_RESULT($ac_cv_tls)
-
- AS_IF([test "$ac_cv_tls" != "none"],
- AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
- m4_ifnblank([$1], [$1]),
- m4_ifnblank([$2], [$2])
- )
-])
])
-AH_BOTTOM([
-#ifdef WIN32
-#define _WIN32_WINNT 0x0501
-#endif
-
-/* To hide the platform differences between MS Windows and Unix, I am
- * going to use the Microsoft way and #define the Microsoft-specific
- * functions to the unix way. Microsoft use a separate subsystem for sockets,
- * but Unix normally just use a filedescriptor on the same functions. It is
- * a lot easier to map back to the unix way with macros than going the other
- * way without side effect ;-)
- */
-#ifdef WIN32
-#include "win32/wrappers.h"
-#define get_socket_errno() WSAGetLastError()
-#else
-#define INVALID_SOCKET -1
-#define SOCKET_ERROR -1
-#define closesocket(a) close(a)
-#define get_socket_errno() errno
-#endif
-
-#ifndef HAVE_MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-#ifndef HAVE_MSG_DONTWAIT
-#define MSG_DONTWAIT 0
-#endif
-
-#ifndef HAVE_MSG_MORE
-#define MSG_MORE 0
-#endif
-
-])
])dnl CONFIG_EXTRA
+++ /dev/null
-#
-# Some platforms define EWOULDBLOCK == EAGAIN, causing our switch for error
-# codes to be illegal (POSIX.1-2001 allows both return codes from recv, so
-# we need to test both if they differ...)
-#
-AC_DEFUN([DETECT_EAGAIN],
-[
- AC_CACHE_CHECK([if EWOULDBLOCK == EAGAIN],[av_cv_eagain_ewouldblock],
- [AC_TRY_COMPILE([
-#include <errno.h>
- ], [
-int error = EAGAIN;
-switch (error)
-{
- case EAGAIN:
- case EWOULDBLOCK:
- error = 1;
- break;
- default:
- error = 0;
-}
- ],
- [ av_cv_eagain_ewouldblock=no ],
- [ av_cv_eagain_ewouldblock=yes ])
- ])
- AS_IF([test "x$av_cv_eagain_ewouldblock" = "xno"],[
- AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain])])
-])
+dnl Copyright (C) 2012 Data Differential LLC
dnl Copyright (C) 2011 Trond Norbye
dnl This file is free software; Trond Norbye
dnl gives unlimited permission to copy and/or distribute it,
AC_LANG_PUSH([C])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I${srcdir}"
- AC_TRY_LINK([
-#include <sys/socket.h>
- ], [
-int flags= MSG_NOSIGNAL;
- ],
- [ ac_cv_msg_nosignal=yes ],
- [ ac_cv_msg_nosignal=no ])
- CFLAGS="$save_CFLAGS"
- AC_LANG_POP
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"])
+ AC_LANG_POP
])
AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [
AC_LANG_PUSH([C])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I${srcdir}"
- AC_TRY_LINK([
-#include <sys/socket.h>
- ], [
-int flags= MSG_DONTWAIT;
- ],
- [ ac_cv_msg_dontwait=yes ],
- [ ac_cv_msg_dontwait=no ])
- CFLAGS="$save_CFLAGS"
- AC_LANG_POP
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"])
+ AC_LANG_POP
])
AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [
AC_LANG_PUSH([C])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I${srcdir}"
- AC_TRY_LINK([
-#include <sys/socket.h>
- ], [
-int flags= MSG_MORE;
- ],
- [ ac_cv_msg_more=yes ],
- [ ac_cv_msg_more=no ])
- CFLAGS="$save_CFLAGS"
- AC_LANG_POP
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_MORE ])], [ac_cv_msg_more="yes"])
+ AC_LANG_POP
])
- AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[
- AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])])
- AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[
- AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])])
- AS_IF([test "x$ac_cv_msg_more" = "xyes"],[
- AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a HAVE_MSG_MORE])])
+ AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])])
+ AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[ AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])])
+ AS_IF([test "x$ac_cv_msg_more" = "xyes"],[ AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a MSG_MORE])])
])
dnl ---------------------------------------------------------------------------