cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

RE: cleanup half closed sockets in connection cache

From: Frank Meier <f.meier_at_phion.com>
Date: Tue, 17 Nov 2009 18:49:11 +0100

On Fri, 13 Nov 2009, Frank Meier wrote:

>> What about running the thing every time a transfer completes? Or perhaps
>> even we could do it at completion time and when a handle is removed from
>> the multi handle.
>
> that would not be of much help, because (at least in our case) the servers
> we are taking to have keepalive enabled, so the socket get's into close_wait
> after serveral seconds, when the process is already doing something else.

> I see. But I was thinking more of a case there you use N connections and they
> all complete with Y seconds interval. Then it would make sense to check the
> connection cache when each transfer ends, as the the previous transfer might
> be possible to close correctly. This is something we don't do today since the
> current logic is more limited.

I have the feeling it does not make a big difference, because now we cleanup the cache
at the beginning of of each request. If we would do it after (a few 100ms
later), there is the chance that some more connections are being cleaned up.
But on the other hand we had to run through the cache once more only to search for dead
connections, and it does not solve the problem. So it's a trade off.

> Perhaps we could make it do that check every N seconds, where N would be a
> conservatively high value (at least 60 seconds, possibly even 300 or so) to
> start with and we add a new curl_multi/easy_setopt() option to allow it to get
> set to something smaller.

I quite like that, but It would only help with the multi interface. right?
And the timer could be reseted on each curl_easy_add(), because then a new
transfer starts anyway, and if the timer has expired when calling
curl_multi_perform() the cleanup is done.

> Perhaps, but I think having it based on time is slightly better since it'll
> then also cover the case when you do 10 transfers and 9 of them stop at once
> and the last one takes another hour to complete.

Agreed

> Well, that would make it a really odd exception to how curl_easy_perform() is
> used today so I'm not sure I'm that comfortable with such a solution. After
> all, if you've done your curl_easy_perform() you can force a closure of
> everything by simply closing the easy handle.

But closing everything is not the goal, only the dead connections. In my opinion it
is not an odd behavior, because when an URL is given curl_easy_perform() does the cleanup
and the performs the request, if no URL is given, it does only the cleanup.

I would prefer the first approach with the timeout in curl_multi_perform(), although
the people using the easy interface have no possibility to cleanup the connection cache.

cheers, Frank

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
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 2009-11-17

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET