From: Brian Aker Date: Tue, 22 Sep 2009 08:36:13 +0000 (-0700) Subject: Merge fix for binary mget X-Git-Tag: 0.34~24 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c80e9f74b4ea8c9c8f2b7bb4f22ce8f27cbad6de;p=m6w6%2Flibmemcached Merge fix for binary mget --- c80e9f74b4ea8c9c8f2b7bb4f22ce8f27cbad6de diff --cc tests/function.c index d3b67f0f,27af6736..dfdb4d93 --- a/tests/function.c +++ b/tests/function.c @@@ -1042,6 -1042,70 +1042,70 @@@ static test_return get_test5(memcached_ return TEST_SUCCESS; } + static test_return mget_end(memcached_st *memc) + { - const char *keys[] = { "foo", "foo2" }; - size_t lengths[] = { 3, 4 }; - const char *values[] = { "fjord", "41" }; ++ const char *keys[]= { "foo", "foo2" }; ++ size_t lengths[]= { 3, 4 }; ++ const char *values[]= { "fjord", "41" }; + + memcached_return rc; + + // Set foo and foo2 - for(int i = 0; i < 2; i++) ++ for (int i= 0; i < 2; i++) + { + rc= memcached_set(memc, keys[i], lengths[i], values[i], strlen(values[i]), + (time_t)0, (uint32_t)0); + assert(rc == MEMCACHED_SUCCESS); + } + + char *string; + size_t string_length; + uint32_t flags; + + // retrieve both via mget + rc= memcached_mget(memc, keys, lengths, 2); + assert(rc == MEMCACHED_SUCCESS); + + char key[MEMCACHED_MAX_KEY]; + size_t key_length; + + // this should get both - for(int i = 0; i < 2; i++) { - string = memcached_fetch(memc, key, &key_length, &string_length, - &flags, &rc); ++ for (int i = 0; i < 2; i++) ++ { ++ string= memcached_fetch(memc, key, &key_length, &string_length, ++ &flags, &rc); + assert(rc == MEMCACHED_SUCCESS); + int val = 0; - if(key_length == 4) - val = 1; ++ if (key_length == 4) ++ val= 1; + assert(string_length == strlen(values[val])); + assert(strncmp(values[val], string, string_length) == 0); + free(string); + } + + // this should indicate end - string = memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); ++ string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); + assert(rc == MEMCACHED_END); + + // now get just one + rc= memcached_mget(memc, keys, lengths, 1); + assert(rc == MEMCACHED_SUCCESS); + - string = memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); ++ string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); + assert(key_length == lengths[0]); + assert(strncmp(keys[0], key, key_length) == 0); + assert(string_length == strlen(values[0])); + assert(strncmp(values[0], string, string_length) == 0); + assert(rc == MEMCACHED_SUCCESS); + free(string); + + // this should indicate end - string = memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); - assert(rc != MEMCACHED_SUCCESS); ++ string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); + assert(rc == MEMCACHED_END); + + return TEST_SUCCESS; + } + /* Do not copy the style of this code, I just access hosts to testthis function */ static test_return stats_servername_test(memcached_st *memc) {