From 5ba03c8cc82605f0eb171d547876fb6cbed70a76 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 14 Jun 2011 17:55:10 -0700 Subject: [PATCH] Fix (test for) lp:655423 It creates 6K of keys, and then does a simple get of them. --- libmemcached/fetch.cc | 3 ++- tests/mem_functions.cc | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/libmemcached/fetch.cc b/libmemcached/fetch.cc index 4420ad02..783ee771 100644 --- a/libmemcached/fetch.cc +++ b/libmemcached/fetch.cc @@ -78,7 +78,8 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, *key_length= result_buffer->key_length; } - *flags= result_buffer->item_flags; + if (flags) + *flags= result_buffer->item_flags; return memcached_string_c_copy(&result_buffer->value); } diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 338e23c8..a791559c 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -5760,6 +5760,56 @@ static test_return_t regression_bug_581030(memcached_st *) return TEST_SUCCESS; } +#define regression_bug_655423_COUNT 6000 +static test_return_t regression_bug_655423(memcached_st *memc) +{ + memcached_st *clone= memcached_clone(NULL, memc); + memc= NULL; // Just to make sure it is not used + test_true(clone); + char payload[100]; + + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1)); + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); + test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 1)); + + memset(payload, int('x'), sizeof(payload)); + + for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) + { + char key[1024]; + snprintf(key, sizeof(key), "%u", x); + + test_compare(MEMCACHED_SUCCESS, memcached_set(clone, key, strlen(key), payload, sizeof(payload), 0, 0)); + } + + for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) + { + char key[1024]; + snprintf(key, sizeof(key), "%u", x); + + size_t value_length; + memcached_return_t rc; + char *value= memcached_get(clone, key, strlen(key), &value_length, NULL, &rc); + + if (rc == MEMCACHED_NOTFOUND) + { + test_false(value); + test_compare(0, value_length); + continue; + } + + test_compare(MEMCACHED_SUCCESS, rc); + test_true(value); + test_compare(100, value_length); + free(value); + } + + memcached_free(clone); + + return TEST_SUCCESS; +} + static void memcached_die(memcached_st* mc, memcached_return error, const char* what, uint32_t it) { fprintf(stderr, "Iteration #%u: ", it); @@ -6100,6 +6150,7 @@ test_st regression_tests[]= { {"lp:581030", 1, (test_callback_fn)regression_bug_581030 }, {"lp:71231153 connect()", 1, (test_callback_fn)regression_bug_71231153_connect }, {"lp:71231153 poll()", 1, (test_callback_fn)regression_bug_71231153_poll }, + {"lp:655423", 1, (test_callback_fn)regression_bug_655423 }, {0, 0, (test_callback_fn)0} }; -- 2.30.2