[IOMultiplexer] fixed small operator fail
[IOMultiplexer.git] / src / IOHandler.c
index b2a391bf11e68388112f107a56747f84f6e8cde2..06e2bff70825241b2a8f17fc8c2242dad79f37ad 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <fcntl.h>
 #endif
 
 #ifndef EWOULDBLOCK
@@ -408,11 +409,11 @@ struct IODescriptor *iohandler_connect_flags(const char *hostname, unsigned int
     //make sockfd unblocking
     #if defined(F_GETFL)
     {
-        int flags;
-        flags = fcntl(sockfd, F_GETFL);
-        fcntl(sockfd, F_SETFL, flags|O_NONBLOCK);
-        flags = fcntl(sockfd, F_GETFD);
-        fcntl(sockfd, F_SETFD, flags|FD_CLOEXEC);
+        int fcntl_flags;
+        fcntl_flags = fcntl(sockfd, F_GETFL);
+        fcntl(sockfd, F_SETFL, fcntl_flags|O_NONBLOCK);
+        fcntl_flags = fcntl(sockfd, F_GETFD);
+        fcntl(sockfd, F_SETFD, fcntl_flags|FD_CLOEXEC);
     }
     #else
     /* I hope you're using the Win32 backend or something else that
@@ -480,7 +481,7 @@ struct IODescriptor *iohandler_listen_flags(const char *hostname, unsigned int p
         ip6->sin6_port = htons(port);
         
         bind(sockfd, (struct sockaddr*)ip6, sizeof(*ip6));
-    } else if(ip4 && (flags && IOHANDLER_LISTEN_IPV4)) {
+    } else if(ip4 && (flags & IOHANDLER_LISTEN_IPV4)) {
         sockfd = socket(AF_INET, SOCK_STREAM, 0);
         if(sockfd == -1) return NULL;