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:
parent
52ef9afcc6
commit
859e930466
@ -151,12 +151,17 @@ public:
|
||||
|
||||
SSLProvider(std::unique_ptr<mxs::SSLContext> context);
|
||||
|
||||
// Current configuration
|
||||
const mxs::SSLConfig& config() const;
|
||||
mxs::SSLContext* context() const;
|
||||
void set_context(std::unique_ptr<mxs::SSLContext> ssl);
|
||||
|
||||
// The context or nullptr if no context is set
|
||||
mxs::SSLContext* context() const;
|
||||
|
||||
// Set the context, argument must not be null
|
||||
void set_context(std::unique_ptr<mxs::SSLContext> ssl);
|
||||
|
||||
private:
|
||||
mxs::rworker_local<std::shared_ptr<mxs::SSLContext>> m_context; /**< SSL context */
|
||||
mxs::SSLConfig m_config; /**< SSL configuration */
|
||||
std::unique_ptr<mxs::SSLContext> m_context; /**< SSL context */
|
||||
mxs::SSLConfig m_config; /**< SSL configuration */
|
||||
};
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user