cURL / Mailing Lists / curl-library / Single Mail


libcurl stuck with half-open connection

From: Joe Eggleston <>
Date: Fri, 17 Apr 2009 14:42:40 -0400

I have a C program using the multi-interface to libcurl with libevent.
I found it stuck with a half-open connection. By half-open I mean the
connection was established, then the server box died, so there was no
FIN, etc.
netstat on the host running curl showed the connection as Established.
When I attached to the process using gdb, I found that libevent was
waiting for a Read event on that socket, but wasn't waiting for a
timeout event for that connection. I believe this means that that
connection will sit forever. I was expecting curl to handle this
situation because I had set the CURLOPT_TIMEOUT for the connection to
120 seconds. But, without a timeout event, curl will never wake up to
timeout the connection.
Is my understanding correct? Should curl handle the half-open
connection properly? Of course, it's also possible that there's a bug
in my code so that it's not using curl properly.

Thanks for any help,
Received on 2009-04-17