GNOME Bugzilla – Bug 302672
[PATCH] poll is completely broken on Mac OS X 10.4
Last modified: 2011-02-18 16:14:20 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:
Created attachment 45919 [details] [review] glib/gmain.c patch
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.
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
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.
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.
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?
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.
test program works fine on FC6.
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)