21#include <openssl/ssl.h>
50 other.sess_ =
nullptr;
56 ::SSL_SESSION_free(
sess_);
58 other.sess_ =
nullptr;
69 return sess_ < rhs.sess_;
72 explicit operator bool()
const
74 return sess_ !=
nullptr;
80 ::SSL_SESSION_free(
sess_);
95 typedef std::unique_ptr<Key>
UPtr;
97 Key(
const std::string &key_arg,
100 cache(std::move(cache_arg))
112 mi->second.emplace(sess);
118 auto ins =
cache->
map.emplace(std::piecewise_construct,
119 std::forward_as_tuple(
key),
120 std::forward_as_tuple());
121 ins.first->second.emplace(sess);
132 template <
typename FUNC>
133 void extract(
const std::string &key, FUNC func)
141 throw openssl_sess_cache_error(
"internal error: SessionSet is empty");
142 auto ssi = ss.begin();
145 func(
ssi->openssl_session());
165 typedef std::map<std::string, SessionSet>
Map;
Key(const std::string &key_arg, OpenSSLSessionCache::Ptr cache_arg)
std::unique_ptr< Key > UPtr
OpenSSLSessionCache::Ptr cache
void commit(::SSL_SESSION *sess)
Session & operator=(Session &&other) noexcept
Session & operator=(const Session &)=delete
Session(::SSL_SESSION *sess)
::SSL_SESSION * openssl_session() const
bool operator<(const Session &rhs) const
Session(Session &&other) noexcept
Session(const Session &)=delete
std::map< std::string, SessionSet > Map
void remove_session(Map::iterator mi, SessionSet &ss, SessionSet::iterator ssi)
RCPtr< OpenSSLSessionCache > Ptr
void extract(const std::string &key, FUNC func)
OPENVPN_EXCEPTION(openssl_sess_cache_error)
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
auto find(MAP_SET &ms, const KEY &k)