Moved init for socket to options.
[m6w6/libmemcached] / libmemcached / io.c
index 8f96bc32e19975f50bc74b459e0586fff99159fc..712e11afd9363f345347df0fbab12e44f06065b3 100644 (file)
@@ -333,31 +333,23 @@ ssize_t memcached_io_write(memcached_server_st *ptr,
 
 memcached_return_t memcached_io_close(memcached_server_st *ptr)
 {
-  int r;
-
   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)
   {
-    r= 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);
   }
 
-  r= close(ptr->fd);
-#ifdef DEBUG
-  if (r != 0)
+  if (close(ptr->fd) == -1)
+  {
     WATCHPOINT_ERRNO(errno);
-#endif
+  }
 
   return MEMCACHED_SUCCESS;
 }