cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Threaded resolver provides bad file descriptor on Windows

From: Brian Makin <makin_at_vivisimo.com>
Date: Tue, 06 Jul 2010 16:16:20 -0400

Thank you for the quick feedback. We've added the call to
curl_multi_timeout, which seems to work *most* of the time.
Unfortunately, when we did a very quick test [1], 8 out of 100 times the
returned timeout from curl_multi_timeout was -1. According to the man
page [1], this means that there was no set timeout value, so the logic
is to disregard that value and fall back to a hard-coded limit. You can
see the psuedocode of how we are using the curl functions below.

curl_multi_fdset(curlm, ...);
curl_multi_timeout(curlm, &suggested_timeout);

timeout = external_timeout;

if (timeout > 1000) {
    timeout = 1000;
}
if (suggested_timeout >= 0 &&
    timeout > suggested_timeout)
{
    timeout = suggested_timeout;
}

select(..., timeout);

Obviously, we are missing something, but we are not sure what that is.
The request is going to a local machine that is within the local DNS, so
I'd be very surprised if there were some slowdown in either of those
locations.

[1] 100 iterations using a command line for loop
[2] http://curl.haxx.se/libcurl/c/curl_multi_timeout.html

----- "Brian Makin" <makin_at_vivisimo.com> wrote:

> On Fri, Jul 2, 2010 at 7:35 AM, Brian Makin <makin_at_vivisimo.com>
> wrote:
> > In commit 483ff1ca, the following code was added to lib/hostthre.c:
> >
> >> /* This socket is only to keep Curl_resolv_fdset() and select()
> happy;
> >> * should never become signalled for read since it's unbound but
> >> * Windows needs at least 1 socket in select().
> >> */
> >> td->dummy_sock = socket(AF_INET, SOCK_DGRAM, 0);
> >> if (td->dummy_sock == CURL_SOCKET_BAD)
> >> goto err_exit;
> >
>
> > Since no data will ever become available on this socket, performing
> a
> > select() on the fdset returned by curl_multi_fdset will simply
> timeout.
> > This means that code and servers that previously were fairly
> responsive
> > now have essentially a forced sleep of the select timeout period.
>
> > If so, what is the recommended workaround?
>
> Call curl_multi_timeout to get the right timeout to pass to select
> instead of always
> passing a second.
>
> BTW, in my code, if curl_multi_timeout returns more than 1 second,
> then I still pass 1 second to select.
>
> I'm sorry that the examples were misleading - we should have taken
> care to update them.
>
> If that doesn't fix the problem, let me know. There could be some
> other
> defect.
>
> -Costa
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-06