Bug 14472 - poll() causes long pauses on OSX
Summary: poll() causes long pauses on OSX
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: All Mac OS X (All)
: medium trivial
Assignee: Havoc Pennington
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-12 13:09 UTC by Benjamin Reed
Modified: 2008-03-04 10:26 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
don't test for poll on platforms on which it is broken (1.03 KB, patch)
2008-02-12 13:09 UTC, Benjamin Reed
Details | Splinter Review
update to do a real poll test (2.47 KB, patch)
2008-02-19 08:28 UTC, Benjamin Reed
Details | Splinter Review
don't use poll on Mac OS X, it can't be used with devices, only files (2.38 KB, patch)
2008-02-28 11:33 UTC, Benjamin Reed
Details | Splinter Review

Description Benjamin Reed 2008-02-12 13:09:59 UTC
Created attachment 14289 [details] [review]
don't test for poll on platforms on which it is broken

While better since 10.4, OSX's poll has a dubious history, and one of the kde/mac developers has tracked a dbus issue down to OSX's poll implementation.

Changing dbus to use select instead fixes this.
Comment 1 Colin Walters 2008-02-12 20:33:19 UTC
Do you have any references for this?  Not that I don't believe it, but it would be useful to at least include a link to some background information in the patch.
Comment 2 Benjamin Reed 2008-02-13 05:08:24 UTC
I'll ask till if he has any debugger output.
Comment 3 Till Adam 2008-02-13 06:40:01 UTC
I was experiencing occasional busy spinning of the dbus-daemon on OSX Leopard (but this has also been reported by others on Tiger) and tracked it down to the use of poll() in the main loop. Since poll() is known (well, public consensus outside of Apple claims it) to have quirky, bordering on broken semantics, I tried un-defining HAVE_POLL, to make it fall back to select, which is what many other projects do on OSX as well. This includes many things in Fink/Darwinports (http://www.finkproject.org/doc/porting/porting.en.html, section 6.3). Examples I can easily find with google are curl (http://curl.haxx.se/mail/lib-2007-02/0098.html), lighthttpd, lftp (http://www.nabble.com/Re:--13259:-lftp-crashes-on-Mac-OS-X-10.5-Leopard:-99--CPU-usage-due-to-bad-poll()-td15309938.html) but there are many more. I did not bother to track down the particular failure details, as "oh, it uses poll()" was enough of an indication that that would be the problem. I've been running with HAVE_POLL undefined for a couple of days now, no more CPU hogging loops.
Comment 4 Benjamin Reed 2008-02-19 08:28:21 UTC
Created attachment 14416 [details] [review]
update to do a real poll test

Mac OS X's poll does not let you poll devices, only "regular" filehandles;
this test is merged from Glib's test for a broken poll.
Comment 5 John (J5) Palmieri 2008-02-28 08:26:38 UTC
I'll have to test to make sure it doesn't deselect poll on other platforms first but looks good for inclusion in the point release next week.  Is there any way you can resubmit the patch against master so I don't have to apply them both?
Comment 6 Benjamin Reed 2008-02-28 11:33:14 UTC
Created attachment 14653 [details] [review]
don't use poll on Mac OS X, it can't be used with devices, only files

Got to learn about squash and git rebase -i  ;)  I'm a git n00b, so if this doesn't work, please let me know.

Anyways, here's the rebased patch all-in-one for merging against master.
Comment 7 John (J5) Palmieri 2008-03-04 10:26:04 UTC
pushed to git

Next time you submit can you add a ChangeLog entry.  Both the git commit message and ChangeLog should be the same with minor formatting changes.  Look at ChangeLog and git log to see examples of the format.  Thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.