curl-library
Re: DNS lookup freezes easy handles (multi interface)
Date: Fri, 16 May 2008 22:47:56 +0200 (CEST)
On Fri, 16 May 2008, Emil Romanus wrote:
> I'm having a little bit of a trouble with the multi interface. Now, don't
> let the topic of this thread fool you, what I mean when I say the DNS lookup
> freezes other easy handles is that they are are stalled even after the DNS
> lookup is done, until a timeout is reached and I call curl_multi_socket().
Very strange behavior. Is this easily repeatable? Can you provide us with a
complete source code for an app as simple as possible that shows the problem?
Are all the other "freezing" connections using the same host name or are there
any (also freezing ones) using different host names?
> The problem shows up if I have, for example, 5 URLs pointing to the
> same host name. The adding of the URLs is not very prioritized, and
> when the second URL is added I get this:
> * Connection #0 hasn't finished name resolve, can't reuse
>
> Doesn't seem too wrong does it?
Yes, that certainly seems wrong.
> If I disable http pipelining, the same freezing can be noticed, but without
> the "hasn't finished name resolve" message, of course.
Pipelining had lots of problems before 7.18.1 and you're probably better off
not trying it on older versions.
> My first question, the first socket given by libcurl is obviously a
> CURL_POLL_IN socket, is it somehow associated with the DNS response?
Quite likely that is the waiting for the DNS response, yes.
> If so, then perhaps I should call curl_multi_socket_all() once the FIRST
> socket is removed, to "signal" other easy handles waiting for the DNS lookup
> to finish.
Right, that would of coruse be a useful test to see if it changes things for
debugging purposes, but an app shouldn't have to bother about such things.
> I have libcurl linked with c-ares, and have tested both 7.17.1 and
> 7.18.1. The problem happens when I try the hiperfifo.c example too.
Oh, and it just requires me to use the same host name for several URLs?
> My second question, how can I solve this?
Since it seems likely this is a bug, the procedure would include figuring out
why it happens and where, and then adjust the code to make it work better. I'm
not sure exactly what you're asking or what else I can respond?
> I need to somehow know when the DNS lookup is done, and "wake up" the curl
> handles when this happens.
libcurl of course knows when the resolving is done. But I think we (may) have
a problem for this kind of scenario when there are N other handles waiting for
the same resolve to finish.
> curl 7.17.1 (x86_64-pc-linux-gnu) libcurl/7.17.1 OpenSSL/0.9.8g
> zlib/1.2.3 c-ares/1.4.0
You should probably upgrade c-ares since there have been a few flaws fixed in
there since that release.
> Would be nice if someone else could try the hiperfifo.c example with 5-6
> URLs pointing to the same host and report back.
I'll give it a shot as soon as I can.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2008-05-16