]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
fix broken poll on Mac OSX - build patch by Benjamin Reed
authorJohn (J5) Palmieri <johnp@redhat.com>
Tue, 4 Mar 2008 18:21:05 +0000 (13:21 -0500)
committerJohn (J5) Palmieri <johnp@redhat.com>
Tue, 4 Mar 2008 18:21:05 +0000 (13:21 -0500)
* configure.in: check for OSX's deadlocking poll
* dbus/dbus-sysdeps-unix.c (_dbus_poll): if we have a broken poll
  don't use poll

ChangeLog
configure.in
dbus/dbus-sysdeps-unix.c

index 28497bc8e7307cbd389d97a22261ab764319704c..96cecd01f76f651d34b4501ace27f3c050ccba4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-04  John (J5) Palmieri  <johnp@redhat.com>
+
+       * fix broken poll on Mac OSX - build patch by Benjamin Reed
+       * configure.in: check for OSX's deadlocking poll
+       * dbus/dbus-sysdeps-unix.c (_dbus_poll): if we have a broken poll
+         don't use poll
+
 2008-03-04  John (J5) Palmieri  <johnp@redhat.com>
 
        * check if the linker supports a flag instead of just checking for GNU
index 1caf7d923a370b8fa7af400db70e01dd963cf402..24e2431a4ac5f63c6a267652a9c3f9d52baacec4 100644 (file)
@@ -590,7 +590,35 @@ AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, [$have_atomic_inc_cond],
 AC_CHECK_LIB(socket,socket)
 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
 
-AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit)
+AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll)
+
+#### Check for broken poll; taken from Glib's configure
+
+AC_MSG_CHECKING([for broken poll])
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+    #include <stdlib.h>
+    #include <fcntl.h>
+    #include <poll.h>
+    #ifdef HAVE_SYS_POLL_H
+    #include <sys/poll.h>
+    #endif
+    int main(void) {
+      struct pollfd fds[1];
+      int fd;
+      fd = open("/dev/null", 1);
+      fds[0].fd = fd;
+      fds[0].events = POLLIN;
+      fds[0].revents = 0;
+      if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
+            exit(1);  /* Does not work for devices -- fail */
+      }
+      exit(0);
+    }]])],
+  [broken_poll=no],
+  [broken_poll=yes
+   AC_DEFINE(BROKEN_POLL,1,[poll doesn't work on devices])],
+  [broken_poll="no (cross compiling)"])
+AC_MSG_RESULT($broken_poll)
 
 AC_MSG_CHECKING(for dirfd)
 AC_TRY_LINK([
index d9a9030c38903c3ffdc59efacf45dfd17511fa5a..19858dd3dede7a882d8ade6b3c4a89b139ae03c1 100644 (file)
@@ -1843,7 +1843,7 @@ _dbus_poll (DBusPollFD *fds,
             int         n_fds,
             int         timeout_milliseconds)
 {
-#ifdef HAVE_POLL
+#if defined(HAVE_POLL) && !defined(BROKEN_POLL)
   /* This big thing is a constant expression and should get optimized
    * out of existence. So it's more robust than a configure check at
    * no cost.