diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-12 11:41:43 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-18 13:49:04 +0200 |
commit | 93fdd88a422e9447ffe7a71b8caf1f4075e8ecf3 (patch) | |
tree | 94129cb1b6fecbaa964b19677d9b1817c4c1cfff /src/plugins | |
parent | 90d8eaad8f0fd50033169f859b450aab0303e99b (diff) |
Hold QSslContext in shared_ptr
... instead of QSharedPointer.
QSharedPointer performs twice as many atomic operations per pointer
copy as std::shared_ptr, and this is private API, we're not bound by
BC constraints, so we can port to the more efficient version.
Change-Id: I2e2a02493565a7ca51c86ec0ed66b6ce7c763e41
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/tls/openssl/qdtls_openssl_p.h | 2 | ||||
-rw-r--r-- | src/plugins/tls/openssl/qsslcontext_openssl.cpp | 9 | ||||
-rw-r--r-- | src/plugins/tls/openssl/qsslcontext_openssl_p.h | 5 | ||||
-rw-r--r-- | src/plugins/tls/openssl/qtls_openssl.cpp | 4 | ||||
-rw-r--r-- | src/plugins/tls/openssl/qtls_openssl_p.h | 6 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/plugins/tls/openssl/qdtls_openssl_p.h b/src/plugins/tls/openssl/qdtls_openssl_p.h index d10d4ce584..8f2b59c8b0 100644 --- a/src/plugins/tls/openssl/qdtls_openssl_p.h +++ b/src/plugins/tls/openssl/qdtls_openssl_p.h @@ -92,7 +92,7 @@ public: using BioMethod = QSharedPointer<BIO_METHOD>; BioMethod bioMethod; - using TlsContext = QSharedPointer<QSslContext>; + using TlsContext = std::shared_ptr<QSslContext>; TlsContext tlsContext; using TlsConnection = QSharedPointer<SSL>; diff --git a/src/plugins/tls/openssl/qsslcontext_openssl.cpp b/src/plugins/tls/openssl/qsslcontext_openssl.cpp index ee69f5aa44..1b32ad37dc 100644 --- a/src/plugins/tls/openssl/qsslcontext_openssl.cpp +++ b/src/plugins/tls/openssl/qsslcontext_openssl.cpp @@ -172,14 +172,15 @@ QSslContext::~QSslContext() q_SSL_SESSION_free(session); } -QSharedPointer<QSslContext> QSslContext::sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading) +std::shared_ptr<QSslContext> QSslContext::sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading) { - QSharedPointer<QSslContext> sslContext = QSharedPointer<QSslContext>::create(); - initSslContext(sslContext.data(), mode, configuration, allowRootCertOnDemandLoading); + struct AccessToPrivateCtor : QSslContext {}; + std::shared_ptr<QSslContext> sslContext = std::make_shared<AccessToPrivateCtor>(); + initSslContext(sslContext.get(), mode, configuration, allowRootCertOnDemandLoading); return sslContext; } -QSharedPointer<QSslContext> QSslContext::sharedFromPrivateConfiguration(QSslSocket::SslMode mode, QSslConfigurationPrivate *privConfiguration, +std::shared_ptr<QSslContext> QSslContext::sharedFromPrivateConfiguration(QSslSocket::SslMode mode, QSslConfigurationPrivate *privConfiguration, bool allowRootCertOnDemandLoading) { return sharedFromConfiguration(mode, privConfiguration, allowRootCertOnDemandLoading); diff --git a/src/plugins/tls/openssl/qsslcontext_openssl_p.h b/src/plugins/tls/openssl/qsslcontext_openssl_p.h index 398ab9bb57..f031386ee1 100644 --- a/src/plugins/tls/openssl/qsslcontext_openssl_p.h +++ b/src/plugins/tls/openssl/qsslcontext_openssl_p.h @@ -69,9 +69,9 @@ public: ~QSslContext(); - static QSharedPointer<QSslContext> sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, + static std::shared_ptr<QSslContext> sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading); - static QSharedPointer<QSslContext> sharedFromPrivateConfiguration(QSslSocket::SslMode mode, QSslConfigurationPrivate *privConfiguration, + static std::shared_ptr<QSslContext> sharedFromPrivateConfiguration(QSslSocket::SslMode mode, QSslConfigurationPrivate *privConfiguration, bool allowRootCertOnDemandLoading); static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions); @@ -103,7 +103,6 @@ public: protected: QSslContext(); - friend class QSharedPointer<QSslContext>; private: static void initSslContext(QSslContext* sslContext, QSslSocket::SslMode mode, const QSslConfiguration &configuration, diff --git a/src/plugins/tls/openssl/qtls_openssl.cpp b/src/plugins/tls/openssl/qtls_openssl.cpp index ec4303bcdc..db7316e927 100644 --- a/src/plugins/tls/openssl/qtls_openssl.cpp +++ b/src/plugins/tls/openssl/qtls_openssl.cpp @@ -504,13 +504,13 @@ void TlsCryptographOpenSSL::init(QSslSocket *qObj, QSslSocketPrivate *dObj) caToFetch = QSslCertificate{}; } -void TlsCryptographOpenSSL::checkSettingSslContext(QSharedPointer<QSslContext> tlsContext) +void TlsCryptographOpenSSL::checkSettingSslContext(std::shared_ptr<QSslContext> tlsContext) { if (!sslContextPointer) sslContextPointer = std::move(tlsContext); } -QSharedPointer<QSslContext> TlsCryptographOpenSSL::sslContext() const +std::shared_ptr<QSslContext> TlsCryptographOpenSSL::sslContext() const { return sslContextPointer; } diff --git a/src/plugins/tls/openssl/qtls_openssl_p.h b/src/plugins/tls/openssl/qtls_openssl_p.h index 48c9223f99..9e7283b15d 100644 --- a/src/plugins/tls/openssl/qtls_openssl_p.h +++ b/src/plugins/tls/openssl/qtls_openssl_p.h @@ -80,8 +80,8 @@ public: ~TlsCryptographOpenSSL(); void init(QSslSocket *qObj, QSslSocketPrivate *dObj) override; - void checkSettingSslContext(QSharedPointer<QSslContext> tlsContext) override; - QSharedPointer<QSslContext> sslContext() const override; + void checkSettingSslContext(std::shared_ptr<QSslContext> tlsContext) override; + std::shared_ptr<QSslContext> sslContext() const override; QList<QSslError> tlsErrors() const override; @@ -133,7 +133,7 @@ private: bool initSslContext(); void destroySslContext(); - QSharedPointer<QSslContext> sslContextPointer; + std::shared_ptr<QSslContext> sslContextPointer; SSL *ssl = nullptr; // TLSTODO: RAII. QList<QSslErrorEntry> errorList; |