X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libmemcached%2Fresponse.cc;h=d3d2510e688fcd920f34a3fa5834277ed00c0d1a;hb=ea7a5dd332779c77eaef6d14eac58372cb3439e1;hp=4035a5b952670f4c3829f919b9e13f2f209a5b56;hpb=e5571ea8efc87c103d98c8633a5b26a0a1df3519;p=awesomized%2Flibmemcached diff --git a/libmemcached/response.cc b/libmemcached/response.cc index 4035a5b9..d3d2510e 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -111,18 +111,15 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st char *buffer, memcached_result_st *result) { - memcached_return_t rc= MEMCACHED_SUCCESS; char *string_ptr; char *end_ptr; char *next_ptr; size_t value_length; size_t to_read; - char *value_ptr; ssize_t read_length= 0; - memcached_return_t rrc; if (ptr->root->flags.use_udp) - return MEMCACHED_NOT_SUPPORTED; + return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); WATCHPOINT_ASSERT(ptr->root); end_ptr= buffer + MEMCACHED_DEFAULT_COMMAND_SIZE; @@ -197,25 +194,26 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st goto read_error; /* We add two bytes so that we can walk the \r\n */ - rc= memcached_string_check(&result->value, value_length+2); - if (rc != MEMCACHED_SUCCESS) + if (memcached_failed(memcached_string_check(&result->value, value_length +2))) { value_length= 0; - return MEMCACHED_MEMORY_ALLOCATION_FAILURE; + return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } - value_ptr= memcached_string_value_mutable(&result->value); - /* - We read the \r\n into the string since not doing so is more - cycles then the waster of memory to do so. - - We are null terminating through, which will most likely make - some people lazy about using the return length. - */ - to_read= (value_length) + 2; - rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length); - if (rrc != MEMCACHED_SUCCESS) - return rrc; + { + char *value_ptr= memcached_string_value_mutable(&result->value); + /* + We read the \r\n into the string since not doing so is more + cycles then the waster of memory to do so. + + We are null terminating through, which will most likely make + some people lazy about using the return length. + */ + to_read= (value_length) + 2; + memcached_return_t rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length); + if (memcached_failed(rrc)) + return rrc; + } if (read_length != (ssize_t)(value_length + 2)) { @@ -386,7 +384,7 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan header.response.keylen= ntohs(header.response.keylen); header.response.status= ntohs(header.response.status); header.response.bodylen= ntohl(header.response.bodylen); - header.response.cas= ntohll(header.response.cas); + header.response.cas= memcached_ntohll(header.response.cas); uint32_t bodylen= header.response.bodylen; if (header.response.status == PROTOCOL_BINARY_RESPONSE_SUCCESS || @@ -452,7 +450,7 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan return MEMCACHED_UNKNOWN_READ_FAILURE; } - val= ntohll(val); + val= memcached_ntohll(val); memcpy(buffer, &val, sizeof(val)); } break; @@ -552,7 +550,7 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan if ((rc= memcached_safe_read(ptr, hole, nr)) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); - return MEMCACHED_UNKNOWN_READ_FAILURE; + return memcached_set_error(*ptr, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } bodylen-= (uint32_t) nr; }