[IOMultiplexerV2] fixed compiling issue with newer MinGW builds...
[NextIRCd.git] / src / IOHandler / IOEngine_select.c
index c0405f4f89e50c93e42ebc8a4c2d5e2bd211b06c..3c62c4c96e3dced7c8eda56c0bcc64c90a424cad 100644 (file)
 
 #include <errno.h>
 #include <time.h>
+#include <string.h>
+#include <stdio.h>
 #ifdef WIN32
+#ifdef _WIN32_WINNT
+#undef _WIN32_WINNT
+#endif
 #define _WIN32_WINNT 0x501
-#include <windows.h>
 #include <winsock2.h>
-#else
-#include <string.h>
-#include <stdio.h>
+#include <windows.h>
+#elif defined HAVE_SYS_SELECT_H
+#include <sys/select.h>
 #endif
 
 /* compat */
@@ -93,8 +97,9 @@ static void engine_select_loop(struct timeval *timeout) {
                        continue;
                if(iosock->fd > fds_size)
                        fds_size = iosock->fd;
-               FD_SET(iosock->fd, &read_fds);
                select_result++;
+               if(iosocket_wants_reads(iosock))
+                       FD_SET(iosock->fd, &read_fds);
                if(iosocket_wants_writes(iosock))
                        FD_SET(iosock->fd, &write_fds);
        }