]> granicus.if.org Git - icinga2/commitdiff
Build fix for Solaris.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 11 May 2012 10:44:04 +0000 (12:44 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 11 May 2012 10:44:04 +0000 (12:44 +0200)
base/socket.cpp
base/unix.h

index 6b57a211633821dfa9e018536bc692280326fc84..edd92b64e79f3a00db13703a71736c058d1506b9 100644 (file)
@@ -84,8 +84,19 @@ void Socket::SetFD(SOCKET fd)
 {
        unsigned long lTrue = 1;
 
-       if (fd != INVALID_SOCKET)
+       if (fd != INVALID_SOCKET) {
+#ifdef F_GETFL
+               int flags;
+               flags = fcntl(fd, F_GETFL, 0);
+               if (flags < 0)
+                       throw PosixException("fcntl failed", errno);
+
+               if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
+                       throw PosixException("fcntl failed", errno);
+#else /* F_GETFL */
                ioctlsocket(fd, FIONBIO, &lTrue);
+#endif /* F_GETFL */
+       }
 
        m_FD = fd;
 }
index f2d1031910f57b364be66b5102ecdb2b7d06c220..c065c72ed2b4a0676ed7319275e4f8bd929f6722 100644 (file)
@@ -41,7 +41,9 @@ void closesocket(SOCKET fd);
 
 #define ioctlsocket ioctl
 
-#define MAXPATHLEN PATH_MAX
+#ifndef MAXPATHLEN
+#      define MAXPATHLEN PATH_MAX
+#endif /* MAXPATHLEN */
 
 /* default visibility takes care of exported symbols */
 #define I2_EXPORT