]> granicus.if.org Git - curl/commitdiff
- Patrick Scott found a rather large memory leak when using the multi
authorDaniel Stenberg <daniel@haxx.se>
Mon, 2 Feb 2009 21:36:47 +0000 (21:36 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 2 Feb 2009 21:36:47 +0000 (21:36 +0000)
  interface and setting CURLMOPT_MAXCONNECTS to something less than the number
  of handles you add to the multi handle. All the connections that didn't fit
  in the cache would not be properly disconnected nor freed!

CHANGES
RELEASE-NOTES
lib/url.c

diff --git a/CHANGES b/CHANGES
index 2dff16a7eb5e5c1084665919a8c4f37faea94e50..80e35725948768f6252a14b5b93f9135070f1d40 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,11 @@
                                   Changelog
 
 Daniel Stenberg (2 Feb 2009)
+- Patrick Scott found a rather large memory leak when using the multi
+  interface and setting CURLMOPT_MAXCONNECTS to something less than the number
+  of handles you add to the multi handle. All the connections that didn't fit
+  in the cache would not be properly disconnected nor freed!
+
 - Craig A West brought us: libcurl now defaults to do CONNECT with HTTP
   version 1.1 instead of 1.0 like before. This change also introduces the new
   proxy type for libcurl called 'CURLPROXY_HTTP_1_0' that then allows apps to
index 9cd40916f05952e41f6188584532734d5594aabd..550a68c59732ad3c0c129adcaaf3076b4d25d0ad 100644 (file)
@@ -25,6 +25,7 @@ This release includes the following bugfixes:
  o FTP ;type=i URLs now work with CURLOPT_PROXY_TRANSFER_MODE in Turkish locale
  o realms with quoted quotation marks in HTTP Digest headers
  o VC9 makefiles are now really included
+ o multi interface memory leak with CURLMOPT_MAXCONNECTS set
 
 This release includes the following known bugs:
 
@@ -34,6 +35,7 @@ This release would not have looked like this without help, code, reports and
 advice from friends like these:
 
  Lisa Xu, Daniel Fandrich, Craig A West, Alexey Borzov, Sharad Gupta,
- Peter Sylvester, Chad Monroe, Markus Moeller, Yang Tse, Scott Cantor
+ Peter Sylvester, Chad Monroe, Markus Moeller, Yang Tse, Scott Cantor,
+ Patrick Scott
 
         Thanks! (and sorry if I forgot to mention someone)
index 7cbe3cec02663bd672882619c5f319df822bf252..80d55bd55f29de4e231247ec1c29f8b210e2dbc6 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4804,8 +4804,12 @@ CURLcode Curl_done(struct connectdata **connp,
      state it is for re-using, so we're forced to close it. In a perfect world
      we can add code that keep track of if we really must close it here or not,
      but currently we have no such detail knowledge.
+
+     connectindex == -1 here means that the connection has no spot in the
+     connection cache and thus we must disconnect it here.
   */
-  if(data->set.reuse_forbid || conn->bits.close || premature) {
+  if(data->set.reuse_forbid || conn->bits.close || premature ||
+     (-1 == conn->connectindex)) {
     CURLcode res2 = Curl_disconnect(conn); /* close the connection */
 
     /* If we had an error already, make sure we return that one. But