cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: cleanup half closed sockets in connection cache

From: Frank Meier <f.meier_at_phion.com>
Date: Wed, 14 Oct 2009 11:13:19 +0200

-----Original Message-----
From: Daniel Stenberg [mailto:daniel_at_haxx.se]
Sent: Dienstag, 13. Oktober 2009 05:33
To: libcurl development
Subject: Re: cleanup half closed sockets in connection cache

On Mon, 12 Oct 2009, Frank Meier wrote:

> I now liked to change that behavior, and didn't find a nice solution. First
> I wanted to remeber the sockets and then close it if I see that the socket
> has been closed by the peer. but this would bypass libcurl, and imho would
> be a hack. After further searching I've found a posting in this mailing
> list, dealing with a similiar problem:
> http://curl.haxx.se/mail/lib-2009-03/0009.html the patch included in this
> post removed all connections in close_wait before a new request

And that patch is merged into the main code since about that time.

> but still there will be at least one (the last) connection, that will remain
> in close_wait state "forever".

So you're actually thinking it is worth adding an entirely new function and
code in your app to call that function with some interval just to make sure
there's a single socket being closed correctly?

I personally do not. I would rather prefer to see that scanning to be done
possibly on some other event and not only when adding a new connection, so
that the possibility that it gets discovered and closed increases but without
adding anything new to the API and without doing the check too often.

-- 
  / daniel.haxx.se
> So you're actually thinking it is worth adding an entirely new function and 
> code in your app to call that function with some interval just to make sure 
> there's a single socket being closed correctly?
I think there should be a possibility to handle this problem, even it it not a
big one. Btw in our case we have an application with a lot of handler child processes, which leads
to a lot of half open connections in the system (seen with netstat for example). 
Nevertheless I see your point, having an extra API call to handle this seems to
be a not really generic approach.
Another idea came to my mind, if it might be possible to use the curl_multi_socket_action() call
to tell libcurl that something has happened on a socket under its control, and then lib curl
checks the state of the socket and closes it if its half open. I tried this out, with no
effect: I suppervised the socket in my application (poll) and then called curl_multi_socket_action().
I haven't had time to go any further in this direction (check libcurl code etc) but maybe this 
would be possible with a small modification. What do you think of that?
cheers Franky
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-10-14