summaryrefslogtreecommitdiff
path: root/libmemcached/response.cc
diff options
context:
space:
mode:
authorBrian Aker <brian@tangent.org>2012-01-22 23:21:54 -0800
committerBrian Aker <brian@tangent.org>2012-01-22 23:21:54 -0800
commit387c65c94bec4333da574771fc82a40deabbc3e2 (patch)
treef482672fdd51c2a7f9a54a36a59fc249fef6f1df /libmemcached/response.cc
parentfb4cba571702210fb165cc1fd3f4a212aa682abe (diff)
downloadlibmemcached-387c65c94bec4333da574771fc82a40deabbc3e2.tar.gz
Fix fatal testing.
Diffstat (limited to 'libmemcached/response.cc')
-rw-r--r--libmemcached/response.cc31
1 files changed, 20 insertions, 11 deletions
diff --git a/libmemcached/response.cc b/libmemcached/response.cc
index e876123d..7af52ce4 100644
--- a/libmemcached/response.cc
+++ b/libmemcached/response.cc
@@ -242,12 +242,18 @@ static memcached_return_t textual_read_one_response(memcached_server_write_insta
return MEMCACHED_SERVER_ERROR;
}
- if (total_read > memcached_literal_param_size("SERVER_ERROR object too large for cache") and
+ if (total_read >= memcached_literal_param_size("SERVER_ERROR object too large for cache") and
(memcmp(buffer, memcached_literal_param("SERVER_ERROR object too large for cache")) == 0))
{
return MEMCACHED_E2BIG;
}
+ if (total_read >= memcached_literal_param_size("SERVER_ERROR out of memory storing object") and
+ (memcmp(buffer, memcached_literal_param("SERVER_ERROR out of memory storing object")) == 0))
+ {
+ return MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE;
+ }
+
// Move past the basic error message and whitespace
char *startptr= buffer + memcached_literal_param_size("SERVER_ERROR");
if (startptr[0] == ' ')
@@ -705,11 +711,7 @@ static memcached_return_t _read_one_response(memcached_server_write_instance_st
assert(rc != MEMCACHED_PROTOCOL_ERROR);
}
- if (rc == MEMCACHED_UNKNOWN_READ_FAILURE or
- rc == MEMCACHED_READ_FAILURE or
- rc == MEMCACHED_PROTOCOL_ERROR or
- rc == MEMCACHED_CLIENT_ERROR or
- rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
+ if (memcached_fatal(rc))
{
memcached_io_reset(ptr);
}
@@ -774,14 +776,21 @@ memcached_return_t memcached_response(memcached_server_write_instance_st ptr,
memcached_return_t rc= _read_one_response(ptr, buffer, buffer_length, junked_result_ptr, numeric_value);
// @TODO should we return an error on another but a bad read case?
- if (rc != MEMCACHED_END and
- rc != MEMCACHED_STORED and
- rc != MEMCACHED_SUCCESS and
- rc != MEMCACHED_STAT and
+ if (
+ rc != MEMCACHED_DATA_EXISTS and
rc != MEMCACHED_DELETED and
+ rc != MEMCACHED_E2BIG and
+ rc != MEMCACHED_END and
+ rc != MEMCACHED_ITEM and
rc != MEMCACHED_NOTFOUND and
rc != MEMCACHED_NOTSTORED and
- rc != MEMCACHED_DATA_EXISTS)
+ rc != MEMCACHED_SERVER_ERROR and
+ rc != MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE and
+ rc != MEMCACHED_STAT and
+ rc != MEMCACHED_STORED and
+ rc != MEMCACHED_SUCCESS and
+ rc != MEMCACHED_VALUE
+ )
{
memcached_result_free(junked_result_ptr);
return rc;