After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 302672 - [PATCH] poll is completely broken on Mac OS X 10.4
[PATCH] poll is completely broken on Mac OS X 10.4
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: mainloop
2.6.x
Other Mac OS
: High critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-05-01 22:48 UTC by Toby Peterson
Modified: 2011-02-18 16:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glib/gmain.c patch (312 bytes, patch)
2005-05-01 22:48 UTC, Toby Peterson
none Details | Review
a poll bug (1.13 KB, text/plain)
2005-05-08 16:43 UTC, Toby Peterson
  Details
Test case from Erlang (292 bytes, application/octet-stream)
2006-06-22 05:55 UTC, Dave Vasilevsky
  Details
Patch to configure.in and gmain.c (1.41 KB, patch)
2006-07-03 21:22 UTC, Dave Vasilevsky
none Details | Review

Description Toby Peterson 2005-05-01 22:48:12 UTC
Please describe the problem:
Mac OS X 10.4 (Tiger) has a new poll implementation, which does not define _POLL_EMUL_H_. However, 
its poll() still doesn't play nice with glib. Patch is very simple:

--- glib/gmain.c.orig   2005-05-01 18:24:23.000000000 -0400
+++ glib/gmain.c        2005-05-01 18:24:40.000000000 -0400
@@ -52,7 +52,7 @@
 /* The poll() emulation on OS/X doesn't handle fds=NULL, nfds=0,
  * so we prefer our own poll emulation.
  */
-#ifdef _POLL_EMUL_H_
+#ifdef __APPLE__
 #undef HAVE_POLL
 #endif
    

This fixes http://bugs.irssi.org/?do=details&id=234

Steps to reproduce:
1. Compile glib2 and irssi on Tiger.
2. Run irssi

Actual results:
Irssi fails to connect, because it is using g_io_channels to pass IP numbers through pipes. Since poll 
doesn't work, the data is never received.

Expected results:
Irssi should connect.

Does this happen every time?
Yes.

Other information:
Comment 1 Toby Peterson 2005-05-01 22:48:48 UTC
Created attachment 45919 [details] [review]
glib/gmain.c patch
Comment 2 Owen Taylor 2005-05-08 14:28:18 UTC
If the lack of _POLL_EMUL_H_ indicates that OS/X actually now has a native
implementation of poll(), then it's worth investigating *why* it's not
working. poll() emulated via select() is inherently considerably less efficient 
than a native poll() syscall.
Comment 3 Toby Peterson 2005-05-08 16:43:12 UTC
Created attachment 46173 [details]
a poll bug

This is a test case that demonstrates one bug in Mac OS X's poll
implementation. I'm sure there are others. Filed as rdar://problem/4107451
Comment 4 Matthias Clasen 2005-06-09 14:38:48 UTC
If poll on OS X has bugs that prevent it from working in glib, then we should
probably have an autoconf test which checks for a buggy poll, and doesn't
set HAVE_POLL in that case.
Comment 5 Matthias Clasen 2005-07-19 19:41:36 UTC
making progress here depends on someone with access to OS X to come up with a
configure test which demonstrates a relevant bug in their poll implementation.
Comment 6 Dave Vasilevsky 2006-06-22 05:55:42 UTC
Created attachment 67826 [details]
Test case from Erlang

As mentioned, OS X Tiger's poll() fails on devices. Here's a test case, shamelessly stolen from Erlang, which Glib could use to detect the brokenness.

I have verified that this program exits with error when compiled against the poll() in Tiger's kernel, and that it exits with success when compiled against a working implementation of poll() on OS X (http://www.clapper.org/software/poll/). Could somebody test on Linux to ensure that it gives the right result?
Comment 7 Dave Vasilevsky 2006-07-03 21:22:54 UTC
Created attachment 68325 [details] [review]
Patch to configure.in and gmain.c

And here's a real patch to test for OS X's broken poll() in configure. As mentioned, it seems to work on OS X--testing on other platforms would be appreciated.
Comment 8 Matthias Clasen 2006-12-12 19:57:09 UTC
test program works fine on FC6.
Comment 9 Matthias Clasen 2006-12-12 20:07:13 UTC
2006-12-12  Matthias Clasen  <mclasen@redhat.com>

        * configure.in: Add a check for broken poll on Mac OS X.

        * glib/gmain.c: Use poll emulation on OS X.  (#302672, Toby Peterson,
        patch by Dave Vasilevsky)