#!/bin/bash
+#
+# Copyright (C) 2012 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.
-if test -f configure; then make clean; make merge-clean; make distclean; fi;
+if test -n $MAKE; then
+ MAKE="make"
+fi
+
+if test -n $MAKE_J; then
+ MAKE_J="-j2"
+fi
-rm -r -f autom4te.cache/ config.h config.log config.status
+if test -f configure; then $MAKE $MAKE_J clean; $MAKE $MAKE_J merge-clean; $MAKE $MAKE_J distclean; fi;
+
+rm -r -f autom4te.cache/ config.h config.log config.status configure
./config/autorun.sh
if [ $(uname) = "Darwin" ];
then
else
./configure --enable-assert
fi
-make
+
+if test -z $JENKINS_URL; then
+$MAKE $MAKE_J
+fi
#include <libmemcached/byteorder.h>
#include <clients/utilities.h>
+#include <vector>
+
#ifdef linux
/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
* optimize the conversion functions, but the prototypes generate warnings
"test_ascii_mget4 test_ascii_mget5 "
"test_ascii_mget6\r\n"));
- char *returned[nkeys];
+ std::vector<char *> returned;
+ returned.resize(nkeys);
for (uint32_t x= 0; x < nkeys; ++x)
{
char *strdup_cleanup(const char *str);
void cleanup(void);
long int timedif(struct timeval a, struct timeval b);
-void version_command(const char *command_name);
+void version_command(const char *command_name) __attribute__ ((noreturn));
void help_command(const char *command_name, const char *description,
const struct option *long_options,
- memcached_programs_help_st *options);
+ memcached_programs_help_st *options) __attribute__ ((noreturn));
void process_hash_option(memcached_st *memc, char *opt_hash);
bool initialize_sasl(memcached_st *memc, char *user, char *password);
void shutdown_sasl(void);
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_PTHREAD(, [AC_MSG_ERROR(could not find libpthread)])
+
AX_HARDEN_COMPILER_FLAGS
-AX_PTHREAD
+
+AX_DEBUG
AC_CONFIG_FILES([
Makefile
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
install-html: html-local
- @rm -r -f /var/www/libmemcaced
- @cp -r docs/html /var/www/libmemcaced
+ @rm -r -f /var/www/libmemcached/*
+ @cp -r docs/html /var/www/libmemcached
html-local: docs/conf.py changes docs
PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/html
extern "C" {
#endif
+LIBMEMCACHED_API
+ const char *memcached_error(const memcached_st *);
+
LIBMEMCACHED_API
const char *memcached_last_error_message(const memcached_st *);
}
static void calc_oldest_node(memcached_analysis_st *result,
- const uint32_t server_num,
- const uint32_t uptime)
+ const uint32_t server_num,
+ const uint32_t uptime)
{
if (result->longest_uptime < uptime)
{
for (uint32_t x= 0; x < server_count; x++)
{
calc_largest_consumption(result, x, memc_stat[x].bytes);
- calc_oldest_node(result, x, memc_stat[x].uptime);
+ calc_oldest_node(result, x, uint32_t(memc_stat[x].uptime));
calc_least_free_node(result, x,
memc_stat[x].limit_maxbytes,
memc_stat[x].bytes);
#ifdef HAVE_EXECINFO_H
void *array[50];
- size_t size= backtrace(array, 50);
+ int size= backtrace(array, 50);
char **strings= backtrace_symbols(array, size);
if (strings == NULL)
return;
}
- fprintf(stderr, "Number of stack frames obtained: %lu\n", (unsigned long)size);
+ fprintf(stderr, "Number of stack frames obtained: %d\n", size);
char *named_function= (char *)std::realloc(NULL, 1024);
return;
}
- for (size_t x= 1; x < size; x++)
+ for (int x= 1; x < size; x++)
{
if (USE_DEMANGLE)
{
hints.ai_protocol= IPPROTO_TCP;
}
- server->address_info= NULL;
+ assert(server->address_info == NULL);
+ assert(server->address_info_next == NULL);
int errcode;
switch(errcode= getaddrinfo(server->hostname, str_port, &hints, &server->address_info))
{
break;
case EAI_AGAIN:
+ if (server->address_info)
+ {
+ freeaddrinfo(server->address_info);
+ server->address_info= NULL;
+ server->address_info_next= NULL;
+ }
return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode)));
case EAI_SYSTEM:
+ if (server->address_info)
+ {
+ freeaddrinfo(server->address_info);
+ server->address_info= NULL;
+ server->address_info_next= NULL;
+ }
return memcached_set_errno(*server, errno, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_SYSTEM)"));
case EAI_BADFLAGS:
+ if (server->address_info)
+ {
+ freeaddrinfo(server->address_info);
+ server->address_info= NULL;
+ server->address_info_next= NULL;
+ }
return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_BADFLAGS)"));
case EAI_MEMORY:
+ if (server->address_info)
+ {
+ freeaddrinfo(server->address_info);
+ server->address_info= NULL;
+ server->address_info_next= NULL;
+ }
return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_MEMORY)"));
default:
{
+ if (server->address_info)
+ {
+ freeaddrinfo(server->address_info);
+ server->address_info= NULL;
+ server->address_info_next= NULL;
+ }
return memcached_set_error(*server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode)));
}
}
{
WATCHPOINT_ASSERT(server->state == MEMCACHED_SERVER_STATE_NEW);
server->address_info_next= NULL;
- memcached_return_t rc;
- uint32_t counter= 5;
- while (--counter)
- {
- if ((rc= set_hostinfo(server)) != MEMCACHED_TIMEOUT)
- {
- break;
- }
-
-#ifndef WIN32
- struct timespec dream, rem;
-
- dream.tv_nsec= 1000;
- dream.tv_sec= 0;
-
- nanosleep(&dream, &rem);
-#endif
- }
+ memcached_return_t rc= set_hostinfo(server);
if (memcached_failed(rc))
{
}
}
-const char *Context::set_hostname(const char *str, size_t size)
+void Context::hostname(const char *str, size_t size, server_t& server_)
{
size_t copy_length= size_t(NI_MAXHOST) > size ? size : size_t(NI_MAXHOST);
memcpy(_hostname, str, copy_length);
_hostname[copy_length]= 0;
- return _hostname;
+ server_.port= MEMCACHED_DEFAULT_PORT;
+ server_.weight= 1;
+ server_.c_str= _hostname;
+ server_.size= size;
+}
+
+bool Context::string_buffer(const char *str, size_t size, memcached_string_t& string_)
+{
+ if (memcached_string_set(_string_buffer, str, size))
+ {
+ string_.c_str= memcached_string_value(_string_buffer);
+ string_.size= memcached_string_length(_string_buffer);
+
+ return true;
+ }
+
+ return false;
}
bool Context::set_hash(memcached_hash_t hash)
class Context
{
public:
- Context(const char *option_string, size_t option_string_length, memcached_st *memc_arg,
+ Context(const char *option_string, size_t option_string_length, memcached_st *memc_,
memcached_return_t &rc_arg) :
previous_token(END),
scanner(NULL),
+ buf(option_string),
begin(NULL),
pos(0),
- memc(NULL),
+ length(option_string_length),
+ memc(memc_),
rc(rc_arg),
_is_server(false),
_end(false),
_has_hash(false)
{
_hostname[0]= 0;
- buf= option_string;
- length= option_string_length;
- memc= memc_arg;
init_scanner();
rc= MEMCACHED_SUCCESS;
memc->state.is_parsing= true;
+ memcached_string_create(memc,
+ &_string_buffer,
+ 1024);
}
bool end()
return _is_server;
}
- const char *set_hostname(const char *str, size_t size);
+ void hostname(const char*, size_t, server_t&);
+
+ bool string_buffer(const char*, size_t, memcached_string_t&);
const char *hostname() const
{
~Context()
{
+ memcached_string_free(&_string_buffer);
destroy_scanner();
memc->state.is_parsing= false;
}
bool _end;
char _hostname[NI_MAXHOST];
bool _has_hash;
+ memcached_string_st _string_buffer;
};
if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, (yyvsp[(3) - (3)].number))))
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "Failed to add server: %s", (yyvsp[(2) - (3)].string).c_str);
+ snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", (yyvsp[(2) - (3)].string).c_str);
parser_abort(context, buffer);
}
}
if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3)))
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "Failed to add server: %s", $2.c_str);
+ snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", $2.c_str);
parser_abort(context, buffer);
}
}
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
-#define YY_NO_INPUT
-
#define YY_EXTRA_TYPE Context*
-#line 24 "libmemcached/csl/scanner.cc"
+#line 22 "libmemcached/csl/scanner.cc"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
-/* %not-for-header */
-
-/* %if-c-only */
-/* %if-not-reentrant */
-/* %endif */
-/* %endif */
-/* %ok-for-header */
-
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define FLEX_BETA
#endif
-/* %if-c++-only */
-/* %endif */
-
-/* %if-c-only */
-
-/* %endif */
-
-/* %if-c-only */
-
-/* %endif */
-
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
-/* %if-c-only */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
-/* %endif */
-/* %if-tables-serialization */
-/* %endif */
/* end standard C headers. */
-/* %if-c-or-c++ */
/* flex integer type definitions */
#ifndef FLEXINT_H
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
-#endif /* ! C99 */
-
#endif /* ! FLEXINT_H */
-/* %endif */
-
-/* %if-c++-only */
-/* %endif */
-
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define yyconst
#endif
-/* %not-for-header */
-
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* %ok-for-header */
-
-/* %not-for-header */
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-/* %ok-for-header */
-
-/* %if-reentrant */
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-/* %endif */
-
-/* %if-not-reentrant */
-/* %endif */
-
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
-/* %if-not-reentrant */
-/* %endif */
-
-/* %if-c-only */
-/* %if-not-reentrant */
-/* %endif */
-/* %endif */
-
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
-/* %if-c-only */
FILE *yy_input_file;
-/* %endif */
-
-/* %if-c++-only */
-/* %endif */
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-/* %if-c-only Standard (non-C++) definition */
-/* %not-for-header */
-
-/* %if-not-reentrant */
-/* %endif */
-/* %ok-for-header */
-
-/* %endif */
-
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-/* %if-c-only Standard (non-C++) definition */
-
-/* %if-not-reentrant */
-/* %not-for-header */
-
-/* %ok-for-header */
-
-/* %endif */
-
void config_restart (FILE *input_file ,yyscan_t yyscanner );
void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
-/* %endif */
-
void *config_alloc (yy_size_t ,yyscan_t yyscanner );
void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner );
void config_free (void * ,yyscan_t yyscanner );
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
/* Begin user sect3 */
#define config_wrap(n) 1
#define YY_SKIP_YYWRAP
-#define FLEX_DEBUG
-
typedef unsigned char YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-/* %if-c-only Standard (non-C++) definition */
-
static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
static int yy_get_next_buffer (yyscan_t yyscanner );
static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
-/* %endif */
-
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \
-/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
yyleng = (size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
-/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
yyg->yy_c_buf_p = yy_cp;
-/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
#define YY_NUM_RULES 66
#define YY_END_OF_BUFFER 67
/* This struct is not used in this scanner,
533, 533, 533, 533
} ;
-static yyconst flex_int16_t yy_rule_linenum[66] =
- { 0,
- 99, 101, 103, 105, 107, 110, 114, 116, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 147, 148, 150, 152,
- 154, 155, 156, 157, 158, 159, 161, 162, 165, 170,
- 171, 172, 174, 175, 176, 177, 178, 179, 180, 181,
- 182, 184, 193, 211, 218
- } ;
-
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
*
*/
-#line 60 "libmemcached/csl/scanner.l"
+#line 58 "libmemcached/csl/scanner.l"
#include <cstdlib>
#include <cstring>
} \
}
+#define YY_FATAL_ERROR(msg) \
+{ \
+}
+
#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
-#line 1196 "libmemcached/csl/scanner.cc"
+#define YY_NO_INPUT 1
+#line 1094 "libmemcached/csl/scanner.cc"
#define INITIAL 0
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
-/* %if-c-only */
#include <unistd.h>
-/* %endif */
-/* %if-c++-only */
-/* %endif */
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
-/* %if-c-only Reentrant structure and macros (non-C++). */
-/* %if-reentrant */
-
/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
{
}; /* end struct yyguts_t */
-/* %if-c-only */
-
static int yy_init_globals (yyscan_t yyscanner );
-/* %endif */
-
-/* %if-reentrant */
-
/* This must go here because YYSTYPE and YYLTYPE are included
* from bison output in section 1.*/
# define yylval yyg->yylval_r
int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
-/* %endif */
-
-/* %endif End reentrant structures and macros. */
-
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
void config_set_lineno (int line_number ,yyscan_t yyscanner );
-/* %if-bison-bridge */
+int config_get_column (yyscan_t yyscanner );
+
+void config_set_column (int column_no ,yyscan_t yyscanner );
YYSTYPE * config_get_lval (yyscan_t yyscanner );
void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
-/* %endif */
-
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#endif
#endif
-/* %not-for-header */
-
-/* %ok-for-header */
-
-/* %endif */
-
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#endif
#ifndef YY_NO_INPUT
-/* %if-c-only Standard (non-C++) definition */
-/* %not-for-header */
#ifdef __cplusplus
static int yyinput (yyscan_t yyscanner );
#else
static int input (yyscan_t yyscanner );
#endif
-/* %ok-for-header */
-/* %endif */
#endif
-/* %if-c-only */
-
-/* %endif */
-
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
-/* %if-c-only Standard (non-C++) definition */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
-/* %endif */
-/* %if-c++-only C++ definition */
-/* %endif */
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
-/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ unsigned n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
} \
}\
\
-/* %if-c++-only C++ definition \ */\
-/* %endif */
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
-/* %if-c-only */
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
#endif
-/* %if-tables-serialization structures and prototypes */
-/* %not-for-header */
-
-/* %ok-for-header */
-
-/* %not-for-header */
-
-/* %tables-yydmap generated elements */
-/* %endif */
/* end tables serialization structures and prototypes */
-/* %ok-for-header */
-
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-/* %if-c-only Standard (non-C++) definition */
extern int config_lex \
(YYSTYPE * yylval_param ,yyscan_t yyscanner);
#define YY_DECL int config_lex \
(YYSTYPE * yylval_param , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only C++ definition */
-/* %endif */
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
#define YY_BREAK break;
#endif
-/* %% [6.0] YY_RULE_SETUP definition goes here */
#define YY_RULE_SETUP \
if ( yyleng > 0 ) \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
(yytext[yyleng - 1] == '\n'); \
YY_USER_ACTION
-/* %not-for-header */
-
/** The main scanner function which does all the work.
*/
YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-/* %% [7.0] user's declarations go here */
-#line 96 "libmemcached/csl/scanner.l"
+#line 100 "libmemcached/csl/scanner.l"
-#line 1504 "libmemcached/csl/scanner.cc"
+#line 1336 "libmemcached/csl/scanner.cc"
yylval = yylval_param;
yyg->yy_start = 1; /* first start state */
if ( ! yyin )
-/* %if-c-only */
yyin = stdin;
-/* %endif */
-/* %if-c++-only */
-/* %endif */
if ( ! yyout )
-/* %if-c-only */
yyout = stdout;
-/* %endif */
-/* %if-c++-only */
-/* %endif */
if ( ! YY_CURRENT_BUFFER ) {
config_ensure_buffer_stack (yyscanner);
while ( 1 ) /* loops until end-of-file is reached */
{
-/* %% [8.0] yymore()-related code goes here */
yy_cp = yyg->yy_c_buf_p;
/* Support of yytext. */
*/
yy_bp = yy_cp;
-/* %% [9.0] code to set up and find next match goes here */
yy_current_state = yyg->yy_start;
yy_current_state += YY_AT_BOL();
yy_match:
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 1740 );
+ while ( yy_current_state != 533 );
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
yy_find_action:
-/* %% [10.0] code to find the action number goes here */
yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yyg->yy_last_accepting_cpos;
- yy_current_state = yyg->yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
YY_DO_BEFORE_ACTION;
-/* %% [11.0] code for yylineno update goes here */
-
do_action: /* This label is used only to access EOF actions. */
-/* %% [12.0] debug code goes here */
- if ( yy_flex_debug )
- {
- if ( yy_act == 0 )
- fprintf( stderr, "--scanner backing up\n" );
- else if ( yy_act < 66 )
- fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
- (long)yy_rule_linenum[yy_act], yytext );
- else if ( yy_act == 66 )
- fprintf( stderr, "--accepting default rule (\"%s\")\n",
- yytext );
- else if ( yy_act == 67 )
- fprintf( stderr, "--(end of buffer or a NUL)\n" );
- else
- fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
- }
-
switch ( yy_act )
{ /* beginning of action switch */
-/* %% [13.0] actions go here */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = yyg->yy_hold_char;
case 1:
YY_RULE_SETUP
-#line 99 "libmemcached/csl/scanner.l"
+#line 103 "libmemcached/csl/scanner.l"
{ return yytext[0];}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 101 "libmemcached/csl/scanner.l"
+#line 105 "libmemcached/csl/scanner.l"
{ yylval->number= atoi(yytext); return (NUMBER); }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 103 "libmemcached/csl/scanner.l"
+#line 107 "libmemcached/csl/scanner.l"
{ yylval->number= atoi(yytext +1); return PORT; }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 105 "libmemcached/csl/scanner.l"
+#line 109 "libmemcached/csl/scanner.l"
{ yylval->number= atoi(yytext +2); return WEIGHT_START; }
YY_BREAK
case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
-#line 107 "libmemcached/csl/scanner.l"
+#line 111 "libmemcached/csl/scanner.l"
; /* skip whitespace */
YY_BREAK
case 6:
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 110 "libmemcached/csl/scanner.l"
+#line 114 "libmemcached/csl/scanner.l"
{
return COMMENT;
}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 114 "libmemcached/csl/scanner.l"
+#line 118 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 116 "libmemcached/csl/scanner.l"
+#line 120 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 118 "libmemcached/csl/scanner.l"
+#line 122 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 119 "libmemcached/csl/scanner.l"
+#line 123 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 120 "libmemcached/csl/scanner.l"
+#line 124 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 121 "libmemcached/csl/scanner.l"
+#line 125 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 122 "libmemcached/csl/scanner.l"
+#line 126 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 123 "libmemcached/csl/scanner.l"
+#line 127 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 124 "libmemcached/csl/scanner.l"
+#line 128 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= HASH; }
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 125 "libmemcached/csl/scanner.l"
+#line 129 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 126 "libmemcached/csl/scanner.l"
+#line 130 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 127 "libmemcached/csl/scanner.l"
+#line 131 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 128 "libmemcached/csl/scanner.l"
+#line 132 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 129 "libmemcached/csl/scanner.l"
+#line 133 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; }
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 130 "libmemcached/csl/scanner.l"
+#line 134 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 131 "libmemcached/csl/scanner.l"
+#line 135 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 132 "libmemcached/csl/scanner.l"
+#line 136 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 133 "libmemcached/csl/scanner.l"
+#line 137 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; }
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 134 "libmemcached/csl/scanner.l"
+#line 138 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 135 "libmemcached/csl/scanner.l"
+#line 139 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 136 "libmemcached/csl/scanner.l"
+#line 140 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; }
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 137 "libmemcached/csl/scanner.l"
+#line 141 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; }
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 138 "libmemcached/csl/scanner.l"
+#line 142 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; }
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 139 "libmemcached/csl/scanner.l"
+#line 143 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; }
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 140 "libmemcached/csl/scanner.l"
+#line 144 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; }
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 141 "libmemcached/csl/scanner.l"
+#line 145 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; }
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 142 "libmemcached/csl/scanner.l"
+#line 146 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; }
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 143 "libmemcached/csl/scanner.l"
+#line 147 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; }
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 144 "libmemcached/csl/scanner.l"
+#line 148 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; }
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 145 "libmemcached/csl/scanner.l"
+#line 149 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; }
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 147 "libmemcached/csl/scanner.l"
+#line 151 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; }
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 148 "libmemcached/csl/scanner.l"
+#line 152 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; }
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 150 "libmemcached/csl/scanner.l"
+#line 154 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; }
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 152 "libmemcached/csl/scanner.l"
+#line 156 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= FETCH_VERSION; }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 154 "libmemcached/csl/scanner.l"
+#line 158 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; }
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 155 "libmemcached/csl/scanner.l"
+#line 159 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RESET; }
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 156 "libmemcached/csl/scanner.l"
+#line 160 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; }
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 157 "libmemcached/csl/scanner.l"
+#line 161 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SERVERS; }
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 158 "libmemcached/csl/scanner.l"
+#line 162 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= END; }
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 159 "libmemcached/csl/scanner.l"
+#line 163 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= ERROR; }
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 161 "libmemcached/csl/scanner.l"
+#line 165 "libmemcached/csl/scanner.l"
{ return yyextra->previous_token= TRUE; }
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 162 "libmemcached/csl/scanner.l"
+#line 166 "libmemcached/csl/scanner.l"
{ return yyextra->previous_token= FALSE; }
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 165 "libmemcached/csl/scanner.l"
+#line 169 "libmemcached/csl/scanner.l"
{
yyextra->begin= yytext;
return UNKNOWN_OPTION;
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 170 "libmemcached/csl/scanner.l"
+#line 174 "libmemcached/csl/scanner.l"
{ return CONSISTENT; }
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 171 "libmemcached/csl/scanner.l"
+#line 175 "libmemcached/csl/scanner.l"
{ return MODULA; }
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 172 "libmemcached/csl/scanner.l"
+#line 176 "libmemcached/csl/scanner.l"
{ return RANDOM; }
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 174 "libmemcached/csl/scanner.l"
+#line 178 "libmemcached/csl/scanner.l"
{ return MD5; }
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 175 "libmemcached/csl/scanner.l"
+#line 179 "libmemcached/csl/scanner.l"
{ return CRC; }
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 176 "libmemcached/csl/scanner.l"
+#line 180 "libmemcached/csl/scanner.l"
{ return FNV1_64; }
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 177 "libmemcached/csl/scanner.l"
+#line 181 "libmemcached/csl/scanner.l"
{ return FNV1A_64; }
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 178 "libmemcached/csl/scanner.l"
+#line 182 "libmemcached/csl/scanner.l"
{ return FNV1_32; }
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 179 "libmemcached/csl/scanner.l"
+#line 183 "libmemcached/csl/scanner.l"
{ return FNV1A_32; }
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 180 "libmemcached/csl/scanner.l"
+#line 184 "libmemcached/csl/scanner.l"
{ return HSIEH; }
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 181 "libmemcached/csl/scanner.l"
+#line 185 "libmemcached/csl/scanner.l"
{ return MURMUR; }
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 182 "libmemcached/csl/scanner.l"
+#line 186 "libmemcached/csl/scanner.l"
{ return JENKINS; }
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 184 "libmemcached/csl/scanner.l"
+#line 188 "libmemcached/csl/scanner.l"
{
- yylval->server.port= MEMCACHED_DEFAULT_PORT;
- yylval->server.weight= 1;
- yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
- if (yylval->server.c_str)
- yylval->server.size= yyleng;
+ yyextra->hostname(yytext, yyleng, yylval->server);
return IPADDRESS;
}
YY_BREAK
{
if (yyextra->is_server())
{
- yylval->server.port= MEMCACHED_DEFAULT_PORT;
- yylval->server.weight= 1;
- yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
- if (yylval->server.c_str)
- yylval->server.size= yyleng;
+ yyextra->hostname(yytext, yyleng, yylval->server);
return HOSTNAME;
}
- yylval->string.c_str = yytext;
- yylval->string.size = yyleng;
+ yyextra->string_buffer(yytext, yyleng, yylval->string);
return STRING;
}
case 64:
/* rule 64 can match eol */
YY_RULE_SETUP
-#line 211 "libmemcached/csl/scanner.l"
+#line 206 "libmemcached/csl/scanner.l"
{
config_get_text(yyscanner)[yyleng -1]= 0;
- yylval->string.c_str= yytext +1;
- yylval->string.size= yyleng -2;
+ yyextra->string_buffer(yytext +1, yyleng -2, yylval->string);
return QUOTED_STRING;
}
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 218 "libmemcached/csl/scanner.l"
+#line 212 "libmemcached/csl/scanner.l"
{
yyextra->begin= yytext;
return UNKNOWN;
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 223 "libmemcached/csl/scanner.l"
+#line 217 "libmemcached/csl/scanner.l"
ECHO;
YY_BREAK
-#line 1992 "libmemcached/csl/scanner.cc"
+#line 1779 "libmemcached/csl/scanner.cc"
case YY_STATE_EOF(INITIAL):
yyterminate();
else
{
-/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
- yy_cp = yyg->yy_c_buf_p;
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
}
}
} /* end of action switch */
} /* end of scanning one token */
} /* end of config_lex */
-/* %ok-for-header */
-
-/* %if-c++-only */
-/* %not-for-header */
-
-/* %ok-for-header */
-
-/* %endif */
/* yy_get_next_buffer - try to read in a new buffer
*
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
-/* %if-c-only */
static int yy_get_next_buffer (yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
/* yy_get_previous_state - get the state just before the EOB char was reached */
-/* %if-c-only */
-/* %not-for-header */
-
static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
register yy_state_type yy_current_state;
register char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-/* %% [15.0] code to get the start state into yy_current_state goes here */
yy_current_state = yyg->yy_start;
yy_current_state += YY_AT_BOL();
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{
-/* %% [16.0] code to find the next state goes here */
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
-/* %if-c-only */
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
register int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
-/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
register char *yy_cp = yyg->yy_c_buf_p;
register YY_CHAR yy_c = 1;
return yy_is_jam ? 0 : yy_current_state;
}
-/* %if-c-only */
-
-/* %endif */
-
-/* %if-c-only */
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (yyscan_t yyscanner)
static int input (yyscan_t yyscanner)
#endif
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
int c;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
*yyg->yy_c_buf_p = '\0'; /* preserve yytext */
yyg->yy_hold_char = *++yyg->yy_c_buf_p;
-/* %% [19.0] update BOL and yylineno */
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
return c;
}
-/* %if-c-only */
#endif /* ifndef YY_NO_INPUT */
-/* %endif */
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
-/* %if-c-only */
void config_restart (FILE * input_file , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
-/* %if-c-only */
void config__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_did_buffer_switch_on_eof = 1;
}
-/* %if-c-only */
static void config__load_buffer_state (yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
-/* %if-c-only */
YY_BUFFER_STATE config__create_buffer (FILE * file, int size , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
YY_BUFFER_STATE b;
* @param b a buffer created with config__create_buffer()
* @param yyscanner The scanner object.
*/
-/* %if-c-only */
void config__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
config_free((void *) b ,yyscanner );
}
-/* %if-c-only */
-
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
-/* %endif */
-
-/* %if-c++-only */
-/* %endif */
-
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a config_restart() or at EOF.
*/
-/* %if-c-only */
static void config__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
int oerrno = errno;
b->yy_bs_column = 0;
}
-/* %if-c-only */
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ b->yy_is_interactive = 0;
-/* %endif */
-/* %if-c++-only */
-/* %endif */
errno = oerrno;
}
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
-/* %if-c-only */
void config__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
config__load_buffer_state(yyscanner );
}
-/* %if-c-or-c++ */
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-/* %if-c-only */
void config_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
config__load_buffer_state(yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
-/* %endif */
-/* %if-c-or-c++ */
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-/* %if-c-only */
void config_pop_buffer_state (yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
-/* %endif */
-/* %if-c-or-c++ */
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-/* %if-c-only */
static void config_ensure_buffer_stack (yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only */
-/* %endif */
{
int num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_buffer_stack_max = num_to_alloc;
}
}
-/* %endif */
-/* %if-c-only */
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
return b;
}
-/* %endif */
-/* %if-c-only */
/** Setup the input buffer state to scan a string. The next call to config_lex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
return config__scan_bytes(yystr,strlen(yystr) ,yyscanner);
}
-/* %endif */
-/* %if-c-only */
/** Setup the input buffer state to scan the given bytes. The next call to config_lex() will
* scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
return b;
}
-/* %endif */
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
-/* %if-c-only */
static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
-/* %endif */
-/* %if-c++-only */
-/* %endif */
/* Redefine yyless() so it works in section 3 code. */
/* Accessor methods (get/set functions) to struct members. */
-/* %if-c-only */
-/* %if-reentrant */
-
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
return yyextra;
}
-/* %endif */
-
/** Get the current line number.
* @param yyscanner The scanner object.
*/
return yytext;
}
-/* %if-reentrant */
-
/** Set the user-defined data. This data is never touched by the scanner.
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
yyextra = user_defined ;
}
-/* %endif */
-
/** Set the current line number.
* @param line_number
* @param yyscanner The scanner object.
yy_flex_debug = bdebug ;
}
-/* %endif */
-
-/* %if-reentrant */
/* Accessor methods for yylval and yylloc */
-/* %if-bison-bridge */
-
YYSTYPE * config_get_lval (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yylval = yylval_param;
}
-/* %endif */
-
/* User-visible API */
/* config_lex_init is special because it creates the scanner itself, so it is
return yy_init_globals ( *ptr_yy_globals );
}
-/* %endif if-c-only */
-
-/* %if-c-only */
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
*/
return 0;
}
-/* %endif */
-/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
/* config_lex_destroy is for both reentrant and non-reentrant scanners. */
int config_lex_destroy (yyscan_t yyscanner)
{
* config_lex() is called, initialization will occur. */
yy_init_globals( yyscanner);
-/* %if-reentrant */
/* Destroy the main struct (reentrant only). */
config_free ( yyscanner , yyscanner );
yyscanner = NULL;
-/* %endif */
return 0;
}
-/* %endif */
/*
* Internal utility routines.
free( (char *) ptr ); /* see config_realloc() for (char *) cast */
}
-/* %if-tables-serialization definitions */
-/* %define-yytables The name for this specific scanner's tables. */
#define YYTABLES_NAME "yytables"
-/* %endif */
-
-/* %ok-for-header */
-#line 223 "libmemcached/csl/scanner.l"
+#line 217 "libmemcached/csl/scanner.l"
void Context::destroy_scanner()
{
+ (void)yy_fatal_error; // Removes warning about unused yy_fatal_error()
config_lex_destroy(scanner);
}
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
-#define YY_NO_INPUT
-
#define YY_EXTRA_TYPE Context*
-#line 28 "libmemcached/csl/scanner.h"
+#line 26 "libmemcached/csl/scanner.h"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
-/* %not-for-header */
-
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define FLEX_BETA
#endif
-/* %if-c++-only */
-/* %endif */
-
-/* %if-c-only */
-
-/* %endif */
-
-/* %if-c-only */
-
-/* %endif */
-
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
-/* %if-c-only */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
-/* %endif */
-/* %if-tables-serialization */
-/* %endif */
/* end standard C headers. */
-/* %if-c-or-c++ */
/* flex integer type definitions */
#ifndef FLEXINT_H
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define UINT32_MAX (4294967295U)
#endif
-#endif /* ! C99 */
-
#endif /* ! FLEXINT_H */
-/* %endif */
-
-/* %if-c++-only */
-/* %endif */
-
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define yyconst
#endif
-/* %not-for-header */
-
-/* %not-for-header */
-
-/* %if-reentrant */
-
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-/* %endif */
-
-/* %if-not-reentrant */
-/* %endif */
-
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
-/* %if-not-reentrant */
-/* %endif */
-
-/* %if-c-only */
-/* %if-not-reentrant */
-/* %endif */
-/* %endif */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
-/* %if-c-only */
FILE *yy_input_file;
-/* %endif */
-
-/* %if-c++-only */
-/* %endif */
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-/* %if-c-only Standard (non-C++) definition */
-/* %not-for-header */
-
-/* %endif */
-
-/* %if-c-only Standard (non-C++) definition */
-
-/* %if-not-reentrant */
-/* %not-for-header */
-
-/* %endif */
-
void config_restart (FILE *input_file ,yyscan_t yyscanner );
void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
-/* %endif */
-
void *config_alloc (yy_size_t ,yyscan_t yyscanner );
void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner );
void config_free (void * ,yyscan_t yyscanner );
-/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
/* Begin user sect3 */
#define config_wrap(n) 1
#define YY_SKIP_YYWRAP
-#define FLEX_DEBUG
-
#define yytext_ptr yytext_r
-/* %if-c-only Standard (non-C++) definition */
-
-/* %endif */
-
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
-/* %if-c-only */
#include <unistd.h>
-/* %endif */
-/* %if-c++-only */
-/* %endif */
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
-/* %if-c-only Reentrant structure and macros (non-C++). */
-/* %if-reentrant */
-
-/* %if-c-only */
-
-/* %endif */
-
-/* %if-reentrant */
-
int config_lex_init (yyscan_t* scanner);
int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
-/* %endif */
-
-/* %endif End reentrant structures and macros. */
-
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
void config_set_lineno (int line_number ,yyscan_t yyscanner );
-/* %if-bison-bridge */
+int config_get_column (yyscan_t yyscanner );
+
+void config_set_column (int column_no ,yyscan_t yyscanner );
YYSTYPE * config_get_lval (yyscan_t yyscanner );
void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
-/* %endif */
-
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#endif
#endif
-/* %not-for-header */
-
-/* %endif */
-
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#endif
#ifndef YY_NO_INPUT
-/* %if-c-only Standard (non-C++) definition */
-/* %not-for-header */
-/* %endif */
#endif
-/* %if-c-only */
-
-/* %endif */
-
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#define YY_START_STACK_INCR 25
#endif
-/* %if-tables-serialization structures and prototypes */
-/* %not-for-header */
-
-/* %not-for-header */
-
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-/* %if-c-only Standard (non-C++) definition */
extern int config_lex \
(YYSTYPE * yylval_param ,yyscan_t yyscanner);
#define YY_DECL int config_lex \
(YYSTYPE * yylval_param , yyscan_t yyscanner)
-/* %endif */
-/* %if-c++-only C++ definition */
-/* %endif */
#endif /* !YY_DECL */
-/* %not-for-header */
-
-/* %if-c++-only */
-/* %not-for-header */
-
-/* %endif */
-
/* yy_get_previous_state - get the state just before the EOB char was reached */
-/* %if-c-only */
-/* %not-for-header */
-
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef YY_DECL
#endif
-#line 223 "libmemcached/csl/scanner.l"
+#line 217 "libmemcached/csl/scanner.l"
-#line 493 "libmemcached/csl/scanner.h"
+#line 362 "libmemcached/csl/scanner.h"
#undef config_IN_HEADER
#endif /* config_HEADER_H */
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
-#define YY_NO_INPUT
-
#define YY_EXTRA_TYPE Context*
}
} \
}
+#define YY_FATAL_ERROR(msg) \
+{ \
+}
+
#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
%option 8bit
%option bison-bridge
+%option never-interactive
%option case-insensitive
-%option debug
+%option noinput
%option nounput
%option noyywrap
%option outfile="libmemcached/csl/scanner.cc" header-file="libmemcached/csl/scanner.h"
%option perf-report
%option prefix="config_"
%option reentrant
+%option warn
%%
JENKINS { return JENKINS; }
(([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) {
- yylval->server.port= MEMCACHED_DEFAULT_PORT;
- yylval->server.weight= 1;
- yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
- if (yylval->server.c_str)
- yylval->server.size= yyleng;
+ yyextra->hostname(yytext, yyleng, yylval->server);
return IPADDRESS;
}
[[:alnum:]]["."[:alnum:]_-]+[[:alnum:]] {
if (yyextra->is_server())
{
- yylval->server.port= MEMCACHED_DEFAULT_PORT;
- yylval->server.weight= 1;
- yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
- if (yylval->server.c_str)
- yylval->server.size= yyleng;
+ yyextra->hostname(yytext, yyleng, yylval->server);
return HOSTNAME;
}
- yylval->string.c_str = yytext;
- yylval->string.size = yyleng;
+ yyextra->string_buffer(yytext, yyleng, yylval->string);
return STRING;
}
L?\"(\\.|[^\\"])*\" {
yyget_text(yyscanner)[yyleng -1]= 0;
- yylval->string.c_str= yytext +1;
- yylval->string.size= yyleng -2;
+ yyextra->string_buffer(yytext +1, yyleng -2, yylval->string);
return QUOTED_STRING;
}
void Context::destroy_scanner()
{
+ (void)yy_fatal_error; // Removes warning about unused yy_fatal_error()
yylex_destroy(scanner);
}
struct server_t
{
- in_port_t port;
- uint32_t weight;
const char *c_str;
size_t size;
+ in_port_t port;
+ uint32_t weight;
};
vector[0].length= UDP_DATAGRAM_HEADER_LENGTH;
msg.msg_iov= (struct iovec*)vector;
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+ msg.msg_iovlen= int(count);
+#else
msg.msg_iovlen= count;
+#endif
uint32_t retry= 5;
while (--retry)
rc= MEMCACHED_CONNECTION_FAILURE;
}
+ if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
+
if (local_errno == EINVAL)
{
rc= MEMCACHED_INVALID_ARGUMENTS;
self.error_messages= NULL;
}
+const char *memcached_error(const memcached_st *memc)
+{
+ return memcached_last_error_message(memc);
+}
+
const char *memcached_last_error_message(const memcached_st *memc)
{
- if (memc == NULL)
+ if (memc)
{
- return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS);
- }
+ if (memc->error_messages)
+ {
+ if (memc->error_messages->size == 0)
+ {
+ return memc->error_messages->message;
+ }
- if (memc->error_messages == NULL)
- {
- return memcached_strerror(memc, MEMCACHED_SUCCESS);
- }
+ return memcached_strerror(memc, memc->error_messages->rc);
+ }
- if (memc->error_messages->size == 0)
- {
- return memcached_strerror(memc, memc->error_messages->rc);
+ return memcached_strerror(memc, MEMCACHED_SUCCESS);
}
- return memc->error_messages->message;
+ return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS);
}
bool memcached_has_current_error(memcached_st &memc)
memcached_return_t memcached_last_error(const memcached_st *memc)
{
- if (memc == NULL)
+ if (memc)
{
- return MEMCACHED_INVALID_ARGUMENTS;
- }
+ if (memc->error_messages)
+ {
+ return memc->error_messages->rc;
+ }
- if (memc->error_messages == NULL)
- {
return MEMCACHED_SUCCESS;
}
- return memc->error_messages->rc;
+ return MEMCACHED_INVALID_ARGUMENTS;
}
int memcached_last_error_errno(const memcached_st *memc)
{
assert_msg(ptr, "Programmer mistake, somehow server_add() was passed a NULL memcached_st");
- org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (ptr->number_of_hosts + 1), org::libmemcached::Instance);
+ if (ptr->number_of_hosts)
+ {
+ assert(memcached_instance_list(ptr));
+ }
+
+ if (memcached_instance_list(ptr))
+ {
+ assert(ptr->number_of_hosts);
+ }
+
+ uint32_t host_list_size= ptr->number_of_hosts +1;
+ org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance);
if (new_host_list == NULL)
{
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
}
- memcached_instance_set(ptr, new_host_list);
+ memcached_instance_set(ptr, new_host_list, host_list_size);
+ assert(ptr->number_of_hosts == host_list_size);
/* TODO: Check return type */
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr));
+ org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr) -1);
if (__instance_create_with(ptr, instance, hostname, port, weight, type) == NULL)
{
}
}
- ptr->number_of_hosts++;
-
return run_distribution(ptr);
}
return MEMCACHED_SUCCESS;
}
+ uint32_t original_host_size= memcached_server_count(ptr);
uint32_t count= memcached_server_list_count(list);
+ uint32_t host_list_size= count +original_host_size;
- org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (count + memcached_server_count(ptr)), org::libmemcached::Instance);
+ org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance);
if (new_host_list == NULL)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
- memcached_instance_set(ptr, new_host_list);
+ memcached_instance_set(ptr, new_host_list, host_list_size);
- for (uint32_t x= 0; x < count; x++)
+ ptr->state.is_parsing= true;
+ for (uint32_t x= 0; x < count; ++x, ++original_host_size)
{
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
// We have extended the array, and now we will find it, and use it.
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr));
+ org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size);
WATCHPOINT_ASSERT(instance);
memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
hostname,
list[x].port, list[x].weight, list[x].type) == NULL)
{
+ ptr->state.is_parsing= false;
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
}
{
memcached_set_weighted_ketama(ptr, true);
}
-
- ptr->number_of_hosts++;
}
+ ptr->state.is_parsing= false;
return run_distribution(ptr);
}
return MEMCACHED_SUCCESS;
}
- org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (number_of_hosts +memcached_server_count(ptr)), org::libmemcached::Instance);
+ uint32_t original_host_size= memcached_server_count(ptr);
+ uint32_t host_list_size= number_of_hosts +original_host_size;
+ org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance);
if (new_host_list == NULL)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
}
- memcached_instance_set(ptr, new_host_list);
+ memcached_instance_set(ptr, new_host_list, host_list_size);
- for (uint32_t x= 0; x < number_of_hosts; x++)
- {
+ // We don't bother with lookups for this operation
+ ptr->state.is_parsing= true;
+ // We use original_host_size since size will now point to the first new
+ // instance allocated.
+ for (uint32_t x= 0; x < number_of_hosts; ++x, ++original_host_size)
+ {
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
// We have extended the array, and now we will find it, and use it.
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr));
+ org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size);
WATCHPOINT_ASSERT(instance);
memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
hostname,
list[x].port(), list[x].weight, list[x].type) == NULL)
{
+ ptr->state.is_parsing= false;
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
}
{
memcached_set_weighted_ketama(ptr, true);
}
-
- ptr->number_of_hosts++;
}
+ ptr->state.is_parsing= false;
return run_distribution(ptr);
}
self->address_info= NULL;
self->address_info_next= NULL;
}
+ assert(self->address_info_next == NULL);
memcached_error_free(*self);
void set_last_disconnected_host(org::libmemcached::Instance* self)
{
assert(self->root);
- if (self->root == NULL)
+ if (self->root)
{
- return;
- }
+ if (memcached_server_get_last_disconnect(self->root) and
+ memcached_server_get_last_disconnect(self->root)->version == self->version)
+ {
+ return;
+ }
- if (memcached_server_get_last_disconnect(self->root) and
- memcached_server_get_last_disconnect(self->root)->version == self->version)
- {
- return;
- }
+ // const_cast
+ memcached_st *root= (memcached_st *)self->root;
- // const_cast
- memcached_st *root= (memcached_st *)self->root;
+ memcached_instance_free((org::libmemcached::Instance*)(root->last_disconnected_server));
- memcached_instance_free((org::libmemcached::Instance*)(root->last_disconnected_server));
- root->last_disconnected_server= memcached_instance_clone(self);
- ((org::libmemcached::Instance*)memcached_server_get_last_disconnect(root))->version= self->version;
+ // We set is_parsing so that no lookup happens
+ root->state.is_parsing= true;
+ root->last_disconnected_server= memcached_instance_clone(self);
+ root->state.is_parsing= false;
+
+ ((org::libmemcached::Instance*)memcached_server_get_last_disconnect(root))->version= self->version;
+ }
}
memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *self)
{
memcached_instance_list_free(memcached_instance_list(self), self->number_of_hosts);
- memcached_instance_set(self, NULL);
+ memcached_instance_set(self, NULL, 0);
self->number_of_hosts= 0;
memcached_instance_free((org::libmemcached::Instance*)self->last_disconnected_server);
self->last_disconnected_server= NULL;
const char *memcached_server_name(const memcached_server_instance_st self)
{
WATCHPOINT_ASSERT(self);
- if (self == NULL)
- return NULL;
+ if (self)
+ {
+ return self->hostname;
+ }
- return self->hostname;
+ return NULL;
}
in_port_t memcached_server_port(const memcached_server_instance_st self)
: self->number_of_hosts;
}
-void memcached_instance_set(memcached_st* memc, org::libmemcached::Instance* list)
+void memcached_instance_set(memcached_st* memc, org::libmemcached::Instance* list, const uint32_t host_list_size)
{
memc->servers= list;
+ memc->number_of_hosts= host_list_size;
}
void memcached_server_list_free(memcached_server_list_st self)
{
- if (self == NULL)
+ if (self)
{
- return;
- }
+ for (uint32_t x= 0; x < memcached_server_list_count(self); x++)
+ {
+ assert_msg(not memcached_is_allocated(&self[x]), "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st");
+ __server_free(&self[x]);
+ }
- for (uint32_t x= 0; x < memcached_server_list_count(self); x++)
- {
- assert_msg(not memcached_is_allocated(&self[x]), "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st");
- __server_free(&self[x]);
+ libmemcached_free(self->root, self);
}
-
- libmemcached_free(self->root, self);
}
void memcached_instance_list_free(org::libmemcached::Instance* self, uint32_t instance_count)
{
- if (self == NULL)
+ if (self)
{
- return;
- }
+ for (uint32_t x= 0; x < instance_count; x++)
+ {
+ assert_msg(memcached_is_allocated(&self[x]) == false, "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st");
+ __instance_free(&self[x]);
+ }
- for (uint32_t x= 0; x < instance_count; x++)
- {
- assert_msg(not memcached_is_allocated(&self[x]), "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st");
- __instance_free(&self[x]);
+ libmemcached_free(self->root, self);
}
-
- libmemcached_free(self->root, self);
}
void memcached_instance_list_free(org::libmemcached::Instance* self, uint32_t count);
-void memcached_instance_set(memcached_st*, org::libmemcached::Instance*);
+void memcached_instance_set(memcached_st*, org::libmemcached::Instance*, const uint32_t host_list_size);
return self;
}
+static memcached_return_t memcached_string_append_null(memcached_string_st& string)
+{
+ if (memcached_failed(_string_check(&string, 1)))
+ {
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
+
+ *string.end= 0;
+
+ return MEMCACHED_SUCCESS;
+}
+
static memcached_return_t memcached_string_append_null(memcached_string_st *string)
{
if (memcached_failed(_string_check(string, 1)))
return c_ptr;
}
+bool memcached_string_set(memcached_string_st& string, const char* value, size_t length)
+{
+ memcached_string_reset(&string);
+ if (memcached_success(memcached_string_append(&string, value, length)))
+ {
+ memcached_string_append_null(string);
+ return true;
+ }
+
+ return false;
+}
+
void memcached_string_reset(memcached_string_st *string)
{
string->end= string->string;
char *memcached_string_value_mutable(const memcached_string_st *self);
+bool memcached_string_set(memcached_string_st&, const char*, size_t);
+
void memcached_string_set_length(memcached_string_st *self, size_t length);
void memcached_string_set_length(memcached_string_st&, const size_t length);
return false;
}
- (void)memcached_behavior_set(memc_ptr, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 400000);
-
- memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port);
- if (memcached_success(rc))
- {
- rc= memcached_version(memc_ptr);
- }
-
- if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS)
+ if (memcached_success((*ret= memcached_behavior_set(memc_ptr, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 400000))))
{
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc_ptr, 0);
+ memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port);
+ if (memcached_success(rc))
+ {
+ rc= memcached_version(memc_ptr);
+ }
- assert_msg(instance and memcached_server_error(instance), " ");
- if (instance and memcached_server_error(instance))
+ if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS)
{
- rc= memcached_server_error_return(instance);
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc_ptr, 0);
+
+ assert_msg(instance and memcached_server_error(instance), " ");
+ if (instance and memcached_server_error(instance))
+ {
+ rc= memcached_server_error_return(instance);
+ }
}
+
+ *ret= rc;
}
memcached_free(memc_ptr);
- *ret= rc;
-
- return memcached_success(rc);
+ return memcached_success(*ret);
}
bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret)
#
LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute
-VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE --xml-file=./tmp_chroot/var/tmp/yatl-\%p.xml --xml=yes
+VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
VALGRIND_COMMAND= TESTS_ENVIRONMENT="valgrind" $(VALGRIND_EXEC_COMMAND)
HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 --read-var-info=yes
DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd
# The Following flags are not checked for
# -Wdeclaration-after-statement is counter to C99
+# AX_APPEND_COMPILE_FLAGS([-std=c++11]) -- Not ready yet
+# AX_APPEND_COMPILE_FLAGS([-pedantic]) -- ?
+# AX_APPEND_COMPILE_FLAGS([-Wstack-protector]) -- Issues on 32bit compile
+# AX_APPEND_COMPILE_FLAGS([-fstack-protector-all]) -- Issues on 32bit compile
#serial 1
-AC_DEFUN([AX_HARDEN_COMPILER_FLAGS],
-[AC_REQUIRE([AX_APPEND_COMPILE_FLAGS])
-AC_REQUIRE([AX_CHECK_LINK_FLAG])
-AC_LANG_PUSH([C])
-AX_APPEND_COMPILE_FLAGS([-O2])
-AX_APPEND_COMPILE_FLAGS([-Werror])
-AX_APPEND_COMPILE_FLAGS([-Wall])
-AX_APPEND_COMPILE_FLAGS([-Wextra])
-AX_APPEND_COMPILE_FLAGS([-std=c99])
-AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast])
-AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
-AX_APPEND_COMPILE_FLAGS([-Wnested-externs])
-AX_APPEND_COMPILE_FLAGS([-Wold-style-definition])
-AX_APPEND_COMPILE_FLAGS([-Woverride-init])
-AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
-AC_LANG_POP
-AC_LANG_PUSH([C++])
-AX_APPEND_COMPILE_FLAGS([-O2])
-AX_APPEND_COMPILE_FLAGS([-Werror])
-AX_APPEND_COMPILE_FLAGS([-Wall])
-AX_APPEND_COMPILE_FLAGS([-Wextra])
-dnl AX_APPEND_COMPILE_FLAGS([-std=c++11])
-AX_APPEND_COMPILE_FLAGS([-Wpragmas])
-dnl AX_APPEND_COMPILE_FLAGS([-pedantic])
-AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1])
-AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2])
-AX_APPEND_COMPILE_FLAGS([-Waddress])
-AX_APPEND_COMPILE_FLAGS([-Warray-bounds])
-AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts])
-AX_APPEND_COMPILE_FLAGS([-Wcomment])
-AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy])
-AX_APPEND_COMPILE_FLAGS([-Wfloat-equal])
-AX_APPEND_COMPILE_FLAGS([-Wformat=2])
-dnl AX_APPEND_COMPILE_FLAGS([-Wlong-long])
-AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized])
-AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers])
-AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn])
-AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor])
-AX_APPEND_COMPILE_FLAGS([-Wnormalized=id])
-AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual])
-AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
-AX_APPEND_COMPILE_FLAGS([-Wredundant-decls])
-AX_APPEND_COMPILE_FLAGS([-Wshadow])
-AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32])
-AX_APPEND_COMPILE_FLAGS([-Wsign-compare])
-AX_APPEND_COMPILE_FLAGS([-Wstack-protector])
-AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1])
-AX_APPEND_COMPILE_FLAGS([-Wswitch-enum])
-AX_APPEND_COMPILE_FLAGS([-Wundef])
-AX_APPEND_COMPILE_FLAGS([-Wunused-result])
-AX_APPEND_COMPILE_FLAGS([-Wunused-variable])
-AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
-AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all])
-AX_APPEND_COMPILE_FLAGS([-fstack-protector-all])
-AX_APPEND_COMPILE_FLAGS([-fwrapv])
-AX_APPEND_COMPILE_FLAGS([-ggdb])
-AX_CHECK_LINK_FLAG([-Werror])
-AX_CHECK_LINK_FLAG([-z relro -z now])
-AC_LANG_POP
-])dnl AX_HARDEN_COMPILER_FLAGS
+ AC_DEFUN([AX_HARDEN_C_COMPILER_FLAGS], [
+ AC_REQUIRE([AX_APPEND_COMPILE_FLAGS])
+ AC_REQUIRE([AX_CHECK_LINK_FLAG])
+ AC_REQUIRE([AX_VCS_CHECKOUT])
+
+ AC_LANG_PUSH([C])
+ AX_APPEND_COMPILE_FLAGS([-O2])
+ AX_APPEND_COMPILE_FLAGS([-Werror])
+ AX_APPEND_COMPILE_FLAGS([-Wall])
+ AX_APPEND_COMPILE_FLAGS([-Wextra])
+ AX_APPEND_COMPILE_FLAGS([-std=c99])
+ AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast])
+ AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
+ AX_APPEND_COMPILE_FLAGS([-Wnested-externs])
+ AX_APPEND_COMPILE_FLAGS([-Wold-style-definition])
+ AX_APPEND_COMPILE_FLAGS([-Woverride-init])
+ AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
+ AC_LANG_POP
+ ])
+
+ AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [
+ AC_REQUIRE([AX_HARDEN_C_COMPILER_FLAGS])
+ AC_LANG_PUSH([C++])
+ AX_APPEND_COMPILE_FLAGS([-O2])
+ AX_APPEND_COMPILE_FLAGS([-Werror])
+ AX_APPEND_COMPILE_FLAGS([-Wall])
+ AX_APPEND_COMPILE_FLAGS([-Wextra])
+ AX_APPEND_COMPILE_FLAGS([-Wpragmas])
+ AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1])
+ AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2])
+ AX_APPEND_COMPILE_FLAGS([-Waddress])
+ AX_APPEND_COMPILE_FLAGS([-Warray-bounds])
+ AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts])
+ AX_APPEND_COMPILE_FLAGS([-Wcomment])
+ AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy])
+ AX_APPEND_COMPILE_FLAGS([-Wfloat-equal])
+ AX_APPEND_COMPILE_FLAGS([-Wformat=2])
+ AX_APPEND_COMPILE_FLAGS([-Wlong-long])
+ AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized])
+ AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers])
+ AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn])
+ AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor])
+ AX_APPEND_COMPILE_FLAGS([-Wnormalized=id])
+ AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual])
+ AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
+ AX_APPEND_COMPILE_FLAGS([-Wredundant-decls])
+ AX_APPEND_COMPILE_FLAGS([-Wshadow])
+ AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32])
+ AX_APPEND_COMPILE_FLAGS([-Wsign-compare])
+ AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1])
+ AX_APPEND_COMPILE_FLAGS([-Wswitch-enum])
+ AX_APPEND_COMPILE_FLAGS([-Wundef])
+ AX_APPEND_COMPILE_FLAGS([-Wunused-result])
+ AX_APPEND_COMPILE_FLAGS([-Wunused-variable])
+ AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
+ AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all])
+ AX_APPEND_COMPILE_FLAGS([-fwrapv])
+ AX_APPEND_COMPILE_FLAGS([-ggdb])
+ AX_CHECK_LINK_FLAG([-Werror])
+ AX_CHECK_LINK_FLAG([-z relro -z now])
+ AC_LANG_POP
+ ])
#
# SYNOPSIS
#
-# AX_LIB_UUID
+# AX_PTHREAD_TIMEDJOIN_NP
#
# DESCRIPTION
#
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 2
+#serial 3
AC_DEFUN([AX_PTHREAD_TIMEDJOIN_NP], [
- AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np], [
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$PTHREAD_LIBS"
- AC_LANG_PUSH([C])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([
-#include <uuid/uuid.h>
- ], [
- uuid_t out;
- pthread_timedjoin_np(out);
- ]), [ax_cv_pthread_timedjoin_np=yes ], [ax_cv_pthread_timedjoin_np=no ]
- ])
+ AC_REQUIRE([AX_PTHREAD])
+ AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np], [
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$PTHREAD_LIBS"
+ AC_LANG_PUSH([C])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
- AC_LANG_POP
- LDFLAGS="$save_LDFLAGS"
+#include <stdlib.h>
+#include <pthread.h>
+ ], [
+ pthread_t thread;
+ pthread_timedjoin_np(thread, NULL);
+ ])],
+ [ax_cv_pthread_timedjoin_np=yes],
+ [])
- ])
+ AC_LANG_POP
+ LDFLAGS="$save_LDFLAGS"
- AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],[
- AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],[
- AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.])
- ])
-])
+ ])
+
+ AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],[
+ AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],[
+ AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.])
+ ])
+ ])
-dnl CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
-AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [{
- AC_MSG_CHECKING(whether SOCK_CLOEXEC is supported)
- AC_TRY_RUN([/* SOCK_CLOEXEC test */
+# Author?
+# AX_CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
+#
+
+#serial 1
+
+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 main (int argc, char *argv [])
-{
- int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
- return (s == -1);
-}
- ],
- [AC_MSG_RESULT(yes) ; ax_cv_sock_cloexec="yes" ; $1],
- [AC_MSG_RESULT(no) ; ax_cv_sock_cloexec="no" ; $2],
- [AC_MSG_RESULT(not during cross-compile) ; ax_cv_sock_cloexec="no"]
- )
-}])
+ ], [
+ int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ return (s == -1);
+ ])],
+ [ax_cv_sock_cloexec=yes],
+ [ax_cv_sock_cloexec=no])
+ ])
+
+ AS_IF([test x"ax_cv_sock_cloexec" = xyes], [AC_MSG_RESULT([yes]) ; $1], AC_MSG_RESULT([no]) ; $2)
+ ])
--- /dev/null
+AC_DEFUN([AX_DEBUG],[
+ AC_ARG_WITH([debug],
+ [AS_HELP_STRING([--with-debug],
+ [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
+ [with_debug=$withval],
+ [with_debug=no])
+ AS_IF([test "$with_debug" = "yes"],[
+ # Debugging. No optimization.
+ AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG"
+ AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG"
+ AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.])
+ ],[
+ # Optimized version. No debug
+ AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}"
+ AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}"
+ AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.])
+ ])
+])
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 1
+#serial 2
-
-AC_DEFUN([AX_CXX_CINTTYPES],
- [
+AC_DEFUN([AX_CXX_CINTTYPES], [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([AC_PROG_CXXCPP])
AC_REQUIRE([AX_CXX_CSTDINT])
- AC_MSG_CHECKING(the location of cinttypes)
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
- ac_cv_cxx_cinttypes=""
- AC_LANG_PUSH([C++])
-# AC_CACHE_CHECK([for location of cinttypes], [ac_cv_cxx_cinttypes],
-# [
-# Look for cinttypes
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <cinttypes>], [ uint32_t foo= UINT32_C(1) ])],
- [ac_cv_cxx_cinttypes="<cinttypes>"],
- [
+ AC_CACHE_CHECK([for location of cinttypes], [ac_cv_cxx_cinttypes], [
+ save_CXXFLAGS="${CXXFLAGS}"
+ CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
+ AC_LANG_PUSH([C++])
+
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <cinttypes>], [
+ uint32_t foo= UINT32_C(1);
+ ])],
+ [ac_cxx_cinttypes_cinttypes="<cinttypes>"])
+
# Look for tr1/cinttypes
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <tr1/cinttypes>], [ uint32_t foo= UINT32_C(1) ])],
- [ac_cv_cxx_cinttypes="<tr1/cinttypes>"],
- [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <tr1/cinttypes>], [
+ uint32_t foo= UINT32_C(1);
+ ])],
+ [ac_cxx_cinttypes_tr1_cinttypes="<tr1/cinttypes>"])
+
# Look for boost/cinttypes.hpp
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <boost/cinttypes.hpp>], [ uint32_t foo= UINT32_C(1) ])],
- [ac_cv_cxx_cinttypes="<boost/cinttypes.hpp>"])
- ])
- ])
-# ])
- AC_LANG_POP()
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <boost/cinttypes.hpp>], [
+ uint32_t foo= UINT32_C(1);
+ ])],
+ [ac_cxx_cinttypes_boost_cinttypes_hpp="<boost/cinttypes.hpp>"])
+
+ AC_LANG_POP
+ CXXFLAGS="${save_CXXFLAGS}"
+
+ AS_IF([test -n "$ac_cxx_cinttypes_cinttypes"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_cinttypes],
+ [test -n "$ac_cxx_cinttypes_tr1_cinttypes"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_tr1_cinttypes],
+ [test -n "$ac_cxx_cinttypes_boost_cinttypes_hpp"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_boost_cinttypes_hpp])
+ ])
- CXXFLAGS="${save_CXXFLAGS}"
- if test -n "$ac_cv_cxx_cinttypes"; then
- AC_MSG_RESULT([$ac_cv_cxx_cinttypes])
- else
- ac_cv_cxx_cinttypes="<inttypes.h>"
- AC_MSG_WARN([Could not find a cinttypes header.])
- AC_MSG_RESULT([$ac_cv_cxx_cinttypes])
- fi
+ AS_IF([ test -n "$ac_cv_cxx_cinttypes"], [
+ AC_MSG_RESULT([$ac_cv_cxx_cinttypes])
+ ],[
+ ac_cv_cxx_cinttypes="<inttypes.h>"
+ AC_MSG_WARN([Could not find a cinttypes header.])
+ AC_MSG_RESULT([$ac_cv_cxx_cinttypes])
+ ])
AC_DEFINE([__STDC_LIMIT_MACROS],[1],[Use STDC Limit Macros in C++])
- AC_DEFINE_UNQUOTED(CINTTYPES_H,$ac_cv_cxx_cinttypes, [the location of <cinttypes>])
+ AC_DEFINE_UNQUOTED([CINTTYPES_H],[$ac_cv_cxx_cinttypes],[the location of <cinttypes>])
])
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 1
+#serial 2
-AC_DEFUN([AX_CXX_CSTDINT],
- [
+AC_DEFUN([AX_CXX_CSTDINT], [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([AC_PROG_CXXCPP])
- AC_MSG_CHECKING(the location of cstdint)
- AC_LANG_PUSH([C++])
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
- ac_cv_cxx_cstdint=""
+ AC_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint], [
+ AC_LANG_PUSH([C++])
+ save_CXXFLAGS="${CXXFLAGS}"
+ CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
- AC_LANG_PUSH([C++])
-# AC_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint],
-# [
-# Look for cstdint
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <cstdint>], [ uint32_t t ])],
- [ac_cv_cxx_cstdint="<cstdint>"],
- [
-# Look for tr1/cstdint
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <tr1/cstdint>], [ uint32_t t ])],
- [ac_cv_cxx_cstdint="<tr1/cstdint>"],
- [
-# Look for boost/cstdint.hpp
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <boost/cstdint.hpp>], [ uint32_t t ])],
- [ac_cv_cxx_cstdint="<boost/cstdint.hpp>"])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <cstdint>], [ uint32_t t ])],
+ [ac_cxx_cstdint_cstdint="<cstdint>"])
- ])
- ])
-# ])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <tr1/cstdint>], [ uint32_t t ])],
+ [ac_cxx_cstdint_tr1_cstdint="<tr1/cstdint>"])
- AC_LANG_POP()
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <boost/cstdint.hpp>], [ uint32_t t ])],
+ [ac_cxx_cstdint_boost_cstdint_hpp="<boost/cstdint.hpp>"])
- CXXFLAGS="${save_CXXFLAGS}"
- if test -n "$ac_cv_cxx_cstdint"; then
- AC_MSG_RESULT([$ac_cv_cxx_cstdint])
- else
- ac_cv_cxx_cstdint="<stdint.h>"
- AC_MSG_WARN([Could not find a cstdint header.])
- AC_MSG_RESULT([$ac_cv_cxx_cstdint])
- fi
+ AC_LANG_POP
+ CXXFLAGS="${save_CXXFLAGS}"
- AC_DEFINE_UNQUOTED(CSTDINT_H,$ac_cv_cxx_cstdint, [the location of <cstdint>])
+ AS_IF([test -n "$ac_cxx_cstdint_cstdint"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_cstdint],
+ [test -n "$ac_cxx_cstdint_tr1_cstdint"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_tr1_cstdint],
+ [test -n "$ac_cxx_cstdint_boost_cstdint_hpp"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_boost_cstdint_hpp])
+ ])
+
+ AS_IF([test -n "$ac_cv_cxx_cstdint"], [
+ AC_MSG_RESULT([$ac_cv_cxx_cstdint])
+ ],[
+ ac_cv_cxx_cstdint="<stdint.h>"
+ AC_MSG_WARN([Could not find a cstdint header.])
+ AC_MSG_RESULT([$ac_cv_cxx_cstdint])
+ ])
+
+AC_DEFINE_UNQUOTED([CSTDINT_H],[$ac_cv_cxx_cstdint], [the location of <cstdint>])
])
#
# SYNOPSIS
#
-# AX_LIB_UUID
+# AX_UUID
+# AX_UUID_GENERATE_TIME_SAFE
#
# DESCRIPTION
#
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 2
+#serial 3
-AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], [
- AC_CACHE_CHECK([check for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="-luuid"
- AC_LANG_PUSH([C])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([
-#include <uuid/uuid.h>
- ], [
- uuid_t out;
- uuid_generate_time_safe(out);
- ]), [ax_cv_uuid_generate_time_safe=yes ], [ax_cv_uuid_generate_time_safe=no ]
- ])
+AC_DEFUN([AX_UUID], [
+ AC_CHECK_HEADER([uuid/uuid.h], [
+ AC_CACHE_CHECK([check to see if -luuid is not needed], [ax_cv_libuuid_is_required], [
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
+ uuid_t out;
+ uuid_generate(out);
+ ])],
+ [ax_cv_libuuid_is_required=no],
+ [ax_cv_libuuid_is_required=maybe],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ ])
+
+ AS_IF([test "$ax_cv_libuuid_is_required" = maybe], [
+ AC_CACHE_CHECK([check to see if -luuid is needed], [ax_cv_libuuid_works], [
+ save_LIBS="$LIBS"
+ LIBS="-luuid $LIBS"
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
+ uuid_t out;
+ uuid_generate(out);
+ ])],
+ [ax_cv_libuuid_works=yes],
+ [ax_cv_libuuid_works=no],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ LIBS="$save_LIBS"
+ ])
+ AS_IF([test "$ax_cv_libuuid_works" = yes], [
+ AC_SUBST([LIBUUID_LDFLAGS],[-luuid])])
+ ])
- AC_LANG_POP
- LDFLAGS="$save_LDFLAGS"
- ])
+ AS_IF([test "$ax_cv_libuuid_is_required" = no], [UUID_UUID_H=yes])
+ AS_IF([test "$ax_cv_libuuid_works" = yes], [UUID_UUID_H=yes])
+ ])
- AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],[
- AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],[
- AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])
+ AS_IF([test "$UUID_UUID_H" = yes], [
+ AC_DEFINE([HAVE_UUID_UUID_H], [1], [Have uuid/uuid.h])
+ ],[
+ AC_DEFINE([HAVE_UUID_UUID_H], [0], [Have uuid/uuid.h])
+ ])
])
-])
+
+ AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], [
+ AC_REQUIRE([AX_UUID])
+ AC_CACHE_CHECK([for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [
+ save_LIBS="$LIBS"
+ LIBS="$LIBUUID_LDFLAGS $LIBS"
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
+ uuid_t out;
+ uuid_generate_time_safe(out);
+ ])],
+ [ax_cv_uuid_generate_time_safe=yes],
+ [ax_cv_uuid_generate_time_safe=no],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ LIBS="$save_LIBS"
+ ])
+
+ AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],[
+ AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],[
+ AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])
+ ])
+ ])
test-memcapable: tests/memcapable
@tests/memcapable
+valgrind-memcapable: tests/memcapable
+ $(VALGRIND_COMMAND) tests/memcapable
+
pahole-mem: tests/testapp
@$(PAHOLE_COMMAND) tests/testapp
check_PROGRAMS+= tests/libmemcached-1.0/testsocket
noinst_PROGRAMS+= tests/libmemcached-1.0/testsocket
+test-socket: tests/libmemcached-1.0/testsocket
+ @tests/libmemcached-1.0/testsocket
+
tests_libmemcached_1_0_sasl_SOURCES=
tests_libmemcached_1_0_sasl_DEPENDENCIES=
tests_libmemcached_1_0_sasl_LDADD=
global_pairs[x].key, global_pairs[x].key_length,
&blob[0], blob.size(),
time_t(0), uint32_t(0));
+ if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
+ {
+ Error << memcached_last_error_message(memc);
+ return TEST_SKIPPED;
+ }
test_compare(*memc, MEMCACHED_SUCCESS);
test_compare(rc, MEMCACHED_SUCCESS);
}
test_return_t util_version_test(memcached_st *memc)
{
- test_compare(MEMCACHED_SUCCESS, memcached_version(memc));
+ test_compare(memcached_version(memc), MEMCACHED_SUCCESS);
test_true(libmemcached_util_version_check(memc, 0, 0, 0));
bool if_successful= libmemcached_util_version_check(memc, 9, 9, 9);
struct socket_weight_t {
const char *socket;
size_t weight;
+ const char* type;
};
static memcached_return_t dump_socket_information(const memcached_st *,
{
socket_weight_t *check= (socket_weight_t *)context;
- if (strcmp(memcached_server_name(instance), check->socket))
+ if (strcmp(memcached_server_type(instance), check->type) == 0)
{
- Error << memcached_server_name(instance) << " != " << check->socket;
- return MEMCACHED_FAILURE;
+ if (strcmp(memcached_server_name(instance), check->socket) == 0)
+ {
+ if (instance->weight == check->weight)
+ {
+ return MEMCACHED_SUCCESS;
+ }
+ else
+ {
+ Error << instance->weight << " != " << check->weight;
+ }
+ }
+ else
+ {
+ Error << "'" << memcached_server_name(instance) << "'" << " != " << "'" << check->socket << "'";
+ }
}
-
- if (instance->weight == check->weight)
+ else
{
- return MEMCACHED_SUCCESS;
+ Error << "'" << memcached_server_type(instance) << "'" << " != " << "'" << check->type << "'";
}
return MEMCACHED_FAILURE;
memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\""));
test_true(memc);
- socket_weight_t check= { "/tmp/foo", 1 };
+ socket_weight_t check= { "/tmp/foo", 1, "SOCKET"};
test_compare(MEMCACHED_SUCCESS,
memcached_server_cursor(memc, callbacks, &check, 1));
memcached_free(memc);
memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"/?23"));
test_true(memc);
- socket_weight_t check= { "/tmp/foo", 23 };
+ socket_weight_t check= { "/tmp/foo", 23, "SOCKET"};
test_compare(MEMCACHED_SUCCESS,
memcached_server_cursor(memc, callbacks, &check, 1));
memcached_free(memc);