You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Stefan Ruppert <ml...@ruppert-it.de> on 2008/11/01 15:04:21 UTC

Bug in trunk/poll/unix/select.c for Windows?

Hi all,

I use an older snapshot of the 1.3 apr trunk (r571958) and encountered a 
problem under Windows using the apr_pollset_poll() function without a 
socket in the pollset. Windows returns a WSAEINVAL error code indicating 
an invalid input parameter. Currently I solved this problem by checking 
if there is no socket in the pollset and then just call apr_sleep() for 
the amount of timeout microseconds I wanted to wait also in the 
apr_pollset_poll() function.

Now I checked the current trunk and I saw the following changes:

--- apr/apr/trunk/poll/unix/select.c	2008/08/28 17:07:32	689895
+++ apr/apr/trunk/poll/unix/select.c	2008/08/28 17:09:06	689896
@@ -453,6 +453,17 @@
      fd_set readset, writeset, exceptset;
      apr_status_t rv = APR_SUCCESS;

+#ifdef WIN32
+    /* On Win32, select() must be presented with at least one socket to
+     * poll on, or select() will return WSAEINVAL.  So, we'll just
+     * short-circuit and bail now.
+     */
+    if (pollset->nelts == 0) {
+        (*num) = 0;
+        return APR_SUCCESS;
+    }
+#endif
+
      if (timeout < 0) {
          tvptr = NULL;
      }

---

I think this is not correct because in such a case the caller expects at 
least timeout microseconds to suspend the current thread. I propose to 
just add a apr_sleep() if timeout is none null and an error if timeout 
is INFINITE.

Regards,
Stefan