mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:13:34 +03:00
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.
This commit is contained in:
parent
ca5f4e2135
commit
d021f2e8a0
14 changed files with 894 additions and 773 deletions
18
lib/easy.c
18
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue