Loading lib/easy.c +15 −9 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ #include "url.h" #include "getinfo.h" #include "hostip.h" #include "share.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> Loading Loading @@ -233,15 +234,18 @@ CURLcode curl_easy_perform(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) { if (data->hostcache) { if ( ! (data->share && data->share->hostcache) ) { if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) { if (data->hostcache) Curl_hash_destroy(data->hostcache); } data->hostcache = Curl_global_host_cache_get(); } if (!data->hostcache) { if (!data->hostcache) data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo); } return Curl_perform(data); Loading @@ -250,9 +254,11 @@ CURLcode curl_easy_perform(CURL *curl) void curl_easy_cleanup(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } Curl_close(data); } Loading lib/http.c +2 −0 Original line number Diff line number Diff line Loading @@ -853,10 +853,12 @@ CURLcode Curl_http(struct connectdata *conn) } if(data->cookies) { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); co = Curl_cookie_getlist(data->cookies, conn->allocptr.cookiehost? conn->allocptr.cookiehost:host, ppath, (bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE)); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } if (conn->bits.httpproxy && Loading lib/share.c +15 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) break; case CURL_LOCK_DATA_COOKIE: if (!share->cookies) { share->cookies = Curl_cookie_init( NULL, NULL, TRUE ); } break; case CURL_LOCK_DATA_SSL_SESSION: Loading Loading @@ -103,6 +106,10 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) break; case CURL_LOCK_DATA_COOKIE: if (share->cookies) { Curl_cookie_cleanup(share->cookies); share->cookies = NULL; } break; case CURL_LOCK_DATA_SSL_SESSION: Loading Loading @@ -144,6 +151,12 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) if (share->dirty) return CURLSHE_IN_USE; if(share->hostcache) Curl_hash_destroy(share->hostcache); if(share->cookies) Curl_cookie_cleanup(share->cookies); free (share); return CURLSHE_OK; Loading @@ -151,7 +164,8 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) CURLSHcode Curl_share_lock(struct SessionHandle *data, curl_lock_data type, curl_lock_access access) Curl_share_lock(struct SessionHandle *data, curl_lock_data type, curl_lock_access access) { struct Curl_share *share = data->share; Loading lib/share.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "setup.h" #include <curl/curl.h> #include "cookie.h" /* this struct is libcurl-private, don't export details */ struct Curl_share { Loading @@ -37,6 +38,7 @@ struct Curl_share { void *clientdata; curl_hash *hostcache; struct CookieInfo *cookies; }; CURLSHcode Curl_share_lock ( Loading lib/transfer.c +4 −0 Original line number Diff line number Diff line Loading @@ -707,12 +707,14 @@ CURLcode Curl_readwrite(struct connectdata *conn, } else if(data->cookies && checkprefix("Set-Cookie:", k->p)) { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); Curl_cookie_add(data->cookies, TRUE, k->p+11, /* If there is a custom-set Host: name, use it here, or else use real peer host name. */ conn->allocptr.cookiehost? conn->allocptr.cookiehost:conn->name, conn->ppath); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } else if(checkprefix("Last-Modified:", k->p) && (data->set.timecondition || data->set.get_filetime) ) { Loading Loading @@ -1509,12 +1511,14 @@ CURLcode Curl_pretransfer(struct SessionHandle *data) do it now! */ if(data->change.cookielist) { struct curl_slist *list = data->change.cookielist; Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); while(list) { data->cookies = Curl_cookie_init(list->data, data->cookies, data->set.cookiesession); list = list->next; } Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); curl_slist_free_all(data->change.cookielist); /* clean up list */ data->change.cookielist = NULL; /* don't do this again! */ } Loading Loading
lib/easy.c +15 −9 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ #include "url.h" #include "getinfo.h" #include "hostip.h" #include "share.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> Loading Loading @@ -233,15 +234,18 @@ CURLcode curl_easy_perform(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) { if (data->hostcache) { if ( ! (data->share && data->share->hostcache) ) { if (Curl_global_host_cache_use(data) && data->hostcache != Curl_global_host_cache_get()) { if (data->hostcache) Curl_hash_destroy(data->hostcache); } data->hostcache = Curl_global_host_cache_get(); } if (!data->hostcache) { if (!data->hostcache) data->hostcache = Curl_hash_alloc(7, Curl_freednsinfo); } return Curl_perform(data); Loading @@ -250,9 +254,11 @@ CURLcode curl_easy_perform(CURL *curl) void curl_easy_cleanup(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } Curl_close(data); } Loading
lib/http.c +2 −0 Original line number Diff line number Diff line Loading @@ -853,10 +853,12 @@ CURLcode Curl_http(struct connectdata *conn) } if(data->cookies) { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); co = Curl_cookie_getlist(data->cookies, conn->allocptr.cookiehost? conn->allocptr.cookiehost:host, ppath, (bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE)); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } if (conn->bits.httpproxy && Loading
lib/share.c +15 −1 Original line number Diff line number Diff line Loading @@ -76,6 +76,9 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) break; case CURL_LOCK_DATA_COOKIE: if (!share->cookies) { share->cookies = Curl_cookie_init( NULL, NULL, TRUE ); } break; case CURL_LOCK_DATA_SSL_SESSION: Loading Loading @@ -103,6 +106,10 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) break; case CURL_LOCK_DATA_COOKIE: if (share->cookies) { Curl_cookie_cleanup(share->cookies); share->cookies = NULL; } break; case CURL_LOCK_DATA_SSL_SESSION: Loading Loading @@ -144,6 +151,12 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) if (share->dirty) return CURLSHE_IN_USE; if(share->hostcache) Curl_hash_destroy(share->hostcache); if(share->cookies) Curl_cookie_cleanup(share->cookies); free (share); return CURLSHE_OK; Loading @@ -151,7 +164,8 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) CURLSHcode Curl_share_lock(struct SessionHandle *data, curl_lock_data type, curl_lock_access access) Curl_share_lock(struct SessionHandle *data, curl_lock_data type, curl_lock_access access) { struct Curl_share *share = data->share; Loading
lib/share.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "setup.h" #include <curl/curl.h> #include "cookie.h" /* this struct is libcurl-private, don't export details */ struct Curl_share { Loading @@ -37,6 +38,7 @@ struct Curl_share { void *clientdata; curl_hash *hostcache; struct CookieInfo *cookies; }; CURLSHcode Curl_share_lock ( Loading
lib/transfer.c +4 −0 Original line number Diff line number Diff line Loading @@ -707,12 +707,14 @@ CURLcode Curl_readwrite(struct connectdata *conn, } else if(data->cookies && checkprefix("Set-Cookie:", k->p)) { Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); Curl_cookie_add(data->cookies, TRUE, k->p+11, /* If there is a custom-set Host: name, use it here, or else use real peer host name. */ conn->allocptr.cookiehost? conn->allocptr.cookiehost:conn->name, conn->ppath); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); } else if(checkprefix("Last-Modified:", k->p) && (data->set.timecondition || data->set.get_filetime) ) { Loading Loading @@ -1509,12 +1511,14 @@ CURLcode Curl_pretransfer(struct SessionHandle *data) do it now! */ if(data->change.cookielist) { struct curl_slist *list = data->change.cookielist; Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); while(list) { data->cookies = Curl_cookie_init(list->data, data->cookies, data->set.cookiesession); list = list->next; } Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); curl_slist_free_all(data->change.cookielist); /* clean up list */ data->change.cookielist = NULL; /* don't do this again! */ } Loading