From c2975d33f85d1abfadedfecd0391bcd6cfb0a4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 23 May 2019 15:57:17 +0300 Subject: [PATCH] MXS-2483: Fix dcb.hh includes The header depended on ssl.hh to include the OpenSSL headers even though it used OpenSSL types. By fixing these dependencies the ssl.h header can now freely include the rworker_local type which removes the need for the hidden implementation of SSLProvider. --- include/maxscale/dcb.hh | 4 ++- include/maxscale/ssl.hh | 9 ++++--- server/core/ssl.cc | 58 +++++++---------------------------------- 3 files changed, 18 insertions(+), 53 deletions(-) diff --git a/include/maxscale/dcb.hh b/include/maxscale/dcb.hh index f238bd2db..af93e33e6 100644 --- a/include/maxscale/dcb.hh +++ b/include/maxscale/dcb.hh @@ -17,13 +17,15 @@ */ #include + +#include #include + #include #include #include #include #include -#include #include diff --git a/include/maxscale/ssl.hh b/include/maxscale/ssl.hh index a597feadf..ceb5e6417 100644 --- a/include/maxscale/ssl.hh +++ b/include/maxscale/ssl.hh @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -142,14 +143,14 @@ private: class SSLProvider { public: + SSLProvider(std::unique_ptr context); + const mxs::SSLConfig& config() const; mxs::SSLContext* context() const; void set_context(std::unique_ptr ssl); - SSLProvider(std::unique_ptr&& context); - ~SSLProvider(); - private: - std::unique_ptr m_imp; + mxs::rworker_local> m_context; /**< SSL context */ + mxs::SSLConfig m_config; /**< SSL configuration */ }; } diff --git a/server/core/ssl.cc b/server/core/ssl.cc index 61d99b24f..c8f55badf 100644 --- a/server/core/ssl.cc +++ b/server/core/ssl.cc @@ -197,45 +197,6 @@ static const char* get_ssl_errors() return ssl_errbuf->c_str(); } -class SSLProviderImp -{ -public: - const mxs::SSLConfig& config() const; - mxs::SSLContext* context() const; - void set_context(std::unique_ptr ssl); - - SSLProviderImp(std::unique_ptr&& context); - -private: - mxs::rworker_local> m_context; /**< SSL context */ - mxs::SSLConfig m_config; /**< SSL configuration */ -}; - -const mxs::SSLConfig& SSLProviderImp::config() const -{ - return m_config; -} - -mxs::SSLContext* SSLProviderImp::context() const -{ - mxb_assert_message(mxs::RoutingWorker::get_current(), "Must be used on a RoutingWorker"); - return m_context->get(); -} - -void SSLProviderImp::set_context(std::unique_ptr 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)); -} - -SSLProviderImp::SSLProviderImp(std::unique_ptr&& context) - : m_context {std::move(context)} -{ -} - namespace maxscale { @@ -453,27 +414,28 @@ SSLContext::~SSLContext() SSL_CTX_free(m_ctx); } -SSLProvider::SSLProvider(std::unique_ptr&& ssl) - : m_imp(new SSLProviderImp(std::move(ssl))) -{ -} - -SSLProvider::~SSLProvider() +SSLProvider::SSLProvider(std::unique_ptr context) + : m_context {std::move(context)} { } mxs::SSLContext* SSLProvider::context() const { - return m_imp->context(); + mxb_assert_message(mxs::RoutingWorker::get_current(), "Must be used on a RoutingWorker"); + return m_context->get(); } const mxs::SSLConfig& SSLProvider::config() const { - return m_imp->config(); + return m_config; } void SSLProvider::set_context(std::unique_ptr ssl) { - m_imp->set_context(std::move(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)); } }