From: Trond Norbye Date: Fri, 18 Dec 2009 11:18:05 +0000 (+0100) Subject: Code cleanup in memcached_io_close X-Git-Tag: 0.37~56^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9cab202576a66e3150d283ea2066ee88a6502cea;p=m6w6%2Flibmemcached Code cleanup in memcached_io_close --- diff --git a/libmemcached/io.c b/libmemcached/io.c index 9f98b8b4..712e11af 100644 --- a/libmemcached/io.c +++ b/libmemcached/io.c @@ -333,39 +333,23 @@ ssize_t memcached_io_write(memcached_server_st *ptr, memcached_return_t memcached_io_close(memcached_server_st *ptr) { -#ifdef DEBUG - int r; -#endif - if (ptr->fd == -1) + { return MEMCACHED_SUCCESS; + } /* in case of death shutdown to avoid blocking at close() */ - if (1) + if (shutdown(ptr->fd, SHUT_RDWR) == -1 && errno != ENOTCONN) { -#ifdef DEBUG - r= -#endif - shutdown(ptr->fd, SHUT_RDWR); - -#ifdef DEBUG - if (r && errno != ENOTCONN) - { - WATCHPOINT_NUMBER(ptr->fd); - WATCHPOINT_ERRNO(errno); - WATCHPOINT_ASSERT(errno); - } -#endif + WATCHPOINT_NUMBER(ptr->fd); + WATCHPOINT_ERRNO(errno); + WATCHPOINT_ASSERT(errno); } -#ifdef DEBUG - r= -#endif - close(ptr->fd); -#ifdef DEBUG - if (r != 0) + if (close(ptr->fd) == -1) + { WATCHPOINT_ERRNO(errno); -#endif + } return MEMCACHED_SUCCESS; }