#include <curl/curl.h>
#include "transfer.h"
#include "vtls/vtls.h"
-#include "vtls/vtls_scache.h"
#include "url.h"
#include "getinfo.h"
#include "hostip.h"
if(data->multi_easy)
multi = data->multi_easy;
else {
- /* this multi handle will only ever have a single easy handled attached
- to it, so make it use minimal hashes */
- multi = Curl_multi_handle(1, 3, 7);
+ /* this multi handle will only ever have a single easy handle attached to
+ it, so make it use minimal hash sizes */
+ multi = Curl_multi_handle(1, 3, 7, 3);
if(!multi)
return CURLE_OUT_OF_MEMORY;
}
#include "multihandle.h"
#include "sigpipe.h"
#include "vtls/vtls.h"
+#include "vtls/vtls_scache.h"
#include "http_proxy.h"
#include "http2.h"
#include "socketpair.h"
#define CURL_DNS_HASH_SIZE 71
#endif
+#ifndef CURL_TLS_SESSION_SIZE
+#define CURL_TLS_SESSION_SIZE 25
+#endif
+
#define CURL_MULTI_HANDLE 0x000bab1e
#ifdef DEBUGBUILD
Curl_llist_append(&multi->msglist, msg, &msg->list);
}
-struct Curl_multi *Curl_multi_handle(size_t hashsize, /* socket hash */
+struct Curl_multi *Curl_multi_handle(size_t hashsize, /* socket hash */
size_t chashsize, /* connection hash */
- size_t dnssize) /* dns hash */
+ size_t dnssize, /* dns hash */
+ size_t sesssize) /* TLS session cache */
{
struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi));
Curl_hash_str, Curl_str_key_compare, ph_freeentry);
if(Curl_cpool_init(&multi->cpool, Curl_on_disconnect,
- multi, NULL, chashsize))
+ multi, NULL, chashsize))
+ goto error;
+
+ if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
goto error;
Curl_llist_init(&multi->msglist, NULL);
Curl_hash_destroy(&multi->proto_hash);
Curl_hash_destroy(&multi->hostcache);
Curl_cpool_destroy(&multi->cpool);
+ Curl_ssl_scache_destroy(multi->ssl_scache);
free(multi);
return NULL;
}
{
return Curl_multi_handle(CURL_SOCKET_HASH_TABLE_SIZE,
CURL_CONNECTION_HASH_SIZE,
- CURL_DNS_HASH_SIZE);
+ CURL_DNS_HASH_SIZE,
+ CURL_TLS_SESSION_SIZE);
}
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
Curl_hash_destroy(&multi->proto_hash);
Curl_hash_destroy(&multi->hostcache);
Curl_psl_destroy(&multi->psl);
+ Curl_ssl_scache_destroy(multi->ssl_scache);
#ifdef USE_WINSOCK
WSACloseEvent(multi->wsa_event);
curl_push_callback push_cb;
void *push_userp;
- /* Hostname cache */
- struct Curl_hash hostcache;
+ struct Curl_hash hostcache; /* Hostname cache */
+ struct Curl_ssl_scache *ssl_scache; /* TLS session pool */
#ifdef USE_LIBPSL
/* PSL cache. */
socket, connection and dns hashes */
struct Curl_multi *Curl_multi_handle(size_t hashsize,
size_t chashsize,
- size_t dnssize);
+ size_t dnssize,
+ size_t sesssize);
/* the write bits start at bit 16 for the *getsock() bitmap */
#define GETSOCK_WRITEBITSTART 16
#endif
#ifdef USE_SSL
if(data->share->ssl_scache == data->state.ssl_scache)
- data->state.ssl_scache = NULL;
+ data->state.ssl_scache = data->multi ? data->multi->ssl_scache : NULL;
#endif
#ifdef USE_LIBPSL
if(data->psl == &data->share->psl)
#include "url.h"
#include "getinfo.h"
#include "vtls/vtls.h"
-#include "vtls/vtls_scache.h"
#include "vquic/vquic.h"
#include "select.h"
#include "multiif.h"
data->state.url = data->set.str[STRING_SET_URL];
#ifdef USE_SSL
- if(!data->state.ssl_scache) {
- /* There was no ssl session cache set via a share, so we create
- * one just for this transfer alone. Most transfers talk to just
- * one host, but redirects may involve several occasionally. */
- result = Curl_ssl_scache_create(3, 2, &data->state.ssl_scache);
- if(result)
- return result;
- }
+ if(!data->state.ssl_scache)
+ /* There was no ssl session cache set via a share, use the multi one */
+ data->state.ssl_scache = data->multi->ssl_scache;
#endif
data->state.requests = 0;
void Curl_ssl_close_all(struct Curl_easy *data)
{
- /* kill the session ID cache if not shared */
- if(data->state.ssl_scache && !CURL_SHARE_ssl_scache(data)) {
- Curl_ssl_scache_destroy(data->state.ssl_scache);
- data->state.ssl_scache = NULL;
- }
-
if(Curl_ssl->close_all)
Curl_ssl->close_all(data);
}
#else /* USE_SSL */
-#define Curl_ssl_scache_create(x,y) CURLE_OK
-#define Curl_ssl_scache_destroy(x) CURLE_OK
+#define Curl_ssl_scache_create(x,y,z) ((void)x, CURLE_OK)
+#define Curl_ssl_scache_destroy(x) do {} while(0)
#endif /* USE_SSL (else) */