diff options
Diffstat (limited to 'libs/libcurl/src/share.c')
-rw-r--r-- | libs/libcurl/src/share.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/libs/libcurl/src/share.c b/libs/libcurl/src/share.c index 6caed2f7a6..d31b23f512 100644 --- a/libs/libcurl/src/share.c +++ b/libs/libcurl/src/share.c @@ -30,6 +30,7 @@ #include "share.h"
#include "psl.h"
#include "vtls/vtls.h"
+#include "vtls/vtls_scache.h"
#include "hsts.h"
#include "url.h"
@@ -45,7 +46,19 @@ curl_share_init(void) if(share) {
share->magic = CURL_GOOD_SHARE;
share->specifier |= (1 << CURL_LOCK_DATA_SHARE);
- Curl_init_dnscache(&share->hostcache, 23);
+ Curl_dnscache_init(&share->dnscache, 23);
+ share->admin = curl_easy_init();
+ if(!share->admin) {
+ free(share);
+ return NULL;
+ }
+ /* admin handles have mid 0 */
+ share->admin->mid = 0;
+ share->admin->state.internal = TRUE;
+#ifdef DEBUGBUILD
+ if(getenv("CURL_DEBUG"))
+ share->admin->set.verbose = TRUE;
+#endif
}
return share;
@@ -108,12 +121,13 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) case CURL_LOCK_DATA_SSL_SESSION:
#ifdef USE_SSL
- if(!share->sslsession) {
- share->max_ssl_sessions = 8;
- share->sslsession = calloc(share->max_ssl_sessions,
- sizeof(struct Curl_ssl_session));
- share->sessionage = 0;
- if(!share->sslsession)
+ if(!share->ssl_scache) {
+ /* There is no way (yet) for the application to configure the
+ * session cache size, shared between many transfers. As for curl
+ * itself, a high session count will impact startup time. Also, the
+ * scache is not optimized for several hundreds of peers. So,
+ * keep it at a reasonable level. */
+ if(Curl_ssl_scache_create(25, 2, &share->ssl_scache))
res = CURLSHE_NOMEM;
}
#else
@@ -123,10 +137,8 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) case CURL_LOCK_DATA_CONNECT:
/* It is safe to set this option several times on a share. */
- if(!share->cpool.idata) {
- if(Curl_cpool_init(&share->cpool, Curl_on_disconnect,
- NULL, share, 103))
- res = CURLSHE_NOMEM;
+ if(!share->cpool.initialised) {
+ Curl_cpool_init(&share->cpool, share->admin, share, 103);
}
break;
@@ -174,7 +186,10 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) case CURL_LOCK_DATA_SSL_SESSION:
#ifdef USE_SSL
- Curl_safefree(share->sslsession);
+ if(share->ssl_scache) {
+ Curl_ssl_scache_destroy(share->ssl_scache);
+ share->ssl_scache = NULL;
+ }
#else
res = CURLSHE_NOT_BUILT_IN;
#endif
@@ -234,7 +249,8 @@ curl_share_cleanup(CURLSH *sh) if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
Curl_cpool_destroy(&share->cpool);
}
- Curl_hash_destroy(&share->hostcache);
+
+ Curl_dnscache_destroy(&share->dnscache);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
Curl_cookie_cleanup(share->cookies);
@@ -245,15 +261,14 @@ curl_share_cleanup(CURLSH *sh) #endif
#ifdef USE_SSL
- if(share->sslsession) {
- size_t i;
- for(i = 0; i < share->max_ssl_sessions; i++)
- Curl_ssl_kill_session(&(share->sslsession[i]));
- free(share->sslsession);
+ if(share->ssl_scache) {
+ Curl_ssl_scache_destroy(share->ssl_scache);
+ share->ssl_scache = NULL;
}
#endif
Curl_psl_destroy(&share->psl);
+ Curl_close(&share->admin);
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|