cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Lingering Connections?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 3 Oct 2008 17:03:25 +0200 (CEST)

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.se
Received on 2008-10-03