uint32_t *flags,
memcached_return_t *error)
{
- char *value;
- size_t dummy_length;
- uint32_t dummy_flags;
- memcached_return_t dummy_error;
-
unlikely (ptr->flags.use_udp)
{
*error= MEMCACHED_NOT_SUPPORTED;
(const char * const *)&key,
&key_length, 1, false);
- value= memcached_fetch(ptr, NULL, NULL,
- value_length, flags, error);
+ char *value= memcached_fetch(ptr, NULL, NULL,
+ value_length, flags, error);
/* This is for historical reasons */
if (*error == MEMCACHED_END)
*error= MEMCACHED_NOTFOUND;
return NULL;
}
- (void)memcached_fetch(ptr, NULL, NULL,
- &dummy_length, &dummy_flags,
- &dummy_error);
+ size_t dummy_length;
+ uint32_t dummy_flags;
+ memcached_return_t dummy_error;
+
+ char *dummy_value= memcached_fetch(ptr, NULL, NULL,
+ &dummy_length, &dummy_flags,
+ &dummy_error);
WATCHPOINT_ASSERT(dummy_length == 0);
+ WATCHPOINT_ASSERT(dummy_value == 0);
return value;
}
size_t number_of_keys,
bool mget_mode)
{
- memcached_return_t rc;
-
if (ptr->number_of_replicas == 0)
{
- rc= simple_binary_mget(ptr, master_server_key, is_group_key_set,
- keys, key_length, number_of_keys, mget_mode);
+ return simple_binary_mget(ptr, master_server_key, is_group_key_set,
+ keys, key_length, number_of_keys, mget_mode);
}
- else
- {
- uint32_t* hash= static_cast<uint32_t*>(libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys));
- bool* dead_servers= static_cast<bool*>(libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool)));
- if (hash == NULL || dead_servers == NULL)
- {
- libmemcached_free(ptr, hash);
- libmemcached_free(ptr, dead_servers);
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- }
+ uint32_t* hash= static_cast<uint32_t*>(libmemcached_malloc(ptr, sizeof(uint32_t) * number_of_keys));
+ bool* dead_servers= static_cast<bool*>(libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(bool)));
- if (is_group_key_set)
+ if (hash == NULL || dead_servers == NULL)
+ {
+ libmemcached_free(ptr, hash);
+ libmemcached_free(ptr, dead_servers);
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
+
+ if (is_group_key_set)
+ {
+ for (size_t x= 0; x < number_of_keys; x++)
{
- for (size_t x= 0; x < number_of_keys; x++)
- {
- hash[x]= master_server_key;
- }
+ hash[x]= master_server_key;
}
- else
+ }
+ else
+ {
+ for (size_t x= 0; x < number_of_keys; x++)
{
- for (size_t x= 0; x < number_of_keys; x++)
- {
- hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
- }
+ hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]);
}
+ }
- rc= replication_binary_mget(ptr, hash, dead_servers, keys,
- key_length, number_of_keys);
+ memcached_return_t rc= replication_binary_mget(ptr, hash, dead_servers, keys,
+ key_length, number_of_keys);
- libmemcached_free(ptr, hash);
- libmemcached_free(ptr, dead_servers);
+ WATCHPOINT_IFERROR(rc);
+ libmemcached_free(ptr, hash);
+ libmemcached_free(ptr, dead_servers);
- return MEMCACHED_SUCCESS;
- }
-
- return rc;
+ return MEMCACHED_SUCCESS;
}
test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
/* All keys are valid in the binary protocol (except for length) */
- if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 0)
+ if (not memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
{
query_id= memcached_query_id(memc_clone);
string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+ test_compare(0, string_length);
+ test_false(string);
set= 0;
query_id= memcached_query_id(memc_clone);
rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
- test_true(string_length == 0);
- test_true(!string);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(0, string_length);
+ test_false(string);
/* Test multi key for bad keys */
const char *keys[] = { "GoodKey", "Bad Key", "NotMine" };
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- test_true(rc == MEMCACHED_NOTFOUND);
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
test_false(string_length);
test_false(string);
static test_return_t get_test2(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
const char *value= "when we sanitize";
- char *string;
- size_t string_length;
- uint32_t flags;
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_set(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, strlen(value),
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
test_compare(query_id +1, memcached_query_id(memc));
query_id= memcached_query_id(memc);
- string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
+ test_true(query_id);
+
+ uint32_t flags;
+ size_t string_length;
+ char *string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
test_compare(query_id +1, memcached_query_id(memc));
+ test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_SUCCESS, memcached_last_error(memc), memcached_last_error_message(memc));
test_true(string);
- test_true(rc == MEMCACHED_SUCCESS);
- test_true(string_length == strlen(value));
+ test_compare(strlen(value), string_length);
test_memcmp(string, value, string_length);
free(string);
static test_return_t set_test2(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
const char *value= "train in the brain";
size_t value_length= strlen(value);
- unsigned int x;
- for (x= 0; x < 10; x++)
+ for (uint32_t x= 0; x < 10; x++)
{
- rc= memcached_set(memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint32_t)0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
}
return TEST_SUCCESS;
static test_return_t set_test3(memcached_st *memc)
{
- memcached_return_t rc;
- char *value;
size_t value_length= 8191;
- value = (char*)malloc(value_length);
+ char *value= (char*)malloc(value_length);
test_true(value);
for (uint32_t x= 0; x < value_length; x++)
+ {
value[x] = (char) (x % 127);
+ }
/* The dump test relies on there being at least 32 items in memcached */
for (uint32_t x= 0; x < 32; x++)
snprintf(key, sizeof(key), "foo%u", x);
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_set(memc, key, strlen(key),
- value, value_length,
- (time_t)0, (uint32_t)0);
+ memcached_return_t rc= memcached_set(memc, key, strlen(key),
+ value, value_length,
+ (time_t)0, (uint32_t)0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
test_compare(query_id +1, memcached_query_id(memc));
}
static test_return_t get_test3(memcached_st *memc)
{
- memcached_return_t rc;
const char *key= "foo";
- char *value;
size_t value_length= 8191;
- char *string;
- size_t string_length;
- uint32_t flags;
- uint32_t x;
- value = (char*)malloc(value_length);
+ char *value= (char*)malloc(value_length);
test_true(value);
- for (x= 0; x < value_length; x++)
+ for (uint32_t x= 0; x < value_length; x++)
+ {
value[x] = (char) (x % 127);
+ }
+ memcached_return_t rc;
rc= memcached_set(memc, key, strlen(key),
value, value_length,
(time_t)0, (uint32_t)0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- string= memcached_get(memc, key, strlen(key),
- &string_length, &flags, &rc);
+ size_t string_length;
+ uint32_t flags;
+ char *string= memcached_get(memc, key, strlen(key),
+ &string_length, &flags, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
test_true(string);
- test_true(string_length == value_length);
- test_true(!memcmp(string, value, string_length));
+ test_compare(string_length, value_length);
+ test_memcmp(string, value, string_length);
free(string);
free(value);
/* We need to empty the server before continueing test */
rc= memcached_flush(memc, 0);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
rc= memcached_mget(memc, keys, key_length, 3);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(MEMCACHED_SUCCESS, rc);
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
&return_value_length, &flags, &rc)) != NULL)
{
test_true(return_value);
}
- test_true(!return_value);
- test_true(return_value_length == 0);
- test_true(rc == MEMCACHED_END);
+ test_false(return_value);
+ test_compare(0, return_value_length);
+ test_compare(MEMCACHED_END, rc);
for (x= 0; x < 3; x++)
{
*/
/* sighandler_t function that always asserts false */
-static void fail(int unused)
+static void fail(int)
{
- (void)unused;
assert(0);
}
{"lp:?", 1, (test_callback_fn)regression_bug_ },
{"lp:728286", 1, (test_callback_fn)regression_bug_728286 },
{"lp:581030", 1, (test_callback_fn)regression_bug_581030 },
+ {"lp:71231153", 1, (test_callback_fn)regression_bug_71231153 },
{0, 0, (test_callback_fn)0}
};