#include <LockingPointer.h>
Public Types | |
typedef Security::LockingPointer< T, UnLocker, Locker > | SelfType |
a helper label to simplify this objects API definitions below More... | |
Public Member Functions | |
constexpr | LockingPointer () |
constructs a nil smart pointer More... | |
constexpr | LockingPointer (std::nullptr_t) |
constructs a nil smart pointer from nullptr More... | |
LockingPointer (T *t) | |
~LockingPointer () | |
use the custom UnLocker to unlock any value still stored. More... | |
LockingPointer (const SelfType &o) | |
const SelfType & | operator= (const SelfType &o) |
LockingPointer (SelfType &&o) | |
SelfType & | operator= (SelfType &&o) |
bool | operator! () const |
operator bool () const | |
bool | operator== (const SelfType &o) const |
bool | operator!= (const SelfType &o) const |
T & | operator* () const |
T * | operator-> () const |
T * | get () const |
Returns raw and possibly nullptr pointer. More... | |
void | resetWithoutLocking (T *t) |
Reset raw pointer - unlock any previous one and save new one without locking. More... | |
void | resetAndLock (T *t) |
void | reset () |
Forget the raw pointer - unlock if any value was set. Become a nil pointer. More... | |
T * | release () |
Forget the raw pointer without unlocking it. Become a nil pointer. More... | |
Private Member Functions | |
void | lock (T *t) |
The lock() method increments Object's reference counter. More... | |
void | unlock () |
Private Attributes | |
T * | raw |
Detailed Description
class Security::LockingPointer< T, UnLocker, Locker >
A shared pointer to a reference-counting Object with library-specific absorption, locking, and unlocking implementations. The API largely follows std::shared_ptr.
The constructor and the resetWithoutLocking() method import a raw Object pointer. Normally, reset() would lock(), but libraries like OpenSSL pre-lock objects before they are fed to LockingPointer, necessitating this resetWithoutLocking() customization hook.
Definition at line 48 of file LockingPointer.h.
Member Typedef Documentation
◆ SelfType
typedef Security::LockingPointer<T, UnLocker, Locker> Security::LockingPointer< T, UnLocker, Locker >::SelfType |
Definition at line 52 of file LockingPointer.h.
Constructor & Destructor Documentation
◆ LockingPointer() [1/5]
|
inlineconstexpr |
Definition at line 55 of file LockingPointer.h.
◆ LockingPointer() [2/5]
|
inlineconstexpr |
Definition at line 58 of file LockingPointer.h.
◆ LockingPointer() [3/5]
|
inlineexplicit |
Construct directly from a (possibly nil) raw pointer. If the supplied pointer is not nil, it is expected that its producer has already created one reference lock for the object pointed to, and our destructor will do the matching unlock.
Definition at line 66 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
◆ ~LockingPointer()
|
inline |
Definition at line 72 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::unlock().
◆ LockingPointer() [4/5]
|
inline |
Definition at line 75 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
◆ LockingPointer() [5/5]
|
inline |
Definition at line 83 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
Member Function Documentation
◆ get()
|
inline |
Definition at line 101 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
Referenced by Security::LockingPointer< T, UnLocker, Locker >::LockingPointer(), addAltNameWithSubjectCn(), Ssl::CertificateDb::addCertAndPrivateKey(), Ssl::appendCertToMemory(), Security::ErrorDetail::brokenCert(), buildCertificate(), ConnStateData::buildSslCertGenerationParams(), Ssl::certificateMatchesProperties(), Ssl::CertificatesCmp(), Ssl::chainCertificatesToSSLContext(), completeIssuers(), Ssl::CrtdMessage::composeRequest(), Ssl::configureSSL(), Ssl::configureSSLUsingPkeyAndCertFromMemory(), Ssl::createSSLContext(), generateFakeSslCertificate(), Ssl::generateUntrustedCert(), Ssl::InRamCertificateDbKey(), Security::ServerOptions::loadDhParams(), Acl::ServerCertificateCheck::match(), mimicAuthorityKeyId(), mimicExtensions(), Ssl::OnDiskCertificateDbKey(), Security::LockingPointer< T, UnLocker, Locker >::operator!=(), Security::LockingPointer< T, UnLocker, Locker >::operator=(), Security::LockingPointer< T, UnLocker, Locker >::operator==(), Security::ErrorDetail::peerCert(), replaceCommonName(), Security::LockingPointer< T, UnLocker, Locker >::resetAndLock(), Ssl::PeekingPeerConnector::serverCertificateVerified(), ssl_verify_cb(), Ssl::writeCertAndPrivateKeyToMemory(), Ssl::WriteX509Certificate(), Ssl::X509_get_signature(), x509Digest(), and x509Pubkeydigest().
◆ lock()
|
inlineprivate |
Definition at line 128 of file LockingPointer.h.
Referenced by Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
◆ operator bool()
|
inlineexplicit |
Definition at line 93 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ operator!()
|
inline |
Definition at line 92 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ operator!=()
|
inline |
Definition at line 95 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ operator*()
|
inline |
Definition at line 97 of file LockingPointer.h.
References Assure, and Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ operator->()
|
inline |
Definition at line 98 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ operator=() [1/2]
|
inline |
Definition at line 78 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
◆ operator=() [2/2]
|
inline |
Definition at line 86 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw, and Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
◆ operator==()
|
inline |
Definition at line 94 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ release()
|
inline |
Definition at line 120 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
◆ reset()
|
inline |
Definition at line 117 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::unlock().
Referenced by createSerial(), Security::KeyData::loadCertificates(), Ssl::readCertAndPrivateKeyFromMemory(), and ssl_verify_cb().
◆ resetAndLock()
|
inline |
Definition at line 109 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), Security::LockingPointer< T, UnLocker, Locker >::lock(), and Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
Referenced by Security::LockingPointer< T, UnLocker, Locker >::LockingPointer(), ConnStateData::buildSslCertGenerationParams(), completeIssuers(), Ssl::generateUntrustedCert(), Security::LockingPointer< T, UnLocker, Locker >::operator=(), Ssl::PeekingPeerConnector::serverCertificateVerified(), and ssl_verify_cb().
◆ resetWithoutLocking()
|
inline |
Definition at line 104 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw, and Security::LockingPointer< T, UnLocker, Locker >::unlock().
Referenced by ClientHttpRequest::ClientHttpRequest(), Security::LockingPointer< T, UnLocker, Locker >::LockingPointer(), Security::PeerConnector::fillChecklist(), Acl::ServerCertificateCheck::match(), Security::LockingPointer< T, UnLocker, Locker >::operator=(), Security::LockingPointer< T, UnLocker, Locker >::resetAndLock(), and Ssl::PeekingPeerConnector::serverCertificateVerified().
◆ unlock()
|
inlineprivate |
Become a nil pointer. Decrements any pointed-to Object's reference counter using UnLocker which ideally destroys the object when the counter reaches zero.
Definition at line 137 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
Referenced by Security::LockingPointer< T, UnLocker, Locker >::~LockingPointer(), Security::LockingPointer< T, UnLocker, Locker >::reset(), and Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
Member Data Documentation
◆ raw
|
private |
Normally, no other code will have this raw pointer.
However, OpenSSL does some strange and not always consistent things. OpenSSL library may keep its own internal raw pointers and manage their reference counts independently, or it may not. This varies between API functions, though it is usually documented.
This means the caller code needs to be carefully written to use the correct reset method and avoid the raw-pointer constructor unless OpenSSL function producing the pointer is clearly documented as incrementing a lock for it.
Definition at line 156 of file LockingPointer.h.
Referenced by Security::LockingPointer< T, UnLocker, Locker >::get(), Security::LockingPointer< T, UnLocker, Locker >::operator bool(), Security::LockingPointer< T, UnLocker, Locker >::operator!(), Security::LockingPointer< T, UnLocker, Locker >::operator!=(), Security::LockingPointer< T, UnLocker, Locker >::operator*(), Security::LockingPointer< T, UnLocker, Locker >::operator->(), Security::LockingPointer< T, UnLocker, Locker >::operator=(), Security::LockingPointer< T, UnLocker, Locker >::operator==(), Security::LockingPointer< T, UnLocker, Locker >::release(), Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking(), and Security::LockingPointer< T, UnLocker, Locker >::unlock().
The documentation for this class was generated from the following file:
- src/security/LockingPointer.h