aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-05-30 20:04:44 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-05-30 20:04:44 +0000
commita49e78d9b758cad12d886df2d5c8459a34477bbb (patch)
treed401a8ea0bc3d14fecf47e3b91db1969f23007ae /lib
parent9583b51d80b36b5d221898cbebc02e84bac22384 (diff)
Added CURLMOPT_MAXCONNECTS which is a curl_multi_setopt() option for setting
the maximum size of the connection cache maximum size of the multi handle.
Diffstat (limited to 'lib')
-rw-r--r--lib/multi.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/multi.c b/lib/multi.c
index d9d7eb290..35c74dc16 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -160,6 +160,8 @@ struct Curl_multi {
/* shared connection cache */
struct conncache *connc;
+ long maxconnects; /* if >0, a fixed limit of the maximum number of entries
+ we're allowed to grow the connection cache to */
/* list of easy handles kept around for doing nice connection closures */
struct closure *closure;
@@ -484,11 +486,19 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
/* We want the connection cache to have plenty room. Before we supported
the shared cache every single easy handle had 5 entries in their cache
by default. */
- CURLcode res = Curl_ch_connc(easy_handle, multi->connc,
- multi->num_easy * 4);
- if(res != CURLE_OK)
- /* TODO: we need to do some cleaning up here! */
- return CURLM_OUT_OF_MEMORY;
+ int newmax = multi->num_easy * 4;
+
+ if(multi->maxconnects && (multi->maxconnects < newmax))
+ /* don't grow beyond the allowed size */
+ newmax = multi->maxconnects;
+
+ if(newmax > multi->connc->num) {
+ /* we only do this is we can in fact grow the cache */
+ CURLcode res = Curl_ch_connc(easy_handle, multi->connc, newmax);
+ if(res != CURLE_OK)
+ /* TODO: we need to do some cleaning up here! */
+ return CURLM_OUT_OF_MEMORY;
+ }
}
/* increase the alive-counter */
@@ -1810,6 +1820,9 @@ CURLMcode curl_multi_setopt(CURLM *multi_handle,
case CURLMOPT_TIMERDATA:
multi->timer_userp = va_arg(param, void *);
break;
+ case CURLMOPT_MAXCONNECTS:
+ multi->maxconnects = va_arg(param, long);
+ break;
default:
res = CURLM_UNKNOWN_OPTION;
break;