cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: cleanup half closed sockets in connection cache

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 21 Oct 2009 23:36:02 +0200 (CEST)

Frank Meier wrote:

> 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).

Right, and I understand your wish to adress this issue. I'm just not sure how
it is best dealt with.

> Nevertheless I see your point, having an extra API call to handle this seems
> to be a not really generic approach.

While it would work, it would be a bit clumpsy (since you'd have to call the
function on chance on some particular interval) and it would leave all exiting
apps to not get the effects until modified.

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.

> 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.

That would have to use a new bitmask bit then, as curl_multi_socket_action()
would in some applications be used very often and it would be critical to keep
it very fast in applications using very very many connections. And a new bit
there would basically be as bad as a new function. Besides, there can be idle
connections on the easy interface too so we should preferably make a fix that
could improve things indepdently of what interface that is used.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-10-21