diff options
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/easy.c b/lib/easy.c index 141c74779..25d4897b6 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -469,6 +469,13 @@ CURLcode curl_easy_perform(CURL *curl) } + if(!data->state.connc) { + /* oops, no connection cache, make one up */ + data->state.connc = Curl_mk_connc(CONNCACHE_PRIVATE); + if(!data->state.connc) + return CURLE_OUT_OF_MEMORY; + } + return Curl_perform(data); } #endif @@ -496,6 +503,13 @@ void Curl_easy_addmulti(struct SessionHandle *data, data->multi = multi; } +void Curl_easy_initHandleData(struct SessionHandle *data) +{ + memset(&data->reqdata, 0, sizeof(struct HandleData)); + + data->reqdata.maxdownload = -1; +} + /* * curl_easy_getinfo() is an external interface that allows an app to retrieve * information from a performed transfer and similar. @@ -543,16 +557,14 @@ CURL *curl_easy_duphandle(CURL *incurl) /* copy all userdefined values */ outcurl->set = data->set; - outcurl->state.numconnects = data->state.numconnects; - outcurl->state.connects = (struct connectdata **) - malloc(sizeof(struct connectdata *) * outcurl->state.numconnects); - if(!outcurl->state.connects) { - break; - } + if(data->state.used_interface == Curl_if_multi) + outcurl->state.connc = data->state.connc; + else + outcurl->state.connc = Curl_mk_connc(CONNCACHE_PRIVATE); - memset(outcurl->state.connects, 0, - sizeof(struct connectdata *)*outcurl->state.numconnects); + if(!outcurl->state.connc) + break; outcurl->state.lastconnect = -1; @@ -574,6 +586,7 @@ CURL *curl_easy_duphandle(CURL *incurl) #endif /* CURL_DISABLE_HTTP */ /* duplicate all values in 'change' */ + if(data->change.url) { outcurl->change.url = strdup(data->change.url); if(!outcurl->change.url) @@ -599,14 +612,16 @@ CURL *curl_easy_duphandle(CURL *incurl) break; #endif + Curl_easy_initHandleData(outcurl); + fail = FALSE; /* we reach this point and thus we are OK */ } while(0); if(fail) { if(outcurl) { - if(outcurl->state.connects) - free(outcurl->state.connects); + if(outcurl->state.connc->type == CONNCACHE_PRIVATE) + Curl_rm_connc(outcurl->state.connc); if(outcurl->state.headerbuff) free(outcurl->state.headerbuff); if(outcurl->change.proxy) @@ -637,6 +652,9 @@ void curl_easy_reset(CURL *curl) /* zero out Progress data: */ memset(&data->progress, 0, sizeof(struct Progress)); + /* init Handle data */ + Curl_easy_initHandleData(data); + /* The remainder of these calls have been taken from Curl_open() */ data->set.out = stdout; /* default output to stdout */ |