You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@attglobal.net> on 2002/01/29 13:26:49 UTC
Re: cvs commit: apr/network_io/unix sa_common.c
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...
Re: cvs commit: apr/network_io/unix sa_common.c
Posted by Jeff Trawick <tr...@attglobal.net>.
Jeff Trawick <tr...@attglobal.net> writes:
> > 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;
I asked a friend to check on the getnameinfo() for a system he works
on (not yet released, so I can't tell you the system). Their
getnameinfo() returns EAI_xxx codes like getaddrinfo().
For such a system we'd need
return rc + APR_OS_START_EAIERR;
in place of your line.
On one level of linux I just tried and h_errno is being set
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->-1 (errno 0 h_errno 1)
The "-1" retcode doesn't seem to be the the normal negative-EAI_xxx
value we get with getaddrinfo() on glibc because -1 as an EAI_xxx
value is
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
and I don't see how NI_NAMEREQD is an invalid set of flags.
On Solaris 8, it looks like EAI_xxx values are returned:
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->8 (errno 0 h_errno 0)
#define EAI_NONAME 8 /* host/servname not known */
On AIX 5L, it looks like EAI_xxx values are returned an h_errno is set
:)
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->7 (errno 0 h_errno 1)
#define EAI_NODATA 7 /* no address associated with hostname */
In order to get to the bottom of this I think that you need to tell me
what sort of error codes are returned by your getnameinfo(); choices I
know of are
a) h_errno codes
b) EAI_xxx codes understood by gai_strerror() (but errno set if EAI_SYSTEM)
c) something with no rhyme or reason (or at least no way to fit
into existing APR support)
Then we can see what sort of autodetection would be necessary to cover
the different environments.
Okay?
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...
Re: cvs commit: apr/network_io/unix sa_common.c
Posted by Jeff Trawick <tr...@attglobal.net>.
Jeff Trawick <tr...@attglobal.net> writes:
> > 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;
I asked a friend to check on the getnameinfo() for a system he works
on (not yet released, so I can't tell you the system). Their
getnameinfo() returns EAI_xxx codes like getaddrinfo().
For such a system we'd need
return rc + APR_OS_START_EAIERR;
in place of your line.
On one level of linux I just tried and h_errno is being set
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->-1 (errno 0 h_errno 1)
The "-1" retcode doesn't seem to be the the normal negative-EAI_xxx
value we get with getaddrinfo() on glibc because -1 as an EAI_xxx
value is
# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
and I don't see how NI_NAMEREQD is an invalid set of flags.
On Solaris 8, it looks like EAI_xxx values are returned:
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->8 (errno 0 h_errno 0)
#define EAI_NONAME 8 /* host/servname not known */
On AIX 5L, it looks like EAI_xxx values are returned an h_errno is set
:)
getnameinfo 9.9.9.9 0 ni_namereqd
getnameinfo->7 (errno 0 h_errno 1)
#define EAI_NODATA 7 /* no address associated with hostname */
In order to get to the bottom of this I think that you need to tell me
what sort of error codes are returned by your getnameinfo(); choices I
know of are
a) h_errno codes
b) EAI_xxx codes understood by gai_strerror() (but errno set if EAI_SYSTEM)
c) something with no rhyme or reason (or at least no way to fit
into existing APR support)
Then we can see what sort of autodetection would be necessary to cover
the different environments.
Okay?
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...