cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Abort under HP-UX

From: Rick Jones <rick_jones2_at_hp.com>
Date: Wed, 12 Mar 2003 18:02:16 -0800

It is common to call inet_addr on a "hostname" to see if it is really a
dotted IP string. This is done because some unenlightened
implementations of gethostbyname get very grumpy if they are given an IP
address string as a hostname. So, the call to inet_addr to see if the
"hostname" was an IP address, then if that "fails" a call to
gethostbyname.

Perhaps insure is simply not aware of this usage of inet_addr and so
when that call "fails" (as it will when called with a hostname) it
spits-out its error message.

Hmm - looks like the CURL code presumes that gethostbyname is not
thread-safe and that only gethostbyname_r is threadsafe (lib/hostip.c)

However, my understanding is that for HP-UX 11 and later at least that
gethostbyname is thread safe. From the manpage:

 MULTITHREAD USAGE
           Thread Safe: Yes

           Cancel Safe: Yes

           Async-cancel Safe: No

           Async-signal Safe: No

      These functions can be called safely in a Multithreaded
      environment. They may be cancellation points in that they call
      functions that are cancel points.

Likely as not, configure on HP-UX 11 will not find a gethostbyname_r:

 OBSOLESCENT INTERFACES
      int gethostent_r(struct hostent *result,
                       struct hostent_data *buffer);

      int gethostbyname_r(const char *name,
                          struct hostent *result,
                          struct hostent_data *buffer);

      int gethostbyaddr_r(const char *addr,
                          int len,
                          int type,
                          struct hostent *result,
                          struct hostent_data *buffer);

      int sethostent_r(int stayopen, struct hostent_data *buffer);

      int endhostent_r(struct hostent_data *buffer);

      The above reentrant interfaces have been moved from libc to
      libd4r.
      They are included to support existing applications and may be
      removed in the future release. New multithreaded applications
      should use the regular APIs (those without the -r suffix).

and indeed on my 11.11 compile, it does not find a gethostbyname_r:

configure:12800: checking for gethostbyname_r
configure:12850: cc -o conftest -D_XOPEN_SOURCE_EXTENDED conftest.c
>&5
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (conftest.o)
was detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Unsatisfied symbols:
   gethostbyname_r (code)
configure:12853: $? = 1
configure: failed program was:

Now, as for the connect "failure" - if the socket is non-blocking I
think that the initial call to connect can return a -1 and set errno to
EINPROGRESS or somesuch - again, perhaps insure is being a bit overly
paranoid?

rick jones

-- 
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com  but NOT BOTH...
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
Received on 2003-03-13