Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sess_hits counter on the server #1974

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ssl/ssl_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ static enum ssl_hs_wait_t ssl_lookup_session(
// TODO(davidben): This should probably move it to the front of the list.
if (session == nullptr) {
ssl_update_counter(ssl->session_ctx.get(),
ssl->session_ctx->stats.sess_miss, true);
ssl->session_ctx->stats.sess_miss, true);
}
}

Expand Down Expand Up @@ -705,15 +705,17 @@ static enum ssl_hs_wait_t ssl_lookup_session(
if (!ssl_session_is_time_valid(ssl, session.get())) {
ssl_update_counter(ssl->session_ctx.get(),
ssl->session_ctx->stats.sess_timeout, true);
if(session) {
if (session) {
// The session was from the cache, so remove it.
SSL_CTX_remove_session(ssl->session_ctx.get(), session.get());
session.reset();
}
}

ssl_update_counter(ssl->session_ctx.get(),
ssl->session_ctx->stats.sess_hit, true);
if (session) {
ssl_update_counter(ssl->session_ctx.get(), ssl->session_ctx->stats.sess_hit,
true);
}
*out_session = std::move(session);
return ssl_hs_ok;
}
Expand Down
3 changes: 3 additions & 0 deletions ssl/ssl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8510,6 +8510,9 @@ TEST_P(SSLVersionTest, SessionMissCache) {
// Subsequent connections will all be both timeouts and misses.
EXPECT_EQ(SSL_CTX_sess_misses(server_ctx_.get()), kNumConnections - 1);
EXPECT_EQ(SSL_CTX_sess_timeouts(server_ctx_.get()), kNumConnections);
// Check that |sess_hits| is not incorrectly incremented on either end.
EXPECT_EQ(SSL_CTX_sess_hits(client_ctx_.get()), 0);
EXPECT_EQ(SSL_CTX_sess_hits(server_ctx_.get()), 0);
}

// Callback function to force an external session cache counter update.
Expand Down
Loading