MXS-2486: Make SSL configurations immutable

Changes to SSL configurations is expected to be rare which allows them to
be made into immutable objects once created. This is an acceptable
compromise between performance and usability.
This commit is contained in:
Markus Mäkelä
2019-05-24 13:11:24 +03:00
parent 52ef9afcc6
commit 859e930466
2 changed files with 13 additions and 10 deletions

View File

@ -422,7 +422,7 @@ SSLProvider::SSLProvider(std::unique_ptr<mxs::SSLContext> context)
mxs::SSLContext* SSLProvider::context() const
{
mxb_assert_message(mxs::RoutingWorker::get_current(), "Must be used on a RoutingWorker");
return m_context->get();
return m_context.get();
}
const mxs::SSLConfig& SSLProvider::config() const
@ -432,10 +432,8 @@ const mxs::SSLConfig& SSLProvider::config() const
void SSLProvider::set_context(std::unique_ptr<mxs::SSLContext> ssl)
{
mxb_assert_message(mxs::RoutingWorker::get_current()
== mxs::RoutingWorker::get(mxs::RoutingWorker::MAIN),
"Must be only set on the main RoutingWorker");
m_config = ssl ? ssl->config() : mxs::SSLConfig {};
m_context.assign(std::move(ssl));
mxb_assert(ssl);
m_context = std::move(ssl);
m_config = m_context->config();
}
}