From: Brian Aker Date: Thu, 15 Nov 2007 02:05:09 +0000 (-0800) Subject: Flags fix found by Stuart Midgley X-Git-Tag: 0.10~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=331a25a55b57056f81690a6573e0ef06158ed108;p=m6w6%2Flibmemcached Flags fix found by Stuart Midgley --- diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 099c78ac..c6fa63e5 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -56,7 +56,7 @@ static memcached_return memcached_send(memcached_st *ptr, write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "%s %.*s %x %llu %zu\r\n", storage_op_string(verb), + "%s %.*s %u %llu %zu\r\n", storage_op_string(verb), (int)key_length, key, flags, (unsigned long long)expiration, value_length); if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) diff --git a/tests/function.c b/tests/function.c index 7d2de703..0200e40c 100644 --- a/tests/function.c +++ b/tests/function.c @@ -1051,6 +1051,51 @@ uint8_t user_supplied_bug6(memcached_st *memc) return 0; } +/* Test flag store/retrieve */ +uint8_t user_supplied_bug7(memcached_st *memc) +{ + memcached_return rc; + char *keys= "036790384900"; + size_t key_length= strlen("036790384900"); + char return_key[MEMCACHED_MAX_KEY]; + size_t return_key_length; + char *value; + size_t value_length; + uint16_t flags; + unsigned int x; + char insert_data[VALUE_SIZE_BUG5]; + + for (x= 0; x < VALUE_SIZE_BUG5; x++) + insert_data[x]= rand(); + + memcached_flush(memc, 0); + + flags= 245; + rc= memcached_set(memc, keys, key_length, + insert_data, VALUE_SIZE_BUG5, + (time_t)0, flags); + assert(rc == MEMCACHED_SUCCESS); + + flags= 0; + value= memcached_get(memc, keys, key_length, + &value_length, &flags, &rc); + assert(flags == 245); + assert(value); + free(value); + + rc= memcached_mget(memc, &keys, &key_length, 1); + + flags= 0; + value= memcached_fetch(memc, return_key, &return_key_length, + &value_length, &flags, &rc); + assert(flags == 245); + assert(value); + free(value); + + + return 0; +} + uint8_t result_static(memcached_st *memc) { memcached_result_st result; @@ -1458,6 +1503,7 @@ test_st user_tests[] ={ {"user_supplied_bug4", 0, user_supplied_bug4 }, {"user_supplied_bug5", 1, user_supplied_bug5 }, {"user_supplied_bug6", 1, user_supplied_bug6 }, + {"user_supplied_bug7", 1, user_supplied_bug7 }, {0, 0, 0} };