cURL / Mailing Lists / curl-library / Single Mail


Re: DNS Resolve problems on 2.4.18 Linux

From: Daniel Stenberg <>
Date: Sun, 26 Oct 2003 16:15:29 +0100 (CET)

On Thu, 23 Oct 2003, Dan C wrote:

> have been using curl in a project at work and found that curl would not
> resolve host names at all on our Linux kernel based on 2.4.18 source. (glibc
> 2.2.5). I traced the problem down to the gethostbyname_r in iphost.c ( the
> six parameter version ) gethostbyname returns a negative 1 (-1) and then
> modifies errno to ERANGE or EAGAIN. This seems to be counter to what the
> man page says for Glibc2 (see below).

Very nice error-tracking! Do I need to say that this function is one of the
worst I've ever dealt with in glibc?

> We are using curl-7.10.3, but the source is the same in 7.10.7. ( Should we
> upgrade to 7.10.8 or wait).

I expect a 7.10.8 release within a week or two, so you decide if you can wait
or not.

> We don't care about the asynch dns cache as we have our own and would turn
> that off anyway in the configure..)

Asynch DNS is only a small portion of what we've done lately. In average, I'd
say we fix 20-30 more or less serious bugs between each release...

> So I modified the check to first check if ret is less than zero and then
> check errno (which works) and if that fails to default back to the original
> check for compatibitlty. (Feel free to "optimize" the if... I made it this
> way to be the most readable.)
> if (( res < 0 ) && ((ERANGE == errno) || (EAGAIN == errno))) {
> step_size+=200;
> continue;
> } else if (( ERANGE == res ) || (EAGAIN == res)) {
> step_size+=200;
> continue;
> }
> break;
> } while(step_size <= CURL_NAMELOOKUP_SIZE);

Ok, I think this is a fine check. Well, not actually fine as in fine code, as
it makes the code look like crap, but I think it covers the case you mention
while at the same time work with the already existing versions of

I only have one concern here: 'errno' is not generally thread-safe. Shouldn't
'h_errnop' get checked instead, as I thought that was set to the errno values
for this function?

Again, thanks for your work!

 Daniel Stenberg -- curl: been grokking URLs since 1998
This email is sponsored by: The Donation Program.
Do you like what is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here:
Received on 2003-10-26