From 710bf70c7f28a509788902c047a4e4e741142292 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 15 Nov 2008 18:15:28 -0800 Subject: [PATCH] Fix for most errors around non-block --- libmemcached/memcached_connect.c | 2 +- libmemcached/memcached_do.c | 3 +++ libmemcached/memcached_io.c | 17 ++++++++++------- libmemcached/memcached_storage.c | 2 ++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index 57bce101..4cd5219a 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -234,7 +234,7 @@ test_connect: { goto handle_retry; } - else if (error != 1 || fds[0].revents & POLLERR) + else if (error != 1 && fds[0].revents & POLLERR) { ptr->cached_errno= errno; WATCHPOINT_ERRNO(ptr->cached_errno); diff --git a/libmemcached/memcached_do.c b/libmemcached/memcached_do.c index 91f7506b..f788582f 100644 --- a/libmemcached/memcached_do.c +++ b/libmemcached/memcached_do.c @@ -10,7 +10,10 @@ memcached_return memcached_do(memcached_server_st *ptr, const void *command, WATCHPOINT_ASSERT(command); if ((rc= memcached_connect(ptr)) != MEMCACHED_SUCCESS) + { + WATCHPOINT_ERROR(rc); return rc; + } sent_length= memcached_io_write(ptr, command, command_length, with_flush); diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index 0afcc29e..506dfd7a 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -225,16 +225,19 @@ memcached_return memcached_io_close(memcached_server_st *ptr) return MEMCACHED_SUCCESS; /* in case of death shutdown to avoid blocking at close() */ - r= shutdown(ptr->fd, SHUT_RDWR); + if (1) + { + r= shutdown(ptr->fd, SHUT_RDWR); #ifdef HAVE_DEBUG - if (r && errno != ENOTCONN) - { - WATCHPOINT_NUMBER(ptr->fd); - WATCHPOINT_ERRNO(errno); - WATCHPOINT_ASSERT(errno); - } + if (r && errno != ENOTCONN) + { + WATCHPOINT_NUMBER(ptr->fd); + WATCHPOINT_ERRNO(errno); + WATCHPOINT_ASSERT(errno); + } #endif + } r= close(ptr->fd); #ifdef HAVE_DEBUG diff --git a/libmemcached/memcached_storage.c b/libmemcached/memcached_storage.c index 93bc140a..770b27d4 100644 --- a/libmemcached/memcached_storage.c +++ b/libmemcached/memcached_storage.c @@ -106,10 +106,12 @@ static inline memcached_return memcached_send(memcached_st *ptr, goto error; } + /* Send command header */ rc= memcached_do(&ptr->hosts[server_key], buffer, write_length, 0); if (rc != MEMCACHED_SUCCESS) goto error; + /* Send command body */ if ((sent_length= memcached_io_write(&ptr->hosts[server_key], value, value_length, 0)) == -1) { rc= MEMCACHED_WRITE_FAILURE; -- 2.30.2