Loading lib/easy.c +0 −5 Original line number Original line Diff line number Diff line Loading @@ -391,11 +391,6 @@ void curl_easy_cleanup(CURL *curl) if(!data) if(!data) return; return; if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } Curl_close(data); Curl_close(data); } } Loading lib/hostip.c +7 −2 Original line number Original line Diff line number Diff line Loading @@ -263,8 +263,9 @@ void Curl_hostcache_prune(struct SessionHandle *data) { { time_t now; time_t now; if(data->set.dns_cache_timeout == -1) if((data->set.dns_cache_timeout == -1) || !data->hostcache) /* cache forever means never prune! */ /* cache forever means never prune, and NULL hostcache means we can't do it */ return; return; if(data->share) if(data->share) Loading Loading @@ -459,7 +460,11 @@ int Curl_resolv(struct connectdata *conn, } } } } else { else { if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); dns->inuse++; /* we use it! */ dns->inuse++; /* we use it! */ if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); rc = CURLRESOLV_RESOLVED; rc = CURLRESOLV_RESOLVED; } } Loading lib/url.c +18 −13 Original line number Original line Diff line number Diff line Loading @@ -204,6 +204,12 @@ CURLcode Curl_close(struct SessionHandle *data) /* Loop through all open connections and kill them one by one */ /* Loop through all open connections and kill them one by one */ while(-1 != ConnectionKillOne(data)); while(-1 != ConnectionKillOne(data)); if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } #ifdef USE_SSLEAY #ifdef USE_SSLEAY /* Close down all open SSL info and sessions */ /* Close down all open SSL info and sessions */ Curl_SSL_Close_All(data); Curl_SSL_Close_All(data); Loading Loading @@ -1432,6 +1438,17 @@ CURLcode Curl_disconnect(struct connectdata *conn) data = conn->data; data = conn->data; if(conn->dns_entry) Curl_resolv_unlock(data, conn->dns_entry); /* done with this */ #if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) /* scan for DNS cache entries still marked as in use */ Curl_hash_apply(data->hostcache, NULL, Curl_scan_cache_used); #endif Curl_hostcache_prune(data); /* kill old DNS cache entries */ /* /* * The range string is usually freed in curl_done(), but we might * The range string is usually freed in curl_done(), but we might * get here *instead* if we fail prematurely. Thus we need to be able * get here *instead* if we fail prematurely. Thus we need to be able Loading Loading @@ -3230,8 +3247,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, if(conn->bits.reuse) { if(conn->bits.reuse) { /* re-used connection, no resolving is necessary */ /* re-used connection, no resolving is necessary */ hostaddr = NULL; hostaddr = NULL; conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh /* we'll need to clear conn->dns_entry later in Curl_disconnect() */ dns entry struct to point to */ if (conn->bits.httpproxy) if (conn->bits.httpproxy) fix_hostname(conn, &conn->host); fix_hostname(conn, &conn->host); Loading Loading @@ -3480,17 +3496,6 @@ CURLcode Curl_done(struct connectdata **connp, conn->newurl = NULL; conn->newurl = NULL; } } if(conn->dns_entry) Curl_resolv_unlock(conn->data, conn->dns_entry); /* done with this */ #if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) /* scan for DNS cache entries still marked as in use */ Curl_hash_apply(data->hostcache, NULL, Curl_scan_cache_used); #endif Curl_hostcache_prune(data); /* kill old DNS cache entries */ /* this calls the protocol-specific function pointer previously set */ /* this calls the protocol-specific function pointer previously set */ if(conn->curl_done) if(conn->curl_done) result = conn->curl_done(conn, status); result = conn->curl_done(conn, status); Loading tests/data/test506 +28 −24 Original line number Original line Diff line number Diff line Loading @@ -79,11 +79,11 @@ unlock: cookie <Pigs in space>: 11 lock: cookie <Pigs in space>: 12 lock: cookie <Pigs in space>: 12 unlock: cookie <Pigs in space>: 13 unlock: cookie <Pigs in space>: 13 run 1: set cookie 1, 2 and 3 run 1: set cookie 1, 2 and 3 CLEANUP lock: dns <Pigs in space>: 14 lock: dns <Pigs in space>: 14 unlock: dns <Pigs in space>: 15 unlock: dns <Pigs in space>: 15 lock: dns <Pigs in space>: 16 lock: dns <Pigs in space>: 16 unlock: dns <Pigs in space>: 17 unlock: dns <Pigs in space>: 17 CLEANUP lock: cookie <Pigs in space>: 18 lock: cookie <Pigs in space>: 18 unlock: cookie <Pigs in space>: 19 unlock: cookie <Pigs in space>: 19 *** run 2 *** run 2 Loading @@ -93,49 +93,53 @@ unlock: share <Pigs in space>: 21 PERFORM PERFORM lock: dns <Pigs in space>: 22 lock: dns <Pigs in space>: 22 unlock: dns <Pigs in space>: 23 unlock: dns <Pigs in space>: 23 lock: cookie <Pigs in space>: 24 lock: dns <Pigs in space>: 24 unlock: cookie <Pigs in space>: 25 unlock: dns <Pigs in space>: 25 lock: cookie <Pigs in space>: 26 lock: cookie <Pigs in space>: 26 unlock: cookie <Pigs in space>: 27 unlock: cookie <Pigs in space>: 27 lock: cookie <Pigs in space>: 28 lock: cookie <Pigs in space>: 28 unlock: cookie <Pigs in space>: 29 unlock: cookie <Pigs in space>: 29 lock: cookie <Pigs in space>: 30 unlock: cookie <Pigs in space>: 31 run 2: set cookie 4 and 5 run 2: set cookie 4 and 5 lock: dns <Pigs in space>: 30 CLEANUP unlock: dns <Pigs in space>: 31 lock: dns <Pigs in space>: 32 lock: dns <Pigs in space>: 32 unlock: dns <Pigs in space>: 33 unlock: dns <Pigs in space>: 33 CLEANUP lock: dns <Pigs in space>: 34 lock: cookie <Pigs in space>: 34 unlock: dns <Pigs in space>: 35 unlock: cookie <Pigs in space>: 35 lock: cookie <Pigs in space>: 36 unlock: cookie <Pigs in space>: 37 *** run 3 *** run 3 CURLOPT_SHARE CURLOPT_SHARE lock: share <Pigs in space>: 36 lock: share <Pigs in space>: 38 unlock: share <Pigs in space>: 37 unlock: share <Pigs in space>: 39 CURLOPT_COOKIEJAR CURLOPT_COOKIEJAR PERFORM PERFORM lock: dns <Pigs in space>: 38 lock: dns <Pigs in space>: 40 unlock: dns <Pigs in space>: 39 unlock: dns <Pigs in space>: 41 lock: cookie <Pigs in space>: 40 lock: dns <Pigs in space>: 42 unlock: cookie <Pigs in space>: 41 unlock: dns <Pigs in space>: 43 lock: cookie <Pigs in space>: 42 unlock: cookie <Pigs in space>: 43 lock: cookie <Pigs in space>: 44 lock: cookie <Pigs in space>: 44 unlock: cookie <Pigs in space>: 45 unlock: cookie <Pigs in space>: 45 lock: cookie <Pigs in space>: 46 unlock: cookie <Pigs in space>: 47 lock: cookie <Pigs in space>: 48 unlock: cookie <Pigs in space>: 49 run 3: overwrite cookie 1 and 4 run 3: overwrite cookie 1 and 4 lock: dns <Pigs in space>: 46 unlock: dns <Pigs in space>: 47 lock: dns <Pigs in space>: 48 unlock: dns <Pigs in space>: 49 try SHARE_CLEANUP... try SHARE_CLEANUP... lock: share <Pigs in space>: 50 lock: share <Pigs in space>: 50 unlock: share <Pigs in space>: 51 unlock: share <Pigs in space>: 51 SHARE_CLEANUP failed, correct SHARE_CLEANUP failed, correct CLEANUP CLEANUP lock: cookie <Pigs in space>: 52 lock: dns <Pigs in space>: 52 unlock: cookie <Pigs in space>: 53 unlock: dns <Pigs in space>: 53 lock: dns <Pigs in space>: 54 unlock: dns <Pigs in space>: 55 lock: cookie <Pigs in space>: 56 unlock: cookie <Pigs in space>: 57 SHARE_CLEANUP SHARE_CLEANUP lock: share <Pigs in space>: 54 lock: share <Pigs in space>: 58 unlock: share <Pigs in space>: 55 unlock: share <Pigs in space>: 59 GLOBAL_CLEANUP GLOBAL_CLEANUP </stdout> </stdout> <stderr> <stderr> Loading Loading
lib/easy.c +0 −5 Original line number Original line Diff line number Diff line Loading @@ -391,11 +391,6 @@ void curl_easy_cleanup(CURL *curl) if(!data) if(!data) return; return; if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } Curl_close(data); Curl_close(data); } } Loading
lib/hostip.c +7 −2 Original line number Original line Diff line number Diff line Loading @@ -263,8 +263,9 @@ void Curl_hostcache_prune(struct SessionHandle *data) { { time_t now; time_t now; if(data->set.dns_cache_timeout == -1) if((data->set.dns_cache_timeout == -1) || !data->hostcache) /* cache forever means never prune! */ /* cache forever means never prune, and NULL hostcache means we can't do it */ return; return; if(data->share) if(data->share) Loading Loading @@ -459,7 +460,11 @@ int Curl_resolv(struct connectdata *conn, } } } } else { else { if(data->share) Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); dns->inuse++; /* we use it! */ dns->inuse++; /* we use it! */ if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); rc = CURLRESOLV_RESOLVED; rc = CURLRESOLV_RESOLVED; } } Loading
lib/url.c +18 −13 Original line number Original line Diff line number Diff line Loading @@ -204,6 +204,12 @@ CURLcode Curl_close(struct SessionHandle *data) /* Loop through all open connections and kill them one by one */ /* Loop through all open connections and kill them one by one */ while(-1 != ConnectionKillOne(data)); while(-1 != ConnectionKillOne(data)); if ( ! (data->share && data->share->hostcache) ) { if ( !Curl_global_host_cache_use(data)) { Curl_hash_destroy(data->hostcache); } } #ifdef USE_SSLEAY #ifdef USE_SSLEAY /* Close down all open SSL info and sessions */ /* Close down all open SSL info and sessions */ Curl_SSL_Close_All(data); Curl_SSL_Close_All(data); Loading Loading @@ -1432,6 +1438,17 @@ CURLcode Curl_disconnect(struct connectdata *conn) data = conn->data; data = conn->data; if(conn->dns_entry) Curl_resolv_unlock(data, conn->dns_entry); /* done with this */ #if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) /* scan for DNS cache entries still marked as in use */ Curl_hash_apply(data->hostcache, NULL, Curl_scan_cache_used); #endif Curl_hostcache_prune(data); /* kill old DNS cache entries */ /* /* * The range string is usually freed in curl_done(), but we might * The range string is usually freed in curl_done(), but we might * get here *instead* if we fail prematurely. Thus we need to be able * get here *instead* if we fail prematurely. Thus we need to be able Loading Loading @@ -3230,8 +3247,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, if(conn->bits.reuse) { if(conn->bits.reuse) { /* re-used connection, no resolving is necessary */ /* re-used connection, no resolving is necessary */ hostaddr = NULL; hostaddr = NULL; conn->dns_entry = NULL; /* we don't connect now so we don't have any fresh /* we'll need to clear conn->dns_entry later in Curl_disconnect() */ dns entry struct to point to */ if (conn->bits.httpproxy) if (conn->bits.httpproxy) fix_hostname(conn, &conn->host); fix_hostname(conn, &conn->host); Loading Loading @@ -3480,17 +3496,6 @@ CURLcode Curl_done(struct connectdata **connp, conn->newurl = NULL; conn->newurl = NULL; } } if(conn->dns_entry) Curl_resolv_unlock(conn->data, conn->dns_entry); /* done with this */ #if defined(CURLDEBUG) && defined(AGGRESIVE_TEST) /* scan for DNS cache entries still marked as in use */ Curl_hash_apply(data->hostcache, NULL, Curl_scan_cache_used); #endif Curl_hostcache_prune(data); /* kill old DNS cache entries */ /* this calls the protocol-specific function pointer previously set */ /* this calls the protocol-specific function pointer previously set */ if(conn->curl_done) if(conn->curl_done) result = conn->curl_done(conn, status); result = conn->curl_done(conn, status); Loading
tests/data/test506 +28 −24 Original line number Original line Diff line number Diff line Loading @@ -79,11 +79,11 @@ unlock: cookie <Pigs in space>: 11 lock: cookie <Pigs in space>: 12 lock: cookie <Pigs in space>: 12 unlock: cookie <Pigs in space>: 13 unlock: cookie <Pigs in space>: 13 run 1: set cookie 1, 2 and 3 run 1: set cookie 1, 2 and 3 CLEANUP lock: dns <Pigs in space>: 14 lock: dns <Pigs in space>: 14 unlock: dns <Pigs in space>: 15 unlock: dns <Pigs in space>: 15 lock: dns <Pigs in space>: 16 lock: dns <Pigs in space>: 16 unlock: dns <Pigs in space>: 17 unlock: dns <Pigs in space>: 17 CLEANUP lock: cookie <Pigs in space>: 18 lock: cookie <Pigs in space>: 18 unlock: cookie <Pigs in space>: 19 unlock: cookie <Pigs in space>: 19 *** run 2 *** run 2 Loading @@ -93,49 +93,53 @@ unlock: share <Pigs in space>: 21 PERFORM PERFORM lock: dns <Pigs in space>: 22 lock: dns <Pigs in space>: 22 unlock: dns <Pigs in space>: 23 unlock: dns <Pigs in space>: 23 lock: cookie <Pigs in space>: 24 lock: dns <Pigs in space>: 24 unlock: cookie <Pigs in space>: 25 unlock: dns <Pigs in space>: 25 lock: cookie <Pigs in space>: 26 lock: cookie <Pigs in space>: 26 unlock: cookie <Pigs in space>: 27 unlock: cookie <Pigs in space>: 27 lock: cookie <Pigs in space>: 28 lock: cookie <Pigs in space>: 28 unlock: cookie <Pigs in space>: 29 unlock: cookie <Pigs in space>: 29 lock: cookie <Pigs in space>: 30 unlock: cookie <Pigs in space>: 31 run 2: set cookie 4 and 5 run 2: set cookie 4 and 5 lock: dns <Pigs in space>: 30 CLEANUP unlock: dns <Pigs in space>: 31 lock: dns <Pigs in space>: 32 lock: dns <Pigs in space>: 32 unlock: dns <Pigs in space>: 33 unlock: dns <Pigs in space>: 33 CLEANUP lock: dns <Pigs in space>: 34 lock: cookie <Pigs in space>: 34 unlock: dns <Pigs in space>: 35 unlock: cookie <Pigs in space>: 35 lock: cookie <Pigs in space>: 36 unlock: cookie <Pigs in space>: 37 *** run 3 *** run 3 CURLOPT_SHARE CURLOPT_SHARE lock: share <Pigs in space>: 36 lock: share <Pigs in space>: 38 unlock: share <Pigs in space>: 37 unlock: share <Pigs in space>: 39 CURLOPT_COOKIEJAR CURLOPT_COOKIEJAR PERFORM PERFORM lock: dns <Pigs in space>: 38 lock: dns <Pigs in space>: 40 unlock: dns <Pigs in space>: 39 unlock: dns <Pigs in space>: 41 lock: cookie <Pigs in space>: 40 lock: dns <Pigs in space>: 42 unlock: cookie <Pigs in space>: 41 unlock: dns <Pigs in space>: 43 lock: cookie <Pigs in space>: 42 unlock: cookie <Pigs in space>: 43 lock: cookie <Pigs in space>: 44 lock: cookie <Pigs in space>: 44 unlock: cookie <Pigs in space>: 45 unlock: cookie <Pigs in space>: 45 lock: cookie <Pigs in space>: 46 unlock: cookie <Pigs in space>: 47 lock: cookie <Pigs in space>: 48 unlock: cookie <Pigs in space>: 49 run 3: overwrite cookie 1 and 4 run 3: overwrite cookie 1 and 4 lock: dns <Pigs in space>: 46 unlock: dns <Pigs in space>: 47 lock: dns <Pigs in space>: 48 unlock: dns <Pigs in space>: 49 try SHARE_CLEANUP... try SHARE_CLEANUP... lock: share <Pigs in space>: 50 lock: share <Pigs in space>: 50 unlock: share <Pigs in space>: 51 unlock: share <Pigs in space>: 51 SHARE_CLEANUP failed, correct SHARE_CLEANUP failed, correct CLEANUP CLEANUP lock: cookie <Pigs in space>: 52 lock: dns <Pigs in space>: 52 unlock: cookie <Pigs in space>: 53 unlock: dns <Pigs in space>: 53 lock: dns <Pigs in space>: 54 unlock: dns <Pigs in space>: 55 lock: cookie <Pigs in space>: 56 unlock: cookie <Pigs in space>: 57 SHARE_CLEANUP SHARE_CLEANUP lock: share <Pigs in space>: 54 lock: share <Pigs in space>: 58 unlock: share <Pigs in space>: 55 unlock: share <Pigs in space>: 59 GLOBAL_CLEANUP GLOBAL_CLEANUP </stdout> </stdout> <stderr> <stderr> Loading