cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Threaded resolver spins bug + patch

From: Jamie Lokier <jamie_at_shareable.org>
Date: Sun, 9 Aug 2009 01:13:59 +0100

Constantine Sapuntzakis wrote:
> 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.

You can create a self-connected socket on Windows (and on unix).
Create a TCP socket bound to AF_INET 127.0.0.1, port zero.
getsockname() to get which port it was really bound to, and listen().
Then create another TCP socket and connect it to the address returned
from getsockname().

Then you can write to the socket from your resolver thread when it's
done, and monitor the socket from your select() loop.

-- Jamie
Received on 2009-08-09