cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1604956 ] Memory leak if MAXCONNECTS == 0

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 28 Nov 2006 17:36:02 -0800

Bugs item #1604956, was opened at 2006-11-28 17:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1604956&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jared Lundell (jaredlundell)
Assigned to: Daniel Stenberg (bagder)
Summary: Memory leak if MAXCONNECTS == 0

Initial Comment:
curl_easy_perform leaks memory if CURLOPT_MAXCONNECTS is set to 0 and CURLOPT_FORBID_REUSE is not set to 1.

I've observed this using libcurl 7.16.0, and the line numbers I reference come from that release.

When MAXCONNECTS is set to 0, the connection cache doesn't have room to hold any connections. As a result, ConnectionStore(struct SessionHandle*, struct connectdata*), url.c:2170, will always fail to find room for a new connection and simply gives up. This isn't an immediate problem since a handle to the connection struct is held elsewhere.

When Curl_done(struct connectdata**, CURLCode), url.c:4033 is called at the end of the Curl_perform, it assumes that ConnectionStore managed to find a place to cache the connection and will leave it open for appropriate protocols like HTTP. Since there is no connection cache, this results in a memory leak.

The obvious workaround to this is to set FORBID_REUSE to 1, forcing the connections to be properly cleaned up.

It also looks like version 7.16 adds some support to better detect this (I originally found this in 7.14). connectdata.connectindex should be -1 if there was no space in the cache. I've only looked at the code for 7.16 very briefly, but if I'm following it correctly the patch to url.c should be:

4092c4092
< if(data->set.reuse_forbid || conn->bits.close || conn->connectindex == -1) {

---
>   if(data->set.reuse_forbid || conn->bits.close) {
I haven't been able to verify this yet (my environment is behaving a bit strangely right now).  Maybe tomorrow.
----------------------------------------------------------------------
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1604956&group_id=976
Received on 2006-11-29

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET