cURL / Mailing Lists / curl-library / Single Mail

curl-library

Threaded resolver spins bug + patch

From: Constantine Sapuntzakis <csapuntz_at_gmail.com>
Date: Fri, 7 Aug 2009 19:27:31 -0700

Under Windows XP SP3, my app spins when using threaded async name resolution
with curl_multi. The dummy socket allocated in the threaded resolver
(hostthre.c) is always selectable for writing, so select always returns
instantly. The dummy socket was there because select() on Windows doesn't
support being passed no descriptors.

The patch below allows an app to indicate to curl that it does not require a
dummy socket (CURLMOPT_NODUMMY). If the set of descriptors is empty then the
app will call a sleep function (e.g. SleepEx) instead.

In addition, the patch implements polling for async resolv done starting at
1ms interval and decaying expontentially up to 250ms intervals. It retains
the old behavior of not timing out name resolution.

Thoughts?

-Costa

P.S. I considered an approach of using WSAWaitForMultipleEvents instead off
select and having the async name resolver call a user-defined callback that
woul do a QueueUserApc on the waiting thread to wake up the
WSAWaitForMultipleEvents when the name resolution was done. This has the
advantage of not polling but the disadvantage of requiring W2K or above and
rewriting my select-based to code to use
WSACreateEvent/WSAEventSelect/WSAWaitForMultipleEvents.

I also considered using ARES but my app requires religiously following the
Windows DNS suffix rules for non-FQDN names.

Received on 2009-08-08