X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fget.cc;h=9aa884f443687d63f9c2390179179019c483030e;hb=b5495838fb245aa1068a1198ed549b98a9c3e666;hp=86f136707e0d3a9ebb92d8c63e33b167e9336a8d;hpb=868795ee745fd29e511647fad2176b0f44daba83;p=m6w6%2Flibmemcached diff --git a/libmemcached/get.cc b/libmemcached/get.cc index 86f13670..9aa884f4 100644 --- a/libmemcached/get.cc +++ b/libmemcached/get.cc @@ -119,8 +119,9 @@ char *memcached_get_by_key(memcached_st *ptr, { if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND) { - memcached_result_reset(&ptr->result); - memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result); + memcached_result_st key_failure_result; + memcached_result_st* result_ptr= memcached_result_create(ptr, &key_failure_result); + memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, result_ptr); /* On all failure drop to returning NULL */ if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED) @@ -135,10 +136,10 @@ char *memcached_get_by_key(memcached_st *ptr, } rc= memcached_set(ptr, key, key_length, - (memcached_result_value(&ptr->result)), - (memcached_result_length(&ptr->result)), + (memcached_result_value(result_ptr)), + (memcached_result_length(result_ptr)), 0, - (memcached_result_flags(&ptr->result))); + (memcached_result_flags(result_ptr))); if (rc == MEMCACHED_BUFFERED and latch == 0) { @@ -148,20 +149,25 @@ char *memcached_get_by_key(memcached_st *ptr, else { rc= memcached_set(ptr, key, key_length, - (memcached_result_value(&ptr->result)), - (memcached_result_length(&ptr->result)), + (memcached_result_value(result_ptr)), + (memcached_result_length(result_ptr)), 0, - (memcached_result_flags(&ptr->result))); + (memcached_result_flags(result_ptr))); } if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED) { *error= rc; - *value_length= memcached_result_length(&ptr->result); - *flags= memcached_result_flags(&ptr->result); - return memcached_string_take_value(&ptr->result.value); + *value_length= memcached_result_length(result_ptr); + *flags= memcached_result_flags(result_ptr); + char *result_value= memcached_string_take_value(&result_ptr->value); + memcached_result_free(result_ptr); + + return result_value; } } + + memcached_result_free(result_ptr); } assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); @@ -486,7 +492,7 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, } protocol_binary_request_getk request= { }; //= {.bytes= {0}}; - request.message.header.request.magic= PROTOCOL_BINARY_REQ; + initialize_binary_request(instance, request.message.header); if (mget_mode) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ; @@ -542,13 +548,13 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, Send a noop command to flush the buffers */ protocol_binary_request_noop request= {}; //= {.bytes= {0}}; - request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; for (uint32_t x= 0; x < memcached_server_count(ptr); ++x) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); + initialize_binary_request(instance, request.message.header); if (memcached_server_response_count(instance)) { @@ -634,7 +640,7 @@ static memcached_return_t replication_binary_mget(memcached_st *ptr, } protocol_binary_request_getk request= {}; - request.message.header.request.magic= PROTOCOL_BINARY_REQ; + initialize_binary_request(instance, request.message.header); request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;