verify(strncmp(buffer, "VALUE ", 6) == 0);
char *end= strchr(buffer + 6, ' ');
verify(end != NULL);
- *end= '\0';
+ if (end)
+ {
+ *end= '\0';
+ }
*key= strdup(buffer + 6);
verify(*key != NULL);
char *ptr= end + 1;
*ndata = (ssize_t)strtoul(end, &end, 10); /* size */
verify(ptr != end);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
++end;
- verify(*end == '\n');
+ verify(end and *end == '\n');
*value= static_cast<char*>(malloc((size_t)*ndata));
verify(*value != NULL);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
+ {
++end;
- verify(*end == '\n');
+ }
+ verify(end and *end == '\n');
execute(retry_read(buffer, datasize));
verify(memcmp(buffer, value, datasize) == 0);
verify(val == datasize);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
+ {
++end;
- verify(*end == '\n');
+ }
+ verify(end and *end == '\n');
execute(retry_read(buffer, datasize));
verify(memcmp(buffer, value, datasize) == 0);
set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */
if (!strcasecmp(opt_hash, "CRC"))
+ {
set= MEMCACHED_HASH_CRC;
+ }
else if (!strcasecmp(opt_hash, "FNV1_64"))
+ {
set= MEMCACHED_HASH_FNV1_64;
+ }
else if (!strcasecmp(opt_hash, "FNV1A_64"))
+ {
set= MEMCACHED_HASH_FNV1A_64;
+ }
else if (!strcasecmp(opt_hash, "FNV1_32"))
+ {
set= MEMCACHED_HASH_FNV1_32;
+ }
else if (!strcasecmp(opt_hash, "FNV1A_32"))
+ {
set= MEMCACHED_HASH_FNV1A_32;
+ }
else
{
fprintf(stderr, "hash: type not recognized %s\n", opt_hash);
AC_CHECK_FUNCS([strtol])
AC_CHECK_FUNCS([strtoul])
AC_CHECK_FUNCS([strtoull])
+
AC_CHECK_HEADERS([arpa/inet.h])
AC_CHECK_HEADERS([fcntl.h])
AC_CHECK_HEADERS([libintl.h])
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([sasl/sasl.h])
+AC_CXX_HEADER_STDCXX_98
+
AC_FUNC_ALLOCA
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
#include <libhashkit/common.h>
/* FNV hash'es lifted from Dustin Sallings work */
-static uint64_t FNV_64_INIT= 0xcbf29ce484222325LLU;
-static uint64_t FNV_64_PRIME= 0x100000001b3LLU;
+static uint64_t FNV_64_INIT= 0xcbf29ce484222325;
+static uint64_t FNV_64_PRIME= 0x100000001b3;
-uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context)
+uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *)
{
/* Thanks to pierre@demartines.com for the pointer */
uint64_t hash= FNV_64_INIT;
- (void)context;
for (size_t x= 0; x < key_length; x++)
{
return (uint32_t)hash;
}
-uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context)
+uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *)
{
uint32_t hash= (uint32_t) FNV_64_INIT;
- (void)context;
for (size_t x= 0; x < key_length; x++)
{
rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ return memcached_set_error(*instance, rc, MEMCACHED_AT);
+ }
+
/*
So why recheck responce? Because the protocol is brain dead :)
The number returned might end up equaling one of the string
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
+#define YY_NO_INPUT
+
#define YY_EXTRA_TYPE Context*
-#line 21 "libmemcached/csl/scanner.cc"
+#line 23 "libmemcached/csl/scanner.cc"
#define YY_INT_ALIGNED short int
static yyconst flex_int16_t yy_rule_linenum[65] =
{ 0,
- 79, 81, 83, 85, 87, 90, 94, 96, 98, 99,
- 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 127, 128, 130, 132,
- 133, 134, 135, 136, 137, 139, 140, 143, 148, 149,
- 150, 152, 153, 154, 155, 156, 157, 158, 159, 160,
- 162, 171, 189, 196
+ 81, 83, 85, 87, 89, 92, 96, 98, 100, 101,
+ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+ 122, 123, 124, 125, 126, 127, 129, 130, 132, 134,
+ 135, 136, 137, 138, 139, 141, 142, 145, 150, 151,
+ 152, 154, 155, 156, 157, 158, 159, 160, 161, 162,
+ 164, 173, 191, 198
} ;
/* The intent behind this definition is that it'll catch
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#line 40 "libmemcached/csl/scanner.l"
+#line 42 "libmemcached/csl/scanner.l"
#include <cstdlib>
#include <cstring>
#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
-#line 1156 "libmemcached/csl/scanner.cc"
+#line 1158 "libmemcached/csl/scanner.cc"
#define INITIAL 0
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* %% [7.0] user's declarations go here */
-#line 76 "libmemcached/csl/scanner.l"
+#line 78 "libmemcached/csl/scanner.l"
-#line 1463 "libmemcached/csl/scanner.cc"
+#line 1465 "libmemcached/csl/scanner.cc"
yylval = yylval_param;
case 1:
YY_RULE_SETUP
-#line 79 "libmemcached/csl/scanner.l"
+#line 81 "libmemcached/csl/scanner.l"
{ return yytext[0];}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 81 "libmemcached/csl/scanner.l"
+#line 83 "libmemcached/csl/scanner.l"
{ yylval->number= atoi(yytext); return (NUMBER); }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 83 "libmemcached/csl/scanner.l"
+#line 85 "libmemcached/csl/scanner.l"
{ yylval->number= atoi(yytext +1); return PORT; }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 85 "libmemcached/csl/scanner.l"
+#line 87 "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 87 "libmemcached/csl/scanner.l"
+#line 89 "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 90 "libmemcached/csl/scanner.l"
+#line 92 "libmemcached/csl/scanner.l"
{
return COMMENT;
}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 94 "libmemcached/csl/scanner.l"
+#line 96 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 96 "libmemcached/csl/scanner.l"
+#line 98 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 98 "libmemcached/csl/scanner.l"
+#line 100 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 99 "libmemcached/csl/scanner.l"
+#line 101 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 100 "libmemcached/csl/scanner.l"
+#line 102 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 101 "libmemcached/csl/scanner.l"
+#line 103 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 102 "libmemcached/csl/scanner.l"
+#line 104 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 103 "libmemcached/csl/scanner.l"
+#line 105 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 104 "libmemcached/csl/scanner.l"
+#line 106 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= HASH; }
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 105 "libmemcached/csl/scanner.l"
+#line 107 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 106 "libmemcached/csl/scanner.l"
+#line 108 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 107 "libmemcached/csl/scanner.l"
+#line 109 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 108 "libmemcached/csl/scanner.l"
+#line 110 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 109 "libmemcached/csl/scanner.l"
+#line 111 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; }
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 110 "libmemcached/csl/scanner.l"
+#line 112 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 111 "libmemcached/csl/scanner.l"
+#line 113 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 112 "libmemcached/csl/scanner.l"
+#line 114 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 113 "libmemcached/csl/scanner.l"
+#line 115 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; }
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 114 "libmemcached/csl/scanner.l"
+#line 116 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 115 "libmemcached/csl/scanner.l"
+#line 117 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 116 "libmemcached/csl/scanner.l"
+#line 118 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; }
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 117 "libmemcached/csl/scanner.l"
+#line 119 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; }
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 118 "libmemcached/csl/scanner.l"
+#line 120 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; }
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 119 "libmemcached/csl/scanner.l"
+#line 121 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; }
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 120 "libmemcached/csl/scanner.l"
+#line 122 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; }
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 121 "libmemcached/csl/scanner.l"
+#line 123 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; }
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 122 "libmemcached/csl/scanner.l"
+#line 124 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; }
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 123 "libmemcached/csl/scanner.l"
+#line 125 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; }
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 124 "libmemcached/csl/scanner.l"
+#line 126 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; }
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 125 "libmemcached/csl/scanner.l"
+#line 127 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; }
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 127 "libmemcached/csl/scanner.l"
+#line 129 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; }
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 128 "libmemcached/csl/scanner.l"
+#line 130 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; }
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 130 "libmemcached/csl/scanner.l"
+#line 132 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; }
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 132 "libmemcached/csl/scanner.l"
+#line 134 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 133 "libmemcached/csl/scanner.l"
+#line 135 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= RESET; }
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 134 "libmemcached/csl/scanner.l"
+#line 136 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; }
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 135 "libmemcached/csl/scanner.l"
+#line 137 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= SERVERS; }
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 136 "libmemcached/csl/scanner.l"
+#line 138 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= END; }
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 137 "libmemcached/csl/scanner.l"
+#line 139 "libmemcached/csl/scanner.l"
{ yyextra->begin= yytext; return yyextra->previous_token= ERROR; }
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 139 "libmemcached/csl/scanner.l"
+#line 141 "libmemcached/csl/scanner.l"
{ return yyextra->previous_token= TRUE; }
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 140 "libmemcached/csl/scanner.l"
+#line 142 "libmemcached/csl/scanner.l"
{ return yyextra->previous_token= FALSE; }
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 143 "libmemcached/csl/scanner.l"
+#line 145 "libmemcached/csl/scanner.l"
{
yyextra->begin= yytext;
return UNKNOWN_OPTION;
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 148 "libmemcached/csl/scanner.l"
+#line 150 "libmemcached/csl/scanner.l"
{ return CONSISTENT; }
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 149 "libmemcached/csl/scanner.l"
+#line 151 "libmemcached/csl/scanner.l"
{ return MODULA; }
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 150 "libmemcached/csl/scanner.l"
+#line 152 "libmemcached/csl/scanner.l"
{ return RANDOM; }
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 152 "libmemcached/csl/scanner.l"
+#line 154 "libmemcached/csl/scanner.l"
{ return MD5; }
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 153 "libmemcached/csl/scanner.l"
+#line 155 "libmemcached/csl/scanner.l"
{ return CRC; }
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 154 "libmemcached/csl/scanner.l"
+#line 156 "libmemcached/csl/scanner.l"
{ return FNV1_64; }
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 155 "libmemcached/csl/scanner.l"
+#line 157 "libmemcached/csl/scanner.l"
{ return FNV1A_64; }
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 156 "libmemcached/csl/scanner.l"
+#line 158 "libmemcached/csl/scanner.l"
{ return FNV1_32; }
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 157 "libmemcached/csl/scanner.l"
+#line 159 "libmemcached/csl/scanner.l"
{ return FNV1A_32; }
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 158 "libmemcached/csl/scanner.l"
+#line 160 "libmemcached/csl/scanner.l"
{ return HSIEH; }
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 159 "libmemcached/csl/scanner.l"
+#line 161 "libmemcached/csl/scanner.l"
{ return MURMUR; }
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 160 "libmemcached/csl/scanner.l"
+#line 162 "libmemcached/csl/scanner.l"
{ return JENKINS; }
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 162 "libmemcached/csl/scanner.l"
+#line 164 "libmemcached/csl/scanner.l"
{
yylval->server.port= MEMCACHED_DEFAULT_PORT;
yylval->server.weight= 1;
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 171 "libmemcached/csl/scanner.l"
+#line 173 "libmemcached/csl/scanner.l"
{
if (yyextra->is_server())
{
case 63:
/* rule 63 can match eol */
YY_RULE_SETUP
-#line 189 "libmemcached/csl/scanner.l"
+#line 191 "libmemcached/csl/scanner.l"
{
config_get_text(yyscanner)[yyleng -1]= 0;
yylval->string.c_str= yytext +1;
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 196 "libmemcached/csl/scanner.l"
+#line 198 "libmemcached/csl/scanner.l"
{
yyextra->begin= yytext;
return UNKNOWN;
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 201 "libmemcached/csl/scanner.l"
+#line 203 "libmemcached/csl/scanner.l"
ECHO;
YY_BREAK
-#line 1946 "libmemcached/csl/scanner.cc"
+#line 1948 "libmemcached/csl/scanner.cc"
case YY_STATE_EOF(INITIAL):
yyterminate();
/* %ok-for-header */
-#line 201 "libmemcached/csl/scanner.l"
+#line 203 "libmemcached/csl/scanner.l"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
+#define YY_NO_INPUT
+
#define YY_EXTRA_TYPE Context*
-#line 25 "libmemcached/csl/scanner.h"
+#line 27 "libmemcached/csl/scanner.h"
#define YY_INT_ALIGNED short int
#undef YY_DECL
#endif
-#line 201 "libmemcached/csl/scanner.l"
+#line 203 "libmemcached/csl/scanner.l"
-#line 480 "libmemcached/csl/scanner.h"
+#line 482 "libmemcached/csl/scanner.h"
#undef config_IN_HEADER
#endif /* config_HEADER_H */
if ((rc= memcached_vdo(instance, vector, 3, flush)) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
- rc= (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
}
unlikely (ptr->number_of_replicas > 0)
const char *memcached_last_error_message(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS);
+ }
if (not memc->error_messages)
return memcached_strerror(memc, MEMCACHED_SUCCESS);
memcached_return_t memcached_last_error(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return MEMCACHED_INVALID_ARGUMENTS;
+ }
if (not memc->error_messages)
return MEMCACHED_SUCCESS;
int memcached_last_error_errno(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return 0;
+ }
if (not memc->error_messages)
+ {
return 0;
+ }
return memc->error_messages->local_errno;
}
const char *memcached_server_error(memcached_server_instance_st server)
{
- if (not server)
- return memcached_strerror(server->root, MEMCACHED_INVALID_ARGUMENTS);
+ if (server == NULL)
+ {
+ return NULL;
+ }
if (not server->error_messages)
return memcached_strerror(server->root, MEMCACHED_SUCCESS);
memcached_error_t *memcached_error_copy(const memcached_server_st& server)
{
- if (not server.error_messages)
+ if (server.error_messages == NULL)
+ {
return NULL;
+ }
memcached_error_t *error= (memcached_error_t *)libmemcached_malloc(server.root, sizeof(memcached_error_t));
memcpy(error, server.error_messages, sizeof(memcached_error_t));
uint32_t num= ptr->ketama.continuum_points_counter;
WATCHPOINT_ASSERT(ptr->ketama.continuum);
- hash= hash;
memcached_continuum_item_st *begin, *end, *left, *right, *middle;
begin= left= ptr->ketama.continuum;
end= right= ptr->ketama.continuum + num;
return -1;
}
}
- ssize_t sent_length;
size_t return_length;
char *local_write_ptr= ptr->write_buffer;
size_t write_length= ptr->write_buffer_offset;
{
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
WATCHPOINT_ASSERT(write_length > 0);
- sent_length= 0;
if (ptr->type == MEMCACHED_CONNECTION_UDP)
increment_udp_message_id(ptr);
+ ssize_t sent_length= 0;
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (with_flush)
{
}
if (ptr->type == MEMCACHED_CONNECTION_UDP and
- (size_t)sent_length != write_length)
+ size_t(sent_length) != write_length)
{
memcached_quit_server(ptr, true);
*error= memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
cache_constructor_t* constructor,
cache_destructor_t* destructor) {
cache_t* ret = calloc(1, sizeof(cache_t));
- char* nm = strdup(name);
+ size_t name_length= strlen(name);
+ char* nm= calloc(1, (sizeof(char) * name_length) +1);
+ memcpy(nm, name, name_length);
void** ptr = calloc(initial_pool_size, bufsize);
if (ret == NULL || nm == NULL || ptr == NULL ||
pthread_mutex_init(&ret->mutex, NULL) == -1) {
/* We add two bytes so that we can walk the \r\n */
if (memcached_failed(memcached_string_check(&result->value, value_length +2)))
{
- value_length= 0;
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
}
hostname,
source->port, source->weight,
source->type);
- if (not destination)
+ if (destination)
{
if (source->error_messages)
{
#include <netdb.h>
#endif
+#ifdef NI_MAXHOST
+#define MEMCACHED_NI_MAXHOST NI_MAXHOST
+#else
+#define MEMCACHED_NI_MAXHOST 1025
+#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
struct memcached_error_t *error_messages;
char read_buffer[MEMCACHED_MAX_BUFFER];
char write_buffer[MEMCACHED_MAX_BUFFER];
- char hostname[NI_MAXHOST];
+ char hostname[MEMCACHED_NI_MAXHOST];
};
string_ptr= end_ptr + 1;
for (end_ptr= string_ptr; !(isspace(*end_ptr)); end_ptr++) {};
value= string_ptr;
- value[(size_t)(end_ptr-string_ptr)]= 0;
- string_ptr= end_ptr + 2;
+ value[(size_t)(end_ptr -string_ptr)]= 0;
if (memc_stat)
{
unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY)
virtual_bucket->replicas= replicas;
self->virtual_bucket= virtual_bucket;
- for (uint32_t x=0; x < buckets; x++)
+ uint32_t x= 0;
+ for (; x < buckets; x++)
{
virtual_bucket->buckets[x].master= host_map[x];
if (forward_map)
#include <arpa/inet.h>
-namespace libtest { class Server; }
+namespace libtest { struct Server; }
namespace libtest {
PANDORA_USE_PIPE
- AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
+ AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
AC_SUBST([AM_CFLAGS])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([PANDORA_CHECK_CXX_STANDARD],[
- dnl AC_REQUIRE([AC_CXX_COMPILE_STDCXX_0X])
- AS_IF([test "$GCC" = "yes"],
- [AS_IF([test "$ac_cv_cxx_compile_cxx0x_native" = "yes"],[],
- [AS_IF([test "$ac_cv_cxx_compile_cxx0x_gxx" = "yes"],
- [CXX_STANDARD="-std=gnu++0x"],
- [CXX_STANDARD="-std=gnu++98"])
- ])
- ])
- AM_CXXFLAGS="${CXX_STANDARD} ${AM_CXXFLAGS}"
-
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${CXXFLAGS} ${CXX_STANDARD}"
- AC_CXX_HEADER_STDCXX_98
- CXXFLAGS="${save_CXXFLAGS}"
-
- AC_SUBST([CXX_STANDARD])
-])
+++ /dev/null
-# ===========================================================================
-# http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AC_CXX_COMPILE_STDCXX_0X
-#
-# DESCRIPTION
-#
-# Check for baseline language coverage in the compiler for the C++0x
-# standard.
-#
-# LICENSE
-#
-# Copyright (C) 2008 Benjamin Kosnik <bkoz@redhat.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
-
-AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
- AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
- ac_cv_cxx_compile_cxx0x_native,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
- AC_LANG_RESTORE
- ])
-
- AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
- ac_cv_cxx_compile_cxx0x_cxx,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -std=c++0x"
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
- CXXFLAGS="$ac_save_CXXFLAGS"
- AC_LANG_RESTORE
- ])
-
- AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
- ac_cv_cxx_compile_cxx0x_gxx,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -std=gnu++0x"
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
- CXXFLAGS="$ac_save_CXXFLAGS"
- AC_LANG_RESTORE
- ])
-
- if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
- test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
- test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
- AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
- fi
-])
+++ /dev/null
-# ===========================================================================
-# http://autoconf-archive.cryp.to/ac_cxx_header_stdcxx_98.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AC_CXX_HEADER_STDCXX_98
-#
-# DESCRIPTION
-#
-# Check for complete library coverage of the C++1998/2003 standard.
-#
-# LICENSE
-#
-# Copyright (C) 2008 Benjamin Kosnik <bkoz@redhat.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
-
-AC_DEFUN([AC_CXX_HEADER_STDCXX_98], [
- AC_CACHE_CHECK(for ISO C++ 98 include files,
- ac_cv_cxx_stdcxx_98,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILE([
- #include <cassert>
- #include <cctype>
- #include <cerrno>
- #include <cfloat>
- #include <ciso646>
- #include <climits>
- #include <clocale>
- #include <cmath>
- #include <csetjmp>
- #include <csignal>
- #include <cstdarg>
- #include <cstddef>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
-
- #include <algorithm>
- #include <bitset>
- #include <complex>
- #include <deque>
- #include <exception>
- #include <fstream>
- #include <functional>
- #include <iomanip>
- #include <ios>
- #include <iosfwd>
- #include <iostream>
- #include <istream>
- #include <iterator>
- #include <limits>
- #include <list>
- #include <locale>
- #include <map>
- #include <memory>
- #include <new>
- #include <numeric>
- #include <ostream>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <stdexcept>
- #include <streambuf>
- #include <string>
- #include <typeinfo>
- #include <utility>
- #include <valarray>
- #include <vector>
- ],,
- ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
- AC_LANG_RESTORE
- ])
- if test "$ac_cv_cxx_stdcxx_98" = yes; then
- AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
- fi
-])
;;
esac
- dnl Once we can use a modern autoconf, we can replace the std=gnu99 here
- dnl with using AC_CC_STD_C99 above
- CC="${CC} -std=gnu99"
-
AM_CPPFLAGS="-g ${AM_CPPFLAGS}"
DEBUG_CFLAGS="-O0"
%{_includedir}/libmemcached/delete.h
%{_includedir}/libmemcached/dump.h
%{_includedir}/libmemcached/error.h
+%{_includedir}/libmemcached/exist.h
%{_includedir}/libmemcached/exception.hpp
%{_includedir}/libmemcached/fetch.h
%{_includedir}/libmemcached/flush.h
%{_mandir}/man3/memcached_stat_get_value.3.gz
%{_mandir}/man3/memcached_stat_servername.3.gz
%{_mandir}/man3/memcached_strerror.3.gz
+%{_mandir}/man3/memcached_exist.3.gz
+%{_mandir}/man3/memcached_exist_by_key.3.gz
%{_mandir}/man3/memcached_verbosity.3.gz
%{_mandir}/man3/memcached_version.3.gz
test_compare(MEMCACHED_SUCCESS, rc);
}
- rc= memcached_mget(memc, keys, key_length, 3);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
results= memcached_result_create(memc, &results_obj);
+ test_true(results);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
(time_t)0, (uint32_t)0);
test_compare(MEMCACHED_SUCCESS, rc);
- rc= memcached_mget(memc, keys, keylengths, 1);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, keylengths, 1));
results= memcached_result_create(memc, &results_obj);
+ test_true(results);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
/* All keys are valid in the binary protocol (except for length) */
if (not memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
{
- query_id= memcached_query_id(memc_clone);
+ uint64_t before_query_id= memcached_query_id(memc_clone);
{
size_t string_length;
char *string= memcached_get(memc_clone, key, strlen(key),
test_zero(string_length);
test_false(string);
}
+ test_compare(before_query_id +1, memcached_query_id(memc_clone));
query_id= memcached_query_id(memc_clone);
test_compare(MEMCACHED_SUCCESS,
// this should indicate end
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
test_compare(MEMCACHED_END, rc);
+ test_null(string);
// now get just one
rc= memcached_mget(memc, keys, lengths, 1);
// this should indicate end
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
test_compare(MEMCACHED_END, rc);
+ test_null(string);
return TEST_SUCCESS;
}
{
memcached_result_st results_obj;
memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
memcached_return_t rc;
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
{
memcached_result_st results_obj;
memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
+ test_false(memcached_is_allocated(results));
memcached_return_t rc;
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
/* Make sure be default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
+ test_null(value);
test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
/* Test a clean set */
/* Make sure be default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
+ test_null(value);
test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
/* Test a clean set */