#define MEMCACHED_NI_MAXHOST 1025
#endif
+#ifdef NI_MAXSERV
+#define MEMCACHED_NI_MAXSERV NI_MAXSERV
+#else
+#define MEMCACHED_NI_MAXSERV 32
+#endif
+
enum memcached_server_state_t {
MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
pointer_index < pointer_per_server / pointer_per_hash;
pointer_index++)
{
- char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+ char sort_host[1 +MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 + MEMCACHED_NI_MAXSERV ]= "";
int sort_host_length;
// Spymemcached ketema key format is: hostname/ip:port-index
// If hostname is not available then: /ip:port-index
- sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ sort_host_length= snprintf(sort_host, sizeof(sort_host),
"/%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index);
- if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0)
+ if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0)
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
- memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
+ memcached_literal_param("snprintf(sizeof(sort_host))"));
}
if (DEBUG)
pointer_index <= pointer_per_server / pointer_per_hash;
pointer_index++)
{
- char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+ char sort_host[MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 +MEMCACHED_NI_MAXSERV]= "";
int sort_host_length;
if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
{
- sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s-%u",
list[host_index].hostname,
pointer_index - 1);
}
else
{
- sort_host_length= snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s:%u-%u",
list[host_index].hostname,
(uint32_t)list[host_index].port,
pointer_index - 1);
}
- if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0)
+ if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0)
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
- memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
+ memcached_literal_param("snprintf(sizeof(sort_host)))"));
}
if (is_ketama_weighted)
AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
])
- AC_CACHE_CHECK([if system defines RUSAGE_THREAD], [ac_cv_rusage_thread],[
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
- [[
-#include <sys/time.h>
-#include <sys/resource.h>
- ]],[[
- int x= RUSAGE_THREAD;
- ]])
- ],[
- ac_cv_rusage_thread=yes
- ],[
- ac_cv_rusage_thread=no
- ])
- ])
- AS_IF([test "$ac_cv_rusage_thread" = "no"],[
- AC_DEFINE([RUSAGE_THREAD], [RUSAGE_SELF],
- [Define if system doesn't define])
- ])
-
AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)])
AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl Check for all of the headers and libs that Drizzle needs. We check all
-dnl of these for plugins too, to ensure that all of the appropriate defines
-dnl are set.
-
-AC_DEFUN([PANDORA_CXX_DEMANGLE],[
- AC_LANG_PUSH([C++])
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
- AC_CHECK_HEADERS(cxxabi.h)
- AC_CACHE_CHECK([checking for abi::__cxa_demangle], pandora_cv_cxa_demangle,
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cxxabi.h>]], [[
- char *foo= 0; int bar= 0;
- foo= abi::__cxa_demangle(foo, foo, 0, &bar);
- ]])],[pandora_cv_cxa_demangle=yes],[pandora_cv_cxa_demangle=no])])
- CXXFLAGS="${save_CXXFLAGS}"
- AC_LANG_POP()
-
- AS_IF([test "x$pandora_cv_cxa_demangle" = xyes],[
- AC_DEFINE(HAVE_ABI_CXA_DEMANGLE, 1,
- [Define to 1 if you have the `abi::__cxa_demangle' function.])
- ])
-])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-#--------------------------------------------------------------------
-# Check for libdl
-#--------------------------------------------------------------------
-
-
-AC_DEFUN([_PANDORA_SEARCH_LIBDL],[
-
- save_LIBS="$LIBS"
- LIBS=""
- AC_CHECK_LIB(dl,dlopen)
- AC_CHECK_FUNCS(dlopen)
- LIBDL_LIBS="$LIBS"
- LIBS="${save_LIBS}"
- AC_SUBST(LIBDL_LIBS)
-
- AM_CONDITIONAL(HAVE_LIBDL, [test "x${ac_cv_func_dlopen}" = "xyes"])
-])
-
-AC_DEFUN([_PANDORA_HAVE_LIBDL],[
-
- AC_ARG_ENABLE([libdl],
- [AS_HELP_STRING([--disable-libdl],
- [Build with libdl support @<:@default=on@:>@])],
- [ac_enable_libdl="$enableval"],
- [ac_enable_libdl="yes"])
-
- _PANDORA_SEARCH_LIBDL
-])
-
-
-AC_DEFUN([PANDORA_HAVE_LIBDL],[
- AC_REQUIRE([_PANDORA_HAVE_LIBDL])
-])
-
-AC_DEFUN([_PANDORA_REQUIRE_LIBDL],[
- ac_enable_libdl="yes"
- _PANDORA_SEARCH_LIBDL
-
- AS_IF([test "$ac_cv_func_dlopen" != "yes"],[
- AC_MSG_ERROR([libdl/dlopen() is required for ${PACKAGE}. On Debian this can be found in libc6-dev. On RedHat this can be found in glibc-devel.])
- ])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBDL],[
- AC_REQUIRE([_PANDORA_REQUIRE_LIBDL])
-])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([PANDORA_RUN_CPPLINT],[
- m4_syscmd([python config/make-lint.py])
-])