From: Date: Wed, 6 Feb 2008 04:25:16 +0000 (-0800) Subject: Modifying behavior to bounce connection in the case of a bad value from X-Git-Tag: _20~22 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=05a0de51880aa6ee2428a365ef5d6ad530f96454;p=m6w6%2Flibmemcached Modifying behavior to bounce connection in the case of a bad value from memcached. --- diff --git a/lib/memcached_fetch.c b/lib/memcached_fetch.c index 19f60870..96363684 100644 --- a/lib/memcached_fetch.c +++ b/lib/memcached_fetch.c @@ -117,6 +117,8 @@ memcached_return value_fetch(memcached_server_st *ptr, return MEMCACHED_SUCCESS; read_error: + memcached_io_reset(ptr); + return MEMCACHED_PARTIAL_READ; } diff --git a/lib/memcached_io.c b/lib/memcached_io.c index d9e2602d..3b5b25af 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -309,6 +309,5 @@ static ssize_t io_flush(memcached_server_st *ptr, */ void memcached_io_reset(memcached_server_st *ptr) { - ptr->write_buffer_offset= 0; memcached_quit_server(ptr, 0); } diff --git a/lib/memcached_response.c b/lib/memcached_response.c index 31b59117..33dc0b1e 100644 --- a/lib/memcached_response.c +++ b/lib/memcached_response.c @@ -49,7 +49,10 @@ memcached_return memcached_response(memcached_server_st *ptr, WATCHPOINT_ASSERT(isgraph(*buffer_ptr) || isspace(*buffer_ptr)); if (read_length != 1) + { + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; + } if (*buffer_ptr == '\n') break; @@ -60,7 +63,10 @@ memcached_return memcached_response(memcached_server_st *ptr, WATCHPOINT_ASSERT(total_length <= buffer_length); if (total_length >= buffer_length) + { + memcached_io_reset(ptr); return MEMCACHED_PROTOCOL_ERROR; + } } buffer_ptr++; *buffer_ptr= 0; @@ -92,6 +98,7 @@ memcached_return memcached_response(memcached_server_st *ptr, { WATCHPOINT_STRING(buffer); WATCHPOINT_ASSERT(0); + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; } case 'O': /* OK */ @@ -111,6 +118,7 @@ memcached_return memcached_response(memcached_server_st *ptr, { WATCHPOINT_STRING(buffer); WATCHPOINT_ASSERT(0); + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; } } @@ -123,20 +131,31 @@ memcached_return memcached_response(memcached_server_st *ptr, else if (buffer[4] == 'S') return MEMCACHED_NOTSTORED; else + { + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; + } } case 'E': /* PROTOCOL ERROR or END */ { if (buffer[1] == 'N') return MEMCACHED_END; else if (buffer[1] == 'R') + { + memcached_io_reset(ptr); return MEMCACHED_PROTOCOL_ERROR; + } else + { + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; + } } case 'C': /* CLIENT ERROR */ + memcached_io_reset(ptr); return MEMCACHED_CLIENT_ERROR; default: + memcached_io_reset(ptr); return MEMCACHED_UNKNOWN_READ_FAILURE; }