From 797bc8504c0c1d718b088dca0622d920e3c6fcff Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Wed, 19 Nov 2008 10:15:19 +0000
Subject: [PATCH] - Andreas Wurf and Markus Koetter helped me analyze a problem
 that Andreas got   when uploading files to a single FTP server using multiple
 easy handle   handles with the multi interface. Occasionally a handle would
 stall in   mysterious ways.

  The problem turned out to be a side-effect of the ConnectionExists()
  function's eagerness to re-use a handle for HTTP pipelining so it would
  select it even if already being in use, due to an inadequate check for its
  chances of being used for pipelnining.
---
 CHANGES       | 11 +++++++++++
 RELEASE-NOTES |  5 ++++-
 lib/url.c     |  5 +++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index b632499272..bb93c2516c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,17 @@
 
                                   Changelog
 
+Daniel Stenberg (19 Nov 2008)
+- Andreas Wurf and Markus Koetter helped me analyze a problem that Andreas got
+  when uploading files to a single FTP server using multiple easy handle
+  handles with the multi interface. Occasionally a handle would stall in
+  mysterious ways.
+
+  The problem turned out to be a side-effect of the ConnectionExists()
+  function's eagerness to re-use a handle for HTTP pipelining so it would
+  select it even if already being in use, due to an inadequate check for its
+  chances of being used for pipelnining.
+
 Daniel Fandrich (17 Nov 2008)
 - Added more compiler warning options for gcc 4.3
 
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 9ecd2f9758..4318a8b62a 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -17,6 +17,8 @@ This release includes the following bugfixes:
  o fixed several calls to memory functions that didn't check return codes
  o memory leak for SSL connects with libcurl/NSS when CURLOPT_ISSUERCERT was
    used
+ o re-use of connections with the multi interface when multiple handles used
+   the same server
 
 This release includes the following known bugs:
 
@@ -29,6 +31,7 @@ Other curl-related news:
 This release would not have looked like this without help, code, reports and
 advice from friends like these:
 
- Yang Tse, Daniel Fandrich, Jim Meyering, Christian Krause
+ Yang Tse, Daniel Fandrich, Jim Meyering, Christian Krause, Andreas Wurf,
+ Markus Koetter
 
         Thanks! (and sorry if I forgot to mention someone)
diff --git a/lib/url.c b/lib/url.c
index 75f9e099d4..6bb3e3ee71 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2509,6 +2509,11 @@ ConnectionExists(struct SessionHandle *data,
       /* don't do mixed proxy and non-proxy connections */
       continue;
 
+    if(!canPipeline && check->inuse)
+      /* this request can't be pipelined but the checked connection is already
+         in use so we skip it */
+      continue;
+
     if(!needle->bits.httpproxy || needle->protocol&PROT_SSL ||
        (needle->bits.httpproxy && check->bits.httpproxy &&
         needle->bits.tunnel_proxy && check->bits.tunnel_proxy &&
-- 
GitLab