| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-library Mailing List Archives
cleanup half closed sockets in connection cache
From: Frank Meier <f.meier_at_phion.com>
Date: Mon, 12 Oct 2009 18:33:51 +0200
hi
i've experienced the problem, that curl is not aware of connections that are being closed from the peer. So if the Webserver closes the TCP connection after the keepalive timeout (some secconds), the socket will remain in close_wait state, until the next curl request ist issued. Of course I understand the reason, since my application is already doing something else when the connection closes, there is just no code that calls close() on that socket.
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.
I now would propose a cleanup fuction which goes throuh the connection cache an removes and closes all connections, which are not usable anymore. Based on the code in ConnectionExists() in url.c I came up with something like the following:
/*
for(i=0; i< connc->num; i++) {
check = connc->connects[i];
pipeLen = check->send_pipe->size + check->recv_pipe->size;
if(check->connectindex == -1) {
if(!pipeLen && !check->inuse) {
Did I miss something to deal with this problem, or are there other ideas? feedback is appreciated.
cheers, Frank
These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info