cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CLOSE_WAIT and socket options

From: Andrei Tarassov <andrei.tarassov_at_altiris.ee>
Date: Wed, 6 Apr 2005 12:43:18 +0200

I checked on HP-UX 11.00, curl 7.12.3. We use only HTTP and HTTPS. I am
going to check how our code is using curl, maybe there are some curl
handles that stay not closed. I just wanted to make sure that this is
not a well-known issue.

Again, strange as it is, sockets do not get closed on timeout. They are
hanging for hours.

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Wednesday, April 06, 2005 13:05
To: libcurl development
Subject: Re: CLOSE_WAIT and socket options

On Wed, 6 Apr 2005, Andrei Tarassov wrote:

> The situation is that the sockets is hanging in CLOSE_WAIT state for
hours
> (at least I did not notice any changes in the output of the lsof
command).
> On the server side there seems to be nothing known about these
connections.
> I guess the server has closed its socket, but for some reasons the
client
> does not know anything about that.

What OS? Does it happen for all protocols? How many sockets do you get
in
CLOSE_WAIT after having done a single libcurl request (for a given
protocol
such as HTTP for example)?

> If that is the situation, then my understanding is that the connection

> should be closed on the client side as well, at least after some
timeout.
> However this does not seem to happen.

IIRC, CLOSE_WAIT should normally be two minutes.

> 1. Has anyone encountered the same problem and handled it?

Not me, and I've not seen anyone report this before.

> 2. At what moment curl closes the TCP socket?

It uses many sockets and thus closes them all over. Search the source
code for
'sclose' and you'll see. I'm pretty sure it closes all of them as it
should,
as otherwise both the internal memdebug system as well as valgrind would

complain when running test cases.

> 3. Is there any way to pass custom options to the curl function, which

> creates a socket? I want to try to play with different timeouts a bit.

Nope. There have been talka about adding such a callback that allows the
app
to set whatever options it desires, but it hasn't been done. I'm not
even sure
anyway works on it.

> 4. Is there any way to switch off the normal tcp connection closing
> procedure, i.e. to close the socket without sending different
FIN/ACKs?

I don't think you can do that with plain stream sockets. But I'm far
from
sure.

-- 
  Commercial curl and libcurl Technical Support:
http://haxx.se/curl.html
Received on 2005-04-06