use unique_ptr instead of shared_ptr for torrent ssl context

This commit is contained in:
arvidn 2020-03-13 12:49:07 +01:00 committed by Arvid Norberg
parent 10559ed524
commit f27738a7b9
2 changed files with 4 additions and 4 deletions

View File

@ -1258,7 +1258,7 @@ namespace libtorrent {
storage_holder m_storage; storage_holder m_storage;
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
std::shared_ptr<boost::asio::ssl::context> m_ssl_ctx; std::unique_ptr<boost::asio::ssl::context> m_ssl_ctx;
bool verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx); bool verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx);

View File

@ -1625,8 +1625,8 @@ bool is_downloading_state(int const st)
// create the SSL context for this torrent. We need to // create the SSL context for this torrent. We need to
// inject the root certificate, and no other, to // inject the root certificate, and no other, to
// verify other peers against // verify other peers against
std::shared_ptr<context> ctx = std::make_shared<context>( std::unique_ptr<context> ctx(new context(
aux::ssl_version(settings().get_int(settings_pack::ssl_version))); aux::ssl_version(settings().get_int(settings_pack::ssl_version))));
if (!ctx) if (!ctx)
{ {
@ -1712,7 +1712,7 @@ bool is_downloading_state(int const st)
ctx->load_verify_file(filename); ctx->load_verify_file(filename);
#endif #endif
// if all went well, set the torrent ssl context to this one // if all went well, set the torrent ssl context to this one
m_ssl_ctx = ctx; m_ssl_ctx = std::move(ctx);
// tell the client we need a cert for this torrent // tell the client we need a cert for this torrent
alerts().emplace_alert<torrent_need_cert_alert>(get_handle()); alerts().emplace_alert<torrent_need_cert_alert>(get_handle());
} }