From 8f50a5c7e517dee2dbdf01c0228c1baa6f03cdc1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 25 Nov 2011 14:58:55 +0100 Subject: SSLSESSION_SHARED: new macro to check if session is shared Added convenience macro to use to check if a handle is using a shared SSL session, and fixed so that Curl_ssl_close_all() doesn't lock when the session isn't shared. --- lib/sslgen.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/sslgen.c b/lib/sslgen.c index b9176b76c..9ad4ab1d2 100644 --- a/lib/sslgen.c +++ b/lib/sslgen.c @@ -66,6 +66,11 @@ /* The last #include file should be: */ #include "memdebug.h" +/* convenience macro to check if this handle is using a shared SSL session */ +#define SSLSESSION_SHARED(data) (data->share && \ + (data->share->specifier & \ + (1<share && - (data->share->specifier & (1<share->sessionage; } @@ -270,8 +274,7 @@ int Curl_ssl_getsessionid(struct connectdata *conn, } /* Unlock */ - if(data->share && - (data->share->specifier & (1<data; - if(data->share && data->share->sslsession == data->state.session) + if(SSLSESSION_SHARED(data)) Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE); @@ -323,7 +326,7 @@ void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid) } } - if(data->share && data->share->sslsession == data->state.session) + if(SSLSESSION_SHARED(data)) Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION); } @@ -356,7 +359,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, the oldest if necessary) */ /* If using shared SSL session, lock! */ - if(data->share && data->share->sslsession == data->state.session) { + if(SSLSESSION_SHARED(data)) { Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE); general_age = &data->share->sessionage; } @@ -390,7 +393,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, /* Unlock */ - if(data->share && data->share->sslsession == data->state.session) + if(SSLSESSION_SHARED(data)) Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION); if(!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config)) { @@ -406,12 +409,8 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn, void Curl_ssl_close_all(struct SessionHandle *data) { long i; - /* kill the session ID cache */ - if(data->state.session && - !(data->share && data->share->sslsession == data->state.session)) { - - Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE); - + /* kill the session ID cache if not shared */ + if(data->state.session && !SSLSESSION_SHARED(data)) { for(i=0; i< data->set.ssl.numsessions; i++) /* the single-killer function handles empty table slots */ Curl_ssl_kill_session(&data->state.session[i]); @@ -419,8 +418,6 @@ void Curl_ssl_close_all(struct SessionHandle *data) /* free the cache data */ free(data->state.session); data->state.session = NULL; - - Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION); } curlssl_close_all(data); -- cgit v1.2.3