From 6f50a6acc95303396a8a073c3746cdff83df2301 Mon Sep 17 00:00:00 2001 From: Date: Thu, 13 Dec 2007 20:24:58 -0800 Subject: [PATCH] Turns out the protocol docs were in error, and that the size for 1.2 was a uint32_t, not a uint16_t. --- include/memcached.h | 32 +++++++------- lib/memcached_fetch.c | 6 +-- lib/memcached_get.c | 4 +- lib/memcached_storage.c | 26 +++++------ tests/function.c | 96 ++++++++++++++++++++--------------------- 5 files changed, 82 insertions(+), 82 deletions(-) diff --git a/include/memcached.h b/include/memcached.h index a6b342c6..315c284b 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -179,7 +179,7 @@ struct memcached_result_st { char key[MEMCACHED_MAX_KEY]; size_t key_length; memcached_string_st value; - uint16_t flags; + uint32_t flags; uint64_t cas; }; @@ -232,42 +232,42 @@ unsigned long long memcached_behavior_get(memcached_st *ptr, memcached_behavior memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_append(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_prepend(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_cas(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags, + uint32_t flags, uint64_t cas); /* Get functions */ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, size_t *value_length, - uint16_t *flags, + uint32_t *flags, memcached_return *error); memcached_return memcached_mget(memcached_st *ptr, char **keys, size_t *key_length, unsigned int number_of_keys); char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, - size_t *value_length, uint16_t *flags, + size_t *value_length, uint32_t *flags, memcached_return *error); memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, @@ -305,7 +305,7 @@ char *memcached_get_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, size_t *value_length, - uint16_t *flags, + uint32_t *flags, memcached_return *error); memcached_return memcached_mget_by_key(memcached_st *ptr, @@ -318,42 +318,42 @@ memcached_return memcached_set_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_add_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_replace_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_prepend_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_append_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags); + uint32_t flags); memcached_return memcached_cas_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags, + uint32_t flags, uint64_t cas); memcached_return memcached_delete_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, diff --git a/lib/memcached_fetch.c b/lib/memcached_fetch.c index 8d281f35..4f6a575c 100644 --- a/lib/memcached_fetch.c +++ b/lib/memcached_fetch.c @@ -3,7 +3,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_length, memcached_string_st *value, - uint16_t *flags, + uint32_t *flags, uint64_t *cas, unsigned int server_key) { @@ -54,7 +54,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size goto read_error; for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++); if (flags) - *flags= (uint16_t)strtol(next_ptr, &string_ptr, 10); + *flags= (uint32_t)strtol(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) goto read_error; @@ -141,7 +141,7 @@ read_error: char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, - uint16_t *flags, + uint32_t *flags, memcached_return *error) { memcached_string_st *result_buffer; diff --git a/lib/memcached_get.c b/lib/memcached_get.c index 087e4960..63a981e1 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -6,7 +6,7 @@ */ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, size_t *value_length, - uint16_t *flags, + uint32_t *flags, memcached_return *error) { return memcached_get_by_key(ptr, NULL, 0, key, key_length, value_length, @@ -17,7 +17,7 @@ char *memcached_get_by_key(memcached_st *ptr, char *master_key, size_t master_key_length, char *key, size_t key_length, size_t *value_length, - uint16_t *flags, + uint32_t *flags, memcached_return *error) { char *value; diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 43a18a98..3f55796d 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -46,7 +46,7 @@ static inline memcached_return memcached_send(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags, + uint32_t flags, uint64_t cas, memcached_storage_action verb) { @@ -130,7 +130,7 @@ error: memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_SET_START(); @@ -145,7 +145,7 @@ memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_ADD_START(); @@ -160,7 +160,7 @@ memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); @@ -175,7 +175,7 @@ memcached_return memcached_prepend(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; rc= memcached_send(ptr, key, key_length, @@ -188,7 +188,7 @@ memcached_return memcached_append(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; rc= memcached_send(ptr, key, key_length, @@ -201,7 +201,7 @@ memcached_return memcached_cas(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags, + uint32_t flags, uint64_t cas) { memcached_return rc; @@ -216,7 +216,7 @@ memcached_return memcached_set_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_SET_START(); @@ -232,7 +232,7 @@ memcached_return memcached_add_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_ADD_START(); @@ -248,7 +248,7 @@ memcached_return memcached_replace_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); @@ -264,7 +264,7 @@ memcached_return memcached_prepend_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; rc= memcached_send(ptr, key, key_length, @@ -278,7 +278,7 @@ memcached_return memcached_append_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags) + uint32_t flags) { memcached_return rc; rc= memcached_send(ptr, key, key_length, @@ -292,7 +292,7 @@ memcached_return memcached_cas_by_key(memcached_st *ptr, char *key, size_t key_length, char *value, size_t value_length, time_t expiration, - uint16_t flags, + uint32_t flags, uint64_t cas) { memcached_return rc; diff --git a/tests/function.c b/tests/function.c index f21cb684..0be895d6 100644 --- a/tests/function.c +++ b/tests/function.c @@ -111,7 +111,7 @@ uint8_t set_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); return 0; @@ -123,24 +123,24 @@ uint8_t append_test(memcached_st *memc) char *key= "fig"; char *value= "we"; size_t value_length; - uint16_t flags; + uint32_t flags; rc= memcached_flush(memc, 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_append(memc, key, strlen(key), " the", strlen(" the"), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_append(memc, key, strlen(key), " people", strlen(" people"), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); value= memcached_get(memc, key, strlen(key), @@ -161,7 +161,7 @@ uint8_t append_binary_test(memcached_st *memc) unsigned int store_list[] = { 23, 56, 499, 98, 32847, 0 }; char *value; size_t value_length; - uint16_t flags; + uint32_t flags; unsigned int x; rc= memcached_flush(memc, 0); @@ -170,7 +170,7 @@ uint8_t append_binary_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), NULL, 0, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); for (x= 0; store_list[x] ; x++) @@ -178,7 +178,7 @@ uint8_t append_binary_test(memcached_st *memc) rc= memcached_append(memc, key, strlen(key), (char *)&store_list[x], sizeof(unsigned int), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); } @@ -220,7 +220,7 @@ uint8_t cas2_test(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); } @@ -261,7 +261,7 @@ uint8_t cas_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_mget(memc, &key, &key_length, 1); @@ -288,24 +288,24 @@ uint8_t prepend_test(memcached_st *memc) char *key= "fig"; char *value= "people"; size_t value_length; - uint16_t flags; + uint32_t flags; rc= memcached_flush(memc, 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_prepend(memc, key, strlen(key), "the ", strlen("the "), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_prepend(memc, key, strlen(key), "we ", strlen("we "), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); value= memcached_get(memc, key, strlen(key), @@ -330,12 +330,12 @@ uint8_t add_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); memcached_quit(memc); rc= memcached_add(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_NOTSTORED); return 0; @@ -359,7 +359,7 @@ uint8_t replace_test(memcached_st *memc) rc= memcached_replace(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); return 0; @@ -373,7 +373,7 @@ uint8_t delete_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_delete(memc, key, strlen(key), (time_t)0); @@ -398,7 +398,7 @@ uint8_t get_test(memcached_st *memc) char *key= "foo"; char *string; size_t string_length; - uint16_t flags; + uint32_t flags; rc= memcached_delete(memc, key, strlen(key), (time_t)0); assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND); @@ -420,11 +420,11 @@ uint8_t get_test2(memcached_st *memc) char *value= "when we sanitize"; char *string; size_t string_length; - uint16_t flags; + uint32_t flags; rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); string= memcached_get(memc, key, strlen(key), @@ -452,7 +452,7 @@ uint8_t set_test2(memcached_st *memc) { rc= memcached_set(memc, key, strlen(key), value, value_length, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); } @@ -477,7 +477,7 @@ uint8_t set_test3(memcached_st *memc) { rc= memcached_set(memc, key, strlen(key), value, value_length, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); } @@ -494,7 +494,7 @@ uint8_t get_test3(memcached_st *memc) size_t value_length= 8191; char *string; size_t string_length; - uint16_t flags; + uint32_t flags; int x; value = (char*)malloc(value_length); @@ -505,7 +505,7 @@ uint8_t get_test3(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, value_length, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); string= memcached_get(memc, key, strlen(key), @@ -530,7 +530,7 @@ uint8_t get_test4(memcached_st *memc) size_t value_length= 8191; char *string; size_t string_length; - uint16_t flags; + uint32_t flags; int x; value = (char*)malloc(value_length); @@ -541,7 +541,7 @@ uint8_t get_test4(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, value_length, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); for (x= 0; x < 10; x++) @@ -582,7 +582,7 @@ uint8_t increment_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_increment(memc, key, strlen(key), @@ -607,7 +607,7 @@ uint8_t decrement_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_decrement(memc, key, strlen(key), @@ -631,13 +631,13 @@ uint8_t quit_test(memcached_st *memc) rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)10, (uint16_t)3); + (time_t)10, (uint32_t)3); assert(rc == MEMCACHED_SUCCESS); memcached_quit(memc); rc= memcached_set(memc, key, strlen(key), value, strlen(value), - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); return 0; @@ -677,7 +677,7 @@ uint8_t mget_result_test(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); } @@ -727,7 +727,7 @@ uint8_t mget_result_alloc_test(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); } @@ -756,7 +756,7 @@ uint8_t mget_test(memcached_st *memc) char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; - uint16_t flags; + uint32_t flags; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; @@ -783,7 +783,7 @@ uint8_t mget_test(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); } @@ -1004,7 +1004,7 @@ uint8_t user_supplied_bug2(memcached_st *memc) { memcached_return rc= MEMCACHED_SUCCESS; char buffer[SMALL_STRING_LEN]; - uint16_t flags= 0; + uint32_t flags= 0; size_t val_len= 0; char *getval; @@ -1073,7 +1073,7 @@ uint8_t user_supplied_bug3(memcached_st *memc) size_t return_key_length; char *return_value; size_t return_value_length; - uint16_t flags; + uint32_t flags; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) @@ -1098,7 +1098,7 @@ uint8_t user_supplied_bug4(memcached_st *memc) char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; - uint16_t flags; + uint32_t flags; /* Here we free everything before running a bunch of mget tests */ { @@ -1132,7 +1132,7 @@ uint8_t user_supplied_bug4(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_NO_SERVERS); } @@ -1164,7 +1164,7 @@ uint8_t user_supplied_bug5(memcached_st *memc) size_t return_key_length; char *value; size_t value_length; - uint16_t flags; + uint32_t flags; unsigned int count; unsigned int x; char insert_data[VALUE_SIZE_BUG5]; @@ -1188,7 +1188,7 @@ uint8_t user_supplied_bug5(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], insert_data, VALUE_SIZE_BUG5, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); } @@ -1222,7 +1222,7 @@ uint8_t user_supplied_bug6(memcached_st *memc) size_t return_key_length; char *value; size_t value_length; - uint16_t flags; + uint32_t flags; unsigned int count; unsigned int x; char insert_data[VALUE_SIZE_BUG5]; @@ -1249,7 +1249,7 @@ uint8_t user_supplied_bug6(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], insert_data, VALUE_SIZE_BUG5, - (time_t)0, (uint16_t)0); + (time_t)0, (uint32_t)0); assert(rc == MEMCACHED_SUCCESS); } @@ -1318,7 +1318,7 @@ uint8_t user_supplied_bug7(memcached_st *memc) size_t return_key_length; char *value; size_t value_length; - uint16_t flags; + uint32_t flags; unsigned int x; char insert_data[VALUE_SIZE_BUG5]; @@ -1359,7 +1359,7 @@ uint8_t user_supplied_bug9(memcached_st *memc) char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"}; size_t key_length[3]; unsigned int x; - uint16_t flags; + uint32_t flags; unsigned count= 0; char return_key[MEMCACHED_MAX_KEY]; @@ -1377,7 +1377,7 @@ uint8_t user_supplied_bug9(memcached_st *memc) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], - (time_t)50, (uint16_t)9); + (time_t)50, (uint32_t)9); assert(rc == MEMCACHED_SUCCESS); } @@ -1626,7 +1626,7 @@ uint8_t get_read(memcached_st *memc) { char *return_value; size_t return_value_length; - uint16_t flags; + uint32_t flags; for (x= 0; x < GLOBAL_COUNT; x++) { @@ -1656,7 +1656,7 @@ uint8_t mget_read(memcached_st *memc) size_t return_key_length; char *return_value; size_t return_value_length; - uint16_t flags; + uint32_t flags; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) -- 2.30.2