From cca3c1bf4b90a84caba1e3971998e85ce3276437 Mon Sep 17 00:00:00 2001
From: Shao Shuchao <sshao@websense.com>
Date: Mon, 17 Feb 2014 13:44:00 +0800
Subject: [PATCH] ConnectionDone: Set the maxconnects as 4 times of the number of easy handle

---
 lib/multi.c |    3 +++
 lib/url.c   |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/multi.c b/lib/multi.c
index b3b5716..02d2257 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -317,6 +317,9 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
   multi->closure_handle->state.conn_cache = multi->conn_cache;
 
   multi->max_pipeline_length = 5;
+
+  /* -1 means it not set by user, use the default value */
+  multi->maxconnects = -1;
   return (CURLM *) multi;
 
   error:
diff --git a/lib/url.c b/lib/url.c
index c0aebef..30fe4eb 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3190,7 +3190,7 @@ ConnectionDone(struct SessionHandle *data, struct connectdata *conn)
 {
   /* data->multi->maxconnects can be negative, deal with it. */
   size_t maxconnects =
-    (data->multi->maxconnects < 0) ? 0 : data->multi->maxconnects;
+    (data->multi->maxconnects < 0) ? data->multi->num_easy*4 : data->multi->maxconnects;
   struct connectdata *conn_candidate = NULL;
 
   /* Mark the current connection as 'unused' */
-- 
1.7.1

