cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl and Mac OS X

From: Daniel Johnson <daniel_at_daniel-johnson.org>
Date: Tue, 30 Jan 2007 20:15:33 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jan 30, 2007, at 12:23 PM, Yang Tse wrote:

> On Tue, 30 Jan 2007, Daniel Stenberg wrote:
>
>> My memory of this disabled poll is vague, so this made me check
>> why we (I)
>> disabled it. CVS annotate showed me it was done in configure.ac
>> 1.149. The
>> date of that commit is May 13 2005. On that date, Toby Peterson
>> posted this:
>>
>> http://curl.haxx.se/mail/lib-2005-05/0122.html
>
> I've read the thread. And several things have changed since that date
> up to now that might completely change the situation, or not:
>
> 1) Curl_select now also takes in account POLLHUP when poll()ing read
> or write events. It didn't back in May 2005.
>
> 2) libcurl codebase, and internal workings, have suffered HUGE
> changes.
>
> 3) Back in May 2005 apple didn't document poll ? Now it does
> http://developer.apple.com/documentation/Darwin/Reference/ManPages/
> man2/poll.2.html
>
> 4) Mac OS X 10.4 (Darwin 8.0) has, at least, grown up to Mac OS X
> 10.4.8 (Darwin 8.9.1)
>
>> I guess our test cases don't make the bug appear as described in
>> the thread
>> above. And also I'm not sure if perhaps lib/select.c could be
>> adjusted to
>> work, if the above given quirk is the only one that'll haunt us.
>> It was easier
>> to just go with select()...
>
> It would be real nice if Daniel Johnson could find a Mac OS X version
> on which curl 7.16.1 failed when using poll(). I think we need
> something real which can actually be traced.
>
> If not, of course, the conservative and safe approach is to not use
> poll() on MAC OS X. The apple is on his field ;-)

I've gone diving into the Darwin kernel and found that the poll code
changed with OS X 10.4.4 (darwin 8.4.0). This is the only significant
change I could find since 10.4.0:

- --- /Users/daniel/Desktop/xnu-792.6.22/bsd/kern/sys_generic.c
2005-10-24 20:01:14.000000000 -0400
+++ /Users/daniel/Desktop/xnu-792.13.8/bsd/kern/sys_generic.c
2006-11-07 16:19:50.000000000 -0500
@@ -1434,7 +1442,8 @@
{
        struct poll_continue_args *cont = (struct poll_continue_args *)data;
        struct pollfd *fds = CAST_DOWN(struct pollfd *, kevp->udata);
- -
+ short mask;
+
        /* convert the results back into revents */
        if (kevp->flags & EV_EOF)
                fds->revents |= POLLHUP;
@@ -1444,10 +1453,16 @@
        switch (kevp->filter) {
        case EVFILT_READ:
- - if (kevp->data != 0)
- - fds->revents |= (fds->events & ( POLLIN | POLLRDNORM ));
- - if (kevp->flags & EV_OOBAND)
- - fds->revents |= (fds->events & ( POLLPRI | POLLRDBAND ));
+ if (fds->revents & POLLHUP)
+ mask = (POLLIN | POLLRDNORM | POLLPRI | POLLRDBAND );
+ else {
+ mask = 0;
+ if (kevp->data != 0)
+ mask |= (POLLIN | POLLRDNORM );
+ if (kevp->flags & EV_OOBAND)
+ mask |= ( POLLPRI | POLLRDBAND );
+ }
+ fds->revents |= (fds->events & mask);
                break;
        case EVFILT_WRITE:

What's really needed is to find a machine running 10.4.3 and test
libcurl on it. Unfortunately, I don't have an easy way to do that at
this time. I'm going to try to dig up a spare hard drive and install
10.4.3 on it, but it could take a few days.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
Comment: http://homepage.mac.com/danielj7/publickey.txt

iD8DBQFFv+214sDFGYouOqARAnObAJ97mvTbRmvVHeFtHssXv2289CQqawCbBAsQ
8TLhVloWnnU5rg5y1B07nfA=
=vSS3
-----END PGP SIGNATURE-----
Received on 2007-01-31