prepare v1.1.4
[awesomized/libmemcached] / test / lib / Connection.cpp
index 05440723455bfc787caba43a18cb78c800560447..82414f135127d373588e37b67846365e3b599a2b 100644 (file)
@@ -1,16 +1,21 @@
 #include "Connection.hpp"
+#include "p9y/poll.hpp"
 
 #include <cerrno>
-#include <sys/poll.h>
-#include <fcntl.h>
-#include <unistd.h>
+#if HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
+#if !(HAVE_SOCK_NONBLOCK && HAVE_SOCK_CLOEXEC)
+#  include <fcntl.h>
+#  define SOCK_NONBLOCK O_NONBLOCK
+#  define SOCK_CLOEXEC O_CLOEXEC
+#endif
 
 static inline int socket_ex(int af, int so, int pf, int fl) {
 #if HAVE_SOCK_NONBLOCK && HAVE_SOCK_CLOEXEC
   return socket(af, so | fl, pf);
 #else
-# define SOCK_NONBLOCK O_NONBLOCK
-# define SOCK_CLOEXEC O_CLOEXEC
   auto sock = socket(af, so, pf);
   if (0 <= sock) {
     if (0 > fcntl(sock, F_SETFL, fl | fcntl(sock, F_GETFL))) {
@@ -186,10 +191,9 @@ bool Connection::open() {
 string Connection::error(const initializer_list<string> &args) {
   stringstream ss;
 
-  for (auto &arg : args) {
+  for (const auto &arg : args) {
     ss << arg;
   }
 
-  cerr << ss.str() << endl;
   return ss.str();
 }