From ea7a5dd332779c77eaef6d14eac58372cb3439e1 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 14 Jun 2011 18:24:46 -0700 Subject: [PATCH] Extend lp:655423 just to see if we can trigger it via any other method. --- docs/memcached_result_st.rst | 7 ++----- libmemcached/fetch.cc | 22 ++++++++++++++++++---- tests/mem_functions.cc | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/docs/memcached_result_st.rst b/docs/memcached_result_st.rst index fab6c4a4..dbbbfd20 100644 --- a/docs/memcached_result_st.rst +++ b/docs/memcached_result_st.rst @@ -2,17 +2,14 @@ Working with result sets ======================== -.. index:: object: memcached_result_st - -Work with memcached_result_st - - -------- SYNOPSIS -------- #include +.. c:type:: memcached_result_st + .. c:function:: memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result); .. c:function:: void memcached_result_free (memcached_result_st *result); diff --git a/libmemcached/fetch.cc b/libmemcached/fetch.cc index 783ee771..89777534 100644 --- a/libmemcached/fetch.cc +++ b/libmemcached/fetch.cc @@ -90,27 +90,41 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, { memcached_server_st *server; - unlikely (ptr->flags.use_udp) + memcached_return_t unused; + if (not error) + error= &unused; + + if (ptr->flags.use_udp) { *error= MEMCACHED_NOT_SUPPORTED; return NULL; } - if (result == NULL) - if ((result= memcached_result_create(ptr, NULL)) == NULL) + if (not result) + { + if (not (result= memcached_result_create(ptr, NULL))) + { return NULL; + } + } - while ((server= memcached_io_get_readable_server(ptr)) != NULL) + while ((server= memcached_io_get_readable_server(ptr))) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; *error= memcached_response(server, buffer, sizeof(buffer), result); if (*error == MEMCACHED_SUCCESS) + { return result; + } else if (*error == MEMCACHED_END) + { memcached_server_response_reset(server); + } else if (*error != MEMCACHED_NOTFOUND) + { break; + } } /* We have completed reading data */ diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index a791559c..8d9be93e 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -5805,6 +5805,41 @@ static test_return_t regression_bug_655423(memcached_st *memc) free(value); } + char **keys= (char**)calloc(regression_bug_655423_COUNT, sizeof(char*)); + size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t)); + for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++) + { + char key[1024]; + snprintf(key, sizeof(key), "%u", x); + + keys[x]= strdup(key); + key_length[x]= strlen(key); + } + + memcached_return_t rc; + test_compare_got(MEMCACHED_SUCCESS, + rc= memcached_mget(clone, (const char* const *)keys, key_length, regression_bug_655423_COUNT), + memcached_strerror(NULL, rc)); + + uint32_t count= 0; + memcached_result_st *result= NULL; + while ((result= memcached_fetch_result(clone, result, NULL))) + { + test_compare(100, memcached_result_length(result)); + count++; + } + + test_true(count > 100); // If we don't get back atleast this, something is up + + /* Release all allocated resources */ + for (size_t x= 0; x < regression_bug_655423_COUNT; ++x) + { + free(keys[x]); + } + free(keys); + free(key_length); + + memcached_free(clone); return TEST_SUCCESS; -- 2.30.2