22 #include <gtest/gtest.h> 23 #include <gmock/gmock.h> 34 cache_.emplace(identity,
std::move(session));
39 auto it = cache_.find(identity);
40 if (it == cache_.end()) {
53 mutable std::map<std::string, SSLSessionPtr> cache_;
62 sessions_.emplace_back(it.first, it.second);
65 std::make_unique<FakeSessionCallbacks>()));
68 std::vector<std::pair<SSL_SESSION*, size_t>>
sessions_;
69 std::unique_ptr<ThreadSafeSSLSessionCache>
cache_;
73 const size_t numRounds = 100;
78 std::thread writer([&] () {
79 for (
size_t j = 0; j < numRounds; ++j) {
80 for (
size_t i = 0;
i < sessions_.size(); ++
i) {
82 cache_->setSSLSession(
83 folly::to<std::string>(
"host ", j,
i),
89 std::thread reader([&] () {
90 for (
size_t j = 0; j < numRounds; ++j) {
91 for (
size_t i = 0;
i < sessions_.size(); ++
i) {
93 auto sess = cache_->getSSLSession(
94 folly::to<std::string>(
"host ", j,
i));
SSLSessionPtr createPersistentTestSession(std::pair< SSL_SESSION *, size_t > session)
TEST_F(TestInfoTest, Names)
constexpr detail::Map< Move > move
std::unique_ptr< ThreadSafeSSLSessionCache > cache_
void setSSLSession(const std::string &identity, SSLSessionPtr session) noexceptoverride
requires E e noexcept(noexcept(s.error(std::move(e))))
#define EXPECT_GE(val1, val2)
std::unique_ptr< SSL_SESSION, SessionDestructor > SSLSessionPtr
std::vector< std::pair< SSL_SESSION *, size_t > > getSessions()
SSLSessionPtr getSSLSession(const std::string &identity) const noexceptoverride
std::vector< std::pair< SSL_SESSION *, size_t > > sessions_
ThreadSafeSSLSessionCacheTest()
bool removeSSLSession(const std::string &) noexceptoverride