[socket] Fix bad parameter passed to select (#4390)
[mono.git] / mono / utils / mono-poll.c
old mode 100644 (file)
new mode 100755 (executable)
index f353fc5..d81b4eb
@@ -1,6 +1,24 @@
+#include <config.h>
+
+#ifdef HOST_WIN32
+/* For select */
+#include <winsock2.h>
+#endif
+
 #include "mono-poll.h"
 #include <errno.h>
 
+#ifdef DISABLE_SOCKETS
+#include <glib.h>
+
+int
+mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
+{
+       g_assert_not_reached ();
+       return -1;
+}
+#else
+
 #if defined(HAVE_POLL) && !defined(__APPLE__)
 int
 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
@@ -42,7 +60,7 @@ mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
                        return 1;
                }
 #else
-               if (fd > FD_SETSIZE) {
+               if (fd >= FD_SETSIZE) {
                        ufds [i].revents = MONO_POLLNVAL;
                        return 1;
                }
@@ -114,3 +132,4 @@ mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
 
 #endif
 
+#endif /* #ifndef DISABLE_SOCKETS */