From: Brian Aker Date: Sun, 8 Jan 2012 06:52:16 +0000 (-0800) Subject: Remove dead m4, and make sure that the sort buffer is always large enough to handle... X-Git-Tag: 1.0.3~1^2^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0df7db43ac75321e7eb185605f28ecbaae75393d;p=awesomized%2Flibmemcached Remove dead m4, and make sure that the sort buffer is always large enough to handle whatever message it is given. --- diff --git a/libmemcached-1.0/struct/server.h b/libmemcached-1.0/struct/server.h index 183b3739..245b4b9b 100644 --- a/libmemcached-1.0/struct/server.h +++ b/libmemcached-1.0/struct/server.h @@ -48,6 +48,12 @@ #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 diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index 410b38ff..337a999a 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -236,21 +236,21 @@ static memcached_return_t update_continuum(memcached_st *ptr) 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) @@ -281,29 +281,29 @@ static memcached_return_t update_continuum(memcached_st *ptr) 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) diff --git a/m4/pandora_canonical.m4 b/m4/pandora_canonical.m4 index e876a8fa..b7da1ac3 100644 --- a/m4/pandora_canonical.m4 +++ b/m4/pandora_canonical.m4 @@ -171,25 +171,6 @@ AC_DEFUN([PANDORA_CANONICAL_TARGET],[ 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 -#include - ]],[[ - 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)]) diff --git a/m4/pandora_cxx_demangle.m4 b/m4/pandora_cxx_demangle.m4 deleted file mode 100644 index 5ae66877..00000000 --- a/m4/pandora_cxx_demangle.m4 +++ /dev/null @@ -1,27 +0,0 @@ -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 ]], [[ - 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.]) - ]) -]) diff --git a/m4/pandora_have_libdl.m4 b/m4/pandora_have_libdl.m4 deleted file mode 100644 index dde71638..00000000 --- a/m4/pandora_have_libdl.m4 +++ /dev/null @@ -1,51 +0,0 @@ -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]) -]) diff --git a/m4/pandora_run_cpplint.m4 b/m4/pandora_run_cpplint.m4 deleted file mode 100644 index 6d3e9527..00000000 --- a/m4/pandora_run_cpplint.m4 +++ /dev/null @@ -1,8 +0,0 @@ -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]) -])