]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added check for broken poll on OSes where it exists but sets errno for
authorNicholas Bastin <nick.bastin@gmail.com>
Mon, 22 Mar 2004 20:20:33 +0000 (20:20 +0000)
committerNicholas Bastin <nick.bastin@gmail.com>
Mon, 22 Mar 2004 20:20:33 +0000 (20:20 +0000)
bad file descriptor.  Fixes SF Bug #850981

Modules/selectmodule.c
README
configure
configure.in
pyconfig.h.in

index 98b75f0672bfabc18312b6325978edaa326fe78c..11b93a9f59994f03d810b42e2277060b77983eed 100644 (file)
@@ -318,7 +318,7 @@ select_select(PyObject *self, PyObject *args)
        return ret;
 }
 
-#ifdef HAVE_POLL
+#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)
 /* 
  * poll() support
  */
@@ -612,7 +612,7 @@ select_poll(PyObject *self, PyObject *args)
                return NULL;
        return (PyObject *)rv;
 }
-#endif /* HAVE_POLL */
+#endif /* HAVE_POLL && !HAVE_BROKEN_POLL */
 
 PyDoc_STRVAR(select_doc,
 "select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\
@@ -639,9 +639,9 @@ On Windows, only sockets are supported; on Unix, all file descriptors.");
 
 static PyMethodDef select_methods[] = {
     {"select", select_select, METH_VARARGS, select_doc},
-#ifdef HAVE_POLL
+#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)
     {"poll",    select_poll,   METH_VARARGS, poll_doc},
-#endif /* HAVE_POLL */
+#endif /* HAVE_POLL && !HAVE_BROKEN_POLL */
     {0,        0},                          /* sentinel */
 };
 
@@ -660,7 +660,7 @@ initselect(void)
        SelectError = PyErr_NewException("select.error", NULL, NULL);
        Py_INCREF(SelectError);
        PyModule_AddObject(m, "error", SelectError);
-#ifdef HAVE_POLL
+#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL)
        poll_Type.ob_type = &PyType_Type;
        PyModule_AddIntConstant(m, "POLLIN", POLLIN);
        PyModule_AddIntConstant(m, "POLLPRI", POLLPRI);
@@ -684,5 +684,5 @@ initselect(void)
 #ifdef POLLMSG
        PyModule_AddIntConstant(m, "POLLMSG", POLLMSG);
 #endif
-#endif /* HAVE_POLL */
+#endif /* HAVE_POLL && !HAVE_BROKEN_POLL */
 }
diff --git a/README b/README
index e08d0cfa103041e1a72647d5ca16bbd5b84578ad..226d64c69ef6a4dc9182ffd38bc9d35d6260c30e 100644 (file)
--- a/README
+++ b/README
@@ -667,6 +667,7 @@ AtheOS: From Octavian Cerna <tavy at ylabs.com>:
            - select: poll is available in the C library, but does not
              work (It does not return POLLNVAL for bad fds and
              hangs).
+              (Believed fixed, unverified - autoconf check for broken poll)
            - posix: statvfs and fstatvfs always return ENOSYS.
            - disabled modules:
                - mmap: not yet implemented in AtheOS
index 94ff7722fd0ffcecd4881c45420781e677f02d19..6b07079d7c7d67654459db36ad56a83cd31949f9 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.427.4.9 .
+# From configure.in Revision: 1.427.4.10 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.57 for python 2.3.
 #
@@ -18418,6 +18418,78 @@ _ACEOF
 
 fi
 
+echo "$as_me:$LINENO: checking for broken poll()" >&5
+echo $ECHO_N "checking for broken poll()... $ECHO_C" >&6
+if test "$cross_compiling" = yes; then
+  ac_cv_broken_poll=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <poll.h>
+
+int main (void)
+    {
+    struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
+
+    close (42);
+
+    int poll_test = poll (&poll_struct, 1, 0);
+
+    if (poll_test < 0)
+        {
+        exit(0);
+        }
+    else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
+        {
+        exit(0);
+        }
+    else
+        {
+        exit(1);
+        }
+    }
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_broken_poll=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_broken_poll=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_broken_poll" >&5
+echo "${ECHO_T}$ac_cv_broken_poll" >&6
+if test "$ac_cv_broken_poll" = yes
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BROKEN_POLL 1
+_ACEOF
+
+fi
+
+
 # tzset(3) exists and works like we expect it to
 echo "$as_me:$LINENO: checking for working tzset()" >&5
 echo $ECHO_N "checking for working tzset()... $ECHO_C" >&6
index a1382d6d2fc253a257c800240f072bd3df187d7d..67c715ea4d1544b47db99a5ed224bfe9db30983c 100644 (file)
@@ -2839,6 +2839,43 @@ then
   [Define if nice() returns success/failure instead of the new priority.])
 fi
 
+AC_MSG_CHECKING(for broken poll())
+AC_TRY_RUN([
+#include <poll.h>
+
+int main (void)
+    {
+    struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
+    
+    close (42);
+
+    int poll_test = poll (&poll_struct, 1, 0);
+
+    if (poll_test < 0)
+        {
+        exit(0);
+        }
+    else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
+        {
+        exit(0);
+        }
+    else
+        {
+        exit(1);
+        }
+    }
+],
+ac_cv_broken_poll=yes,
+ac_cv_broken_poll=no,
+ac_cv_broken_poll=no)
+AC_MSG_RESULT($ac_cv_broken_poll)
+if test "$ac_cv_broken_poll" = yes
+then
+  AC_DEFINE(HAVE_BROKEN_POLL, 1,
+      [Define if poll() sets errno on invalid file descriptors.])
+fi
+
+
 # tzset(3) exists and works like we expect it to
 AC_MSG_CHECKING(for working tzset())
 AC_CACHE_VAL(ac_cv_working_tzset, [
index 2ab8b9c4fd5b496542bfb151402dda18d2c97323..3eeede5f2bec886b40a11b1096a4964d3d7e3074 100644 (file)
@@ -44,6 +44,9 @@
 /* Define if nice() returns success/failure instead of the new priority. */
 #undef HAVE_BROKEN_NICE
 
+/* Define if poll() sets errno on invalid file descriptors. */
+#undef HAVE_BROKEN_POLL
+
 /* Define if the Posix semaphores do not work on your system */
 #undef HAVE_BROKEN_POSIX_SEMAPHORES
 
 /* Define to 1 if you have the `fstatvfs' function. */
 #undef HAVE_FSTATVFS
 
+/* Define if you have the 'fsync' function. */
+#undef HAVE_FSYNC
+
 /* Define to 1 if you have the `ftell64' function. */
 #undef HAVE_FTELL64
 
 /* Define if you have the 'symlink' function. */
 #undef HAVE_SYMLINK
 
-/* Define if you have the 'fsync' function. */
-#undef HAVE_FSYNC
-
 /* Define to 1 if you have the `sysconf' function. */
 #undef HAVE_SYSCONF