X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Ffetch.cc;h=2fd0dc51e845a96a4f02194ec6e9679958936bdb;hb=edbdb9c55b66d2cc1befe6e589c2bfc98ea2d7fb;hp=dd0b036d8433cecc7177e54f9c40912f1a2a5b0c;hpb=625e84ebfc422790372bc2984f504bdcb4da779c;p=m6w6%2Flibmemcached diff --git a/libmemcached/fetch.cc b/libmemcached/fetch.cc index dd0b036d..2fd0dc51 100644 --- a/libmemcached/fetch.cc +++ b/libmemcached/fetch.cc @@ -44,23 +44,32 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, { memcached_result_st *result_buffer= &ptr->result; memcached_return_t unused; - if (not error) + if (error == NULL) + { error= &unused; + } - - unlikely (ptr->flags.use_udp) + if (memcached_is_udp(ptr)) { if (value_length) + { *value_length= 0; + } if (key_length) + { *key_length= 0; + } if (flags) + { *flags= 0; + } if (key) + { *key= 0; + } *error= MEMCACHED_NOT_SUPPORTED; return NULL; @@ -71,22 +80,32 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, { WATCHPOINT_ASSERT(result_buffer == NULL); if (value_length) + { *value_length= 0; + } if (key_length) + { *key_length= 0; + } if (flags) + { *flags= 0; + } if (key) + { *key= 0; + } return NULL; } if (value_length) + { *value_length= memcached_string_length(&result_buffer->value); + } if (key) { @@ -94,26 +113,39 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, { *error= MEMCACHED_KEY_TOO_BIG; if (value_length) + { *value_length= 0; + } - if (key_length) - *key_length= 0; + if (key_length) + { + *key_length= 0; + } - if (flags) - *flags= 0; + if (flags) + { + *flags= 0; + } - if (key) - *key= 0; + if (key) + { + *key= 0; + } return NULL; } + strncpy(key, result_buffer->item_key, result_buffer->key_length); // For the binary protocol we will cut off the key :( if (key_length) + { *key_length= result_buffer->key_length; + } } if (flags) + { *flags= result_buffer->item_flags; + } return memcached_string_take_value(&result_buffer->value); } @@ -122,31 +154,31 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return_t *error) { - memcached_server_st *server; - memcached_return_t unused; - if (not error) + if (error == NULL) + { error= &unused; + } - if (not ptr) + if (ptr == NULL) { *error= MEMCACHED_INVALID_ARGUMENTS; return NULL; } - if (ptr->flags.use_udp) + if (memcached_is_udp(ptr)) { *error= MEMCACHED_NOT_SUPPORTED; return NULL; } - if (not result) + if (result == NULL) { // If we have already initialized (ie it is in use) our internal, we // create one. if (memcached_is_initialized(&ptr->result)) { - if (not (result= memcached_result_create(ptr, NULL))) + if ((result= memcached_result_create(ptr, NULL)) == NULL) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; @@ -159,12 +191,17 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, } *error= MEMCACHED_MAXIMUM_RETURN; // We use this to see if we ever go into the loop + memcached_instance_st *server; 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) + if (*error == MEMCACHED_IN_PROGRESS) + { + continue; + } + else if (*error == MEMCACHED_SUCCESS) { result->count++; return result;