cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Fix for known bug #64 / simplification of hostthre.c

From: Constantine Sapuntzakis <csapuntz_at_gmail.com>
Date: Mon, 7 Sep 2009 07:52:39 -0700

On Sun, Sep 6, 2009 at 11:52 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Sun, 6 Sep 2009, Constantine Sapuntzakis wrote:
>
> This patch does not really support timeout of async name lookups -- the
>> patch will eventually wait for the thread to exit in
>> Curl_destroy_thread_data if it hasn't earlier.
>>
>
> Lots of people and apps use timeouts so not supporting those is a real
> problem.
>
>
In its defense, the patched code behaves almost the same as the old code
with respect to timeouts but is safer and significantly simpler.

A comparison of the old code and new code:
   * Curl_destroy_thread_data --- old code waits for thread to
terminate, new code waits for thread to terminate (so no real timeout)
   * Curl_wait_for_resolv -- old code respects the timeout then after the
timeout waits for 5 seconds for thread to terminate and if it doesn't,
forcibly terminates it with TerminateThread which is unsafe, new code just
waits for thread to terminate (old code = timeout + 5 seconds + possible
corruption, new code = no real timeout)

So what happens if we have a time-out of 1ms, a very slow DNS that takes a
> full second to respond and we ask for a file on such a host 1000 times in a
> loop? Will we then have 1000 threads waiting to die?

 You will only have 1000 concurrent threads if you add 1000 easy handles to
a multi and don't remove any of them. The code will wait for the thread to
exit when the easy handle is removed from the multi. This part of the
behavior is the same as the old one.

-Costa
Received on 2009-09-07