curl-library
RE: Lingering Connections?
Date: Fri, 3 Oct 2008 10:29:08 -0500
The behavior I was getting was after using curl_easy_init, and using it for
a request, after calling curl_easy_cleanup on it, there were STILL http
connections open to the server. My goal with the pool was to keep the
original curl options I was using and not use curl_easy_cleanup on a handle
until a time delay, at which point I would set FORBID_REUSE on the socket
and then call cleanup and remove it from my pool. That way I could maintain
some connection pooling over requests, but after a period of idle time I
could explicity close all open http connections. Currently the 120 second
idle timeout on the server with hundreds of thousands of clients is
exhausting the servers connection pool.
-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Friday, October 03, 2008 10:03 AM
To: libcurl development
Subject: RE: Lingering Connections?
On Thu, 2 Oct 2008, Alexis Oldroyd wrote:
Please don't top-post!
> The issue I'm experiencing is that without the CURL_OPTIONS marked as
> **NEW**, curl will maintain a socket to the server open until the server
> tells it to terminate.
So why is this a problem? BTW, you only really need FORBID_REUSE for that.
> Can I reuse that curl_easy_handle?
You can re-use easy handles, yes.
> My thought is that I will in the HTTPManager maintain a pool of
> curl_easy_handles
That you can do, but there's not a whole lot to gain by doing that. Apart
from
avoiding some memory free/malloc calls you won't see much diff.
> If I went with this easy handle reuse scheme, I believe I will have to
keep
> the curl flags I marked with **NEW**.
Not really true. The connections are pooled in the multi handle these days
so
you can kill an easy handle, create a new one and _still_ get to re-use a
connection if you used one previously that matches.
> If I didn't, I believe I would end up with the situation I am now where
even
> though cleanup is called on every curl easy handle that is used for every
> http transaction, curl reuses it internally and doesn't close it on the
call
> to cleanup.
libcurl closes all connections it can't have open or have been told to
close.
-- / daniel.haxx.seReceived on 2008-10-03