cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: v2 of patch to fix busy-waiting during Windows async name lookup

From: Constantine Sapuntzakis <csapuntz_at_gmail.com>
Date: Thu, 10 Sep 2009 09:01:06 -0700

Attached is the updated test.

Constantine, would you like to check if you can actually call sendto()

> on the writable unbound socket (sending to a valid address and
> non-zero port), and if that autobinds to a random, unused local port
> number (and chooses a local address)? If so I think we can be
> confident that "ready for read" is the right condition to use in
> select().
>
>
On Windows 7 RC, the test indicates getsockname returns -1 before the sendto
and 0 after the sendto.

FWIW, The documentation seems to indicate it will autobind, though it's a
bit fuzzy:

http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx

> The only question will be whether it works in older versions of
> Windows, which clearly did not implement select() properly.
>
> Speaking of that, do the latest versions of Windows still require a
> dummy socket in select calls? Has anyone checked?
>
>
Added the following code to socket_test.cpp.

   rc = select(0, NULL, NULL, NULL, &tv);
   printf ("rc = %d\n", rc);

   FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep);
   rc = select(0, &fdread, &fdwrite, &fdexcep, &tv);
   printf ("rc = %d\n", rc);

Both print rc = -1 on WIndows 7 RC.

On a separate topic, I would assume we still want to the timeout/polling
code that I added in the patch, even with the dummy socket. Otherwise, the
process will block for an arbitrary amount of time determined by the caller
(since no timeout is pending).

-Costa

Received on 2009-09-10