+
+ if (g_main_poll_debug)
+ g_print ("\n");
+
+ for (f = fds; f < &fds[nfds]; ++f)
+ f->revents = 0;
+
+ if (timeout == -1)
+ timeout = INFINITE;
+
+ /* Polling for several things? */
+ if (nhandles > 1 || (nhandles > 0 && poll_msgs))
+ {
+ /* First check if one or several of them are immediately
+ * available
+ */
+ retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, 0);
+
+ /* If not, and we have a significant timeout, poll again with
+ * timeout then. Note that this will return indication for only
+ * one event, or only for messages. We ignore timeouts less than
+ * ten milliseconds as they are mostly pointless on Windows, the
+ * MsgWaitForMultipleObjectsEx() call will timeout right away
+ * anyway.
+ */
+ if (retval == 0 && (timeout == INFINITE || timeout >= 10))
+ retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);
+ }
+ else
+ {
+ /* Just polling for one thing, so no need to check first if
+ * available immediately
+ */
+ retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);
+ }
+
+ if (retval == -1)
+ for (f = fds; f < &fds[nfds]; ++f)
+ f->revents = 0;
+
+ return retval;