const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
uint64_t offset,
- uint64_t *value)
+ uint64_t& numeric_value)
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
uint32_t server_key;
memcached_return_t rc= memcached_vdo(instance, vector, 6, true);
if (reply == false or memcached_failed(rc))
{
+ numeric_value= UINT64_MAX;
return rc;
}
- rc= memcached_response(instance, buffer, sizeof(buffer), NULL);
-
- if (rc != MEMCACHED_SUCCESS)
- {
- return memcached_set_error(*instance, rc, MEMCACHED_AT);
- }
-
- /*
- So why recheck responce? Because the protocol is brain dead :)
- The number returned might end up equaling one of the string
- values. Less chance of a mistake with strncmp() so we will
- use it. We still called memcached_response() though since it
- worked its magic for non-blocking IO.
- */
- if (not strncmp(buffer, memcached_literal_param("ERROR\r\n")))
- {
- *value= 0;
- rc= MEMCACHED_PROTOCOL_ERROR;
- }
- else if (not strncmp(buffer, memcached_literal_param("CLIENT_ERROR\r\n")))
- {
- *value= 0;
- rc= MEMCACHED_PROTOCOL_ERROR;
- }
- else if (not strncmp(buffer, memcached_literal_param("NOT_FOUND\r\n")))
- {
- *value= 0;
- rc= MEMCACHED_NOTFOUND;
- }
- else
- {
- *value= strtoull(buffer, (char **)NULL, 10);
- rc= MEMCACHED_SUCCESS;
- }
+ rc= memcached_response(instance, buffer, sizeof(buffer), NULL, numeric_value);
return memcached_set_error(*instance, rc, MEMCACHED_AT);
}
}
else
{
- rc= text_incr_decr(ptr, true, group_key, group_key_length, key, key_length, offset, value);
+ rc= text_incr_decr(ptr, true, group_key, group_key_length, key, key_length, offset, *value);
}
LIBMEMCACHED_MEMCACHED_INCREMENT_END();
}
else
{
- rc= text_incr_decr(ptr, false, group_key, group_key_length, key, key_length, offset, value);
+ rc= text_incr_decr(ptr, false, group_key, group_key_length, key, key_length, offset, *value);
}
LIBMEMCACHED_MEMCACHED_DECREMENT_END();
#include <libmemcached/memcached/protocol_binary.h>
#include <libmemcached/byteorder.h>
#include <libmemcached/initialize_query.h>
+#ifdef __cplusplus
#include <libmemcached/response.h>
+#endif
#include <libmemcached/namespace.h>
#include <libmemcached/virtual_bucket.h>
static memcached_return_t textual_read_one_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
- memcached_result_st *result)
+ memcached_result_st *result,
+ uint64_t& numeric_value)
{
+ numeric_value= UINT64_MAX;
size_t total_read;
memcached_return_t rc= memcached_io_readline(ptr, buffer, buffer_length, total_read);
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
+ numeric_value= uint64_t(auto_return_value);
+
WATCHPOINT_STRING(buffer);
return MEMCACHED_SUCCESS;
}
memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
+{
+ uint64_t numeric_value;
+
+ return memcached_read_one_response(ptr, buffer, buffer_length, result, numeric_value);
+}
+
+memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result,
+ uint64_t& numeric_value)
{
memcached_server_response_decrement(ptr);
}
else
{
- rc= textual_read_one_response(ptr, buffer, buffer_length, result);
+ rc= textual_read_one_response(ptr, buffer, buffer_length, result, numeric_value);
}
if (rc == MEMCACHED_UNKNOWN_READ_FAILURE or
memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
+{
+ uint64_t numeric_value;
+
+ return memcached_response(ptr, buffer, buffer_length, result, numeric_value);
+}
+
+memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result,
+ uint64_t& numeric_value)
{
/* We may have old commands in the buffer not set, first purge */
if ((ptr->root->flags.no_block) && (memcached_is_processing_input(ptr->root) == false))
{
while (memcached_server_response_count(ptr) > 1)
{
- memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result);
+ memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result, numeric_value);
if (rc != MEMCACHED_END &&
rc != MEMCACHED_STORED &&
}
}
- return memcached_read_one_response(ptr, buffer, buffer_length, result);
+ return memcached_read_one_response(ptr, buffer, buffer_length, result, numeric_value);
}
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Read a single response from the server */
-LIBMEMCACHED_LOCAL
memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
-LIBMEMCACHED_LOCAL
+memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result,
+ uint64_t& numeric_value);
+
memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result);
-#ifdef __cplusplus
-}
-#endif
+memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
+ char *buffer, size_t buffer_length,
+ memcached_result_st *result,
+ uint64_t& numeric_value);