diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2012-12-06 12:12:04 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-12-07 10:08:33 +0100 |
commit | d021f2e8a0067fc769652f27afec9024c0d02b3d (patch) | |
tree | 563742088b9866a1b8aa42ee7aab4501d72623dd /lib/easy.c | |
parent | ca5f4e21357a0b4a55e7a2a0f71e632442723989 (diff) | |
download | curl-d021f2e8a0067fc769652f27afec9024c0d02b3d.tar.gz |
Introducing a new persistent connection caching system using "bundles".
A bundle is a list of all persistent connections to the same host.
The connection cache consists of a hash of bundles, with the
hostname as the key.
The benefits may not be obvious, but they are two:
1) Faster search for connections to reuse, since the hash
lookup only finds connections to the host in question.
2) It lays out the groundworks for an upcoming patch,
which will introduce multiple HTTP pipelines.
This patch also removes the awkward list of "closure handles",
which were needed to send QUIT commands to the FTP server
when closing a connection.
Now we allocate a separate closure handle and use that
one to close all connections.
This has been tested in a live system for a few weeks, and of
course passes the test suite.
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/easy.c b/lib/easy.c index 6e8ff770a..100d003f3 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -70,6 +70,7 @@ #include "curl_rand.h" #include "non-ascii.h" #include "warnless.h" +#include "conncache.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> @@ -526,10 +527,10 @@ 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, -1L); - if(!data->state.connc) + if(!data->state.conn_cache) { + /* Oops, no connection cache, create one */ + data->state.conn_cache = Curl_conncache_init(CONNCACHE_PRIVATE); + if(!data->state.conn_cache) return CURLE_OUT_OF_MEMORY; } @@ -616,9 +617,9 @@ CURL *curl_easy_duphandle(CURL *incurl) goto fail; /* the connection cache is setup on demand */ - outcurl->state.connc = NULL; + outcurl->state.conn_cache = NULL; - outcurl->state.lastconnect = -1; + outcurl->state.lastconnect = NULL; outcurl->progress.flags = data->progress.flags; outcurl->progress.callback = data->progress.callback; @@ -674,11 +675,6 @@ CURL *curl_easy_duphandle(CURL *incurl) fail: if(outcurl) { - if(outcurl->state.connc && - (outcurl->state.connc->type == CONNCACHE_PRIVATE)) { - Curl_rm_connc(outcurl->state.connc); - outcurl->state.connc = NULL; - } curl_slist_free_all(outcurl->change.cookielist); outcurl->change.cookielist = NULL; Curl_safefree(outcurl->state.headerbuff); |