Merge lp:~tangent-org/libmemcached/1.0-build Build: jenkins-Libmemcached-1.0-63
[awesomized/libmemcached] / libmemcached / io.cc
index 837959da5db6696765036ffe5787741c8235658c..019eafb6e5c9104771f95885d89786d65fda1e2c 100644 (file)
 
 #include <libmemcached/common.h>
 
+#ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+
 void initialize_binary_request(org::libmemcached::Instance* server, protocol_binary_request_header& header)
 {
   server->request_id++;
@@ -330,7 +334,16 @@ static bool io_flush(org::libmemcached::Instance* ptr,
     WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
     WATCHPOINT_ASSERT(write_length > 0);
 
-    int flags= with_flush ? MSG_NOSIGNAL|MSG_DONTWAIT : MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE;
+    int flags;
+    if (with_flush)
+    {
+      flags= MSG_NOSIGNAL|MSG_DONTWAIT;
+    }
+    else
+    {
+      flags= MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE;
+    }
+
     ssize_t sent_length= ::send(ptr->fd, local_write_ptr, write_length, flags);
 
     if (sent_length == SOCKET_ERROR)
@@ -699,7 +712,7 @@ void memcached_io_close(org::libmemcached::Instance* ptr)
   }
 
   /* in case of death shutdown to avoid blocking at close() */
-  if (shutdown(ptr->fd, SHUT_RDWR) == SOCKET_ERROR && get_socket_errno() != ENOTCONN)
+  if (shutdown(ptr->fd, SHUT_RDWR) == SOCKET_ERROR and get_socket_errno() != ENOTCONN)
   {
     WATCHPOINT_NUMBER(ptr->fd);
     WATCHPOINT_ERRNO(get_socket_errno());