|
Squid Web Cache master
|
#include <LockingPointer.h>
Public Types | |
| typedef Security::LockingPointer< T, UnLocker, Locker > | SelfType |
| a helper label to simplify this objects API definitions below | |
Public Member Functions | |
| constexpr | LockingPointer () |
| constructs a nil smart pointer | |
| constexpr | LockingPointer (std::nullptr_t) |
| constructs a nil smart pointer from nullptr | |
| LockingPointer (T *t) | |
| ~LockingPointer () | |
| use the custom UnLocker to unlock any value still stored. | |
| 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. | |
| void | resetWithoutLocking (T *t) |
| Reset raw pointer - unlock any previous one and save new one without locking. | |
| void | resetAndLock (T *t) |
| void | reset () |
| Forget the raw pointer - unlock if any value was set. Become a nil pointer. | |
| T * | release () |
| Forget the raw pointer without unlocking it. Become a nil pointer. | |
Private Member Functions | |
| void | lock (T *t) |
| The lock() method increments Object's reference counter. | |
| void | unlock () |
Private Attributes | |
| T * | raw |
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 50 of file LockingPointer.h.
| typedef Security::LockingPointer<T, UnLocker, Locker> Security::LockingPointer< T, UnLocker, Locker >::SelfType |
Definition at line 54 of file LockingPointer.h.
|
inlineconstexpr |
Definition at line 57 of file LockingPointer.h.
|
inlineconstexpr |
Definition at line 60 of file LockingPointer.h.
|
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 68 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
|
inline |
Definition at line 74 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::unlock().
|
inline |
Definition at line 77 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
|
inline |
Definition at line 85 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
|
inline |
Definition at line 103 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().
|
inlineprivate |
Definition at line 130 of file LockingPointer.h.
Referenced by Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
|
inlineexplicit |
Definition at line 95 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 94 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 97 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 99 of file LockingPointer.h.
References Assure, and Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 100 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 80 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::resetAndLock().
|
inline |
Definition at line 88 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw, and Security::LockingPointer< T, UnLocker, Locker >::resetWithoutLocking().
|
inline |
Definition at line 96 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::get(), and Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 122 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::raw.
|
inline |
Definition at line 119 of file LockingPointer.h.
References Security::LockingPointer< T, UnLocker, Locker >::unlock().
Referenced by createSerial(), Security::KeyData::loadCertificates(), Ssl::readCertAndPrivateKeyFromMemory(), and ssl_verify_cb().
|
inline |
Definition at line 111 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().
|
inline |
Definition at line 106 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::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().
|
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 139 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().
|
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 158 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().