apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: cvs commit: apr/network_io/unix sa_common.c
Date Tue, 29 Jan 2002 12:26:49 GMT
martin@apache.org writes:

> martin      02/01/29 00:37:45
> 
>   Modified:    network_io/unix sa_common.c
>   Log:
>   De facto implementations of getnameinfo() return the error code in their
>   return value. See isc.org's bind9, or FreeBSD's lib/libc/net/getnameinfo.c
>   Implementations that set h_errno a simply broken.

Somehow we need to get to the bottom of this.

As far as "Implementations that set h_errno are simply broken"...

The RFC says they just have to return the equivalent of "good" or
"bad."  If it happens to set h_errno (and I don't know why I would
have coded that if none did :) ), then we potentially get more
information.  I don't see any portability problem with the old code.

Your new code assumes that getnameinfo() works a different way.
That's fine if it does for some systems, but you need to try to
autodetect that or configure it in some way that the user of some
other system doesn't have to patch APR.

>   Index: sa_common.c
>   ===================================================================
>   RCS file: /home/cvs/apr/network_io/unix/sa_common.c,v
>   retrieving revision 1.47
>   retrieving revision 1.48
>   diff -u -r1.47 -r1.48
>   --- sa_common.c	26 Dec 2001 21:18:26 -0000	1.47
>   +++ sa_common.c	29 Jan 2002 08:37:45 -0000	1.48
>   @@ -524,6 +524,16 @@
>                         flags != 0 ? flags : NI_NAMEREQD);
>        if (rc != 0) {
>            *hostname = NULL;
>   +#if 1
>   +        /* De facto implementations return the error code in their
>   +         * return value. See isc.org's bind9, or
>   +         * FreeBSD's lib/libc/net/getnameinfo.c
>   +         * Implementations that set h_errno a simply broken.
>   +         * @@ if you encounter one, replace the #if 1 by an
>   +         * @@ appropriate #ifdef and delete these lines.

No, that is APR's job to expose the right code.

>   +         */
>   +            return rc + APR_OS_START_SYSERR;

This means that it absolutely must be an h_errno-type value.  If it
isn't an h_errno-type value this is broken.

>   +#else
>            /* XXX I have no idea if this is okay.  I don't see any info
>             * about getnameinfo() returning anything other than good or bad.

Look at the code.  It assumes good/bad unless it sees that something
was actually stored in h_errno during the call.

I don't see any info about getnameinfo() returning an error code like
above either, though I'm sure you are correct for some platforms.

Note that this code verified at run-time that h_errno was set.  It
knows that it can't count on the return value meaning anything but it
did see that h_errno should be helpful.

I have seen doc that said getnameinfo can return EAI_AGAIN or
EAI_SYSTEM (for EAI_SYSTEM we'd need to return errno).  I don't know
what system it was for.  There seemed to be some implication that it
was for FreeBSD.

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Mime
View raw message