diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index d6f6149b..008a90fa 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -1854,9 +1854,6 @@ OPENSSL_EXPORT unsigned long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, // session cache. OPENSSL_EXPORT unsigned long SSL_CTX_sess_get_cache_size(const SSL_CTX *ctx); -// SSL_CTX_sessions returns |ctx|'s internal session cache. -OPENSSL_EXPORT LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx); - // SSL_CTX_sess_number returns the number of sessions in |ctx|'s internal // session cache. OPENSSL_EXPORT size_t SSL_CTX_sess_number(const SSL_CTX *ctx); diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc index 9c551c2a..607bf07d 100644 --- a/ssl/ssl_lib.cc +++ b/ssl/ssl_lib.cc @@ -1566,9 +1566,8 @@ int SSL_get_secure_renegotiation_support(const SSL *ssl) { ssl->s3->send_connection_binding; } -LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx) { return ctx->sessions; } - size_t SSL_CTX_sess_number(const SSL_CTX *ctx) { + MutexReadLock lock(const_cast(&ctx->lock)); return lh_SSL_SESSION_num_items(ctx->sessions); } diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc index 64998d8e..6c9db80c 100644 --- a/ssl/ssl_session.cc +++ b/ssl/ssl_session.cc @@ -1041,7 +1041,8 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session) { // Enforce any cache size limits. if (SSL_CTX_sess_get_cache_size(ctx) > 0) { - while (SSL_CTX_sess_number(ctx) > SSL_CTX_sess_get_cache_size(ctx)) { + while (lh_SSL_SESSION_num_items(ctx->sessions) > + SSL_CTX_sess_get_cache_size(ctx)) { if (!remove_session_lock(ctx, ctx->session_cache_tail, 0)) { break; } diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc index 88d8e3f8..2ee01248 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc @@ -1399,7 +1399,7 @@ static bool CacheEquals(SSL_CTX *ctx, // Check the hash table. std::vector actual, expected_copy; - lh_SSL_SESSION_doall_arg(SSL_CTX_sessions(ctx), AppendSession, &actual); + lh_SSL_SESSION_doall_arg(ctx->sessions, AppendSession, &actual); expected_copy = expected; std::sort(actual.begin(), actual.end());