
Go to the source code of this file.
Classes | |
class | CbdataParent |
class | generic_cbdata |
class | CallbackData |
an old-style void* callback parameter More... | |
Macros | |
#define | cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) |
#define | CBDATA_DECL_(type, methodSpecifiers) |
declaration-generator used internally by CBDATA_CLASS() and CBDATA_CHILD() More... | |
#define | CBDATA_CLASS(type) CBDATA_DECL_(type, noexcept) |
#define | CBDATA_CHILD(type) CBDATA_DECL_(type, override final) |
#define | CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN |
#define | CBDATA_NAMESPACED_CLASS_INIT(namespace, type) cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN |
#define | cbdataReference(var) (cbdataInternalLock(var), var) |
#define | cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0) |
Typedefs | |
typedef int | cbdata_type |
Functions | |
void | cbdataRegisterWithCacheManager (void) |
void * | cbdataInternalAlloc (cbdata_type type, const char *, int) |
void * | cbdataInternalFree (void *p, const char *, int) |
void | cbdataInternalLock (const void *p) |
void | cbdataInternalUnlock (const void *p) |
int | cbdataInternalReferenceDoneValid (void **p, void **tp) |
int | cbdataReferenceValid (const void *p) |
cbdata_type | cbdataInternalAddType (cbdata_type type, const char *label, int size) |
Variables | |
static const cbdata_type | CBDATA_UNKNOWN = 0 |
Macro Definition Documentation
◆ CBDATA_CHILD
#define CBDATA_CHILD | ( | type | ) | CBDATA_DECL_(type, override final) |
cbdata-enables a CbdataParent child class (including grandchildren) sets the class declaration section to "private" use this at the start of your class declaration for consistency sake
◆ CBDATA_CLASS
#define CBDATA_CLASS | ( | type | ) | CBDATA_DECL_(type, noexcept) |
cbdata-enables a stand-alone class that is not a CbdataParent child sets the class declaration section to "private" use this at the start of your class declaration for consistency sake
◆ CBDATA_CLASS_INIT
#define CBDATA_CLASS_INIT | ( | type | ) | cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN |
Creates a global instance pointer for the CBDATA memory allocator to allocate and free objects for the matching CBDATA_CLASS().
Place this in the appropriate .cc file for the class being registered.
May be placed inside an explicit namespace scope declaration, or CBDATA_NAMESPACED_CLASS_INIT() used instead.
◆ CBDATA_DECL_
#define CBDATA_DECL_ | ( | type, | |
methodSpecifiers | |||
) |
◆ CBDATA_NAMESPACED_CLASS_INIT
#define CBDATA_NAMESPACED_CLASS_INIT | ( | namespace, | |
type | |||
) | cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN |
Creates a global instance pointer for the CBDATA memory allocator to allocate and free objects for the matching CBDATA_CLASS().
Place this in the appropriate .cc file for the class being registered.
◆ cbdataReference
#define cbdataReference | ( | var | ) | (cbdataInternalLock(var), var) |
Creates a new reference to a cbdata entry. Used when you need to store a reference in another structure. The reference can later be verified for validity by cbdataReferenceValid().
- Deprecated:
- Prefer the use of CbcPointer<> smart pointer.
- Parameters
-
var The reference variable is a pointer to the entry, in all aspects identical to the original pointer. But semantically it is quite different. It is best if the reference is thought of and handled as a "void *".
◆ cbdataReferenceDone
#define cbdataReferenceDone | ( | var | ) | do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0) |
Removes a reference created by cbdataReference().
- Deprecated:
- Prefer the use of CbcPointer<> smart pointer.
- Parameters
-
var The reference variable. Will be automatically cleared to nullptr
◆ cbdataReferenceValidDone
#define cbdataReferenceValidDone | ( | var, | |
ptr | |||
) | cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) |
Typedef Documentation
◆ cbdata_type
typedef int cbdata_type |
cbdata types. Similar to the MEM_* types, but managed in cbdata.cc A big difference is that cbdata types are dynamically allocated.
Initially only UNKNOWN type is predefined. Other types are added at runtime by CBDATA_CLASS().
Function Documentation
◆ cbdataInternalAddType()
cbdata_type cbdataInternalAddType | ( | cbdata_type | type, |
const char * | label, | ||
int | size | ||
) |
Create a run-time registration for the class type with cbdata memory allocator.
- Note
- For internal CBDATA use only.
Definition at line 196 of file cbdata.cc.
References cbdata_types, and type.
◆ cbdataInternalAlloc()
void* cbdataInternalAlloc | ( | cbdata_type | type, |
const char * | , | ||
int | |||
) |
Allocates a new entry of a registered CBDATA type.
- Note
- For internal CBDATA use only.
Definition at line 223 of file cbdata.cc.
References MemAllocator::alloc(), assert, cbdata_htable, cbdata_index, cbdata_types, cbdataCount, cbdata::cookie, cbdata::Cookie, cbdata::data, debugs, dlinkAdd(), cbdata::locks, CBDataIndex::pool, cbdata::type, type, and cbdata::valid.
◆ cbdataInternalFree()
void* cbdataInternalFree | ( | void * | p, |
const char * | , | ||
int | |||
) |
Frees a entry allocated by cbdataInternalAlloc().
Once this has been called cbdataReferenceValid() and cbdataReferenceValidDone() will return false regardless of whether there are remaining cbdata references.
cbdataReferenceDone() must still be called for any active references to the cbdata entry. The cbdata entry will be freed only when the last reference is removed.
- Note
- For internal CBDATA use only.
Definition at line 301 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, cbdata::FromUserData(), NULL, and xfree.
◆ cbdataInternalLock()
void cbdataInternalLock | ( | const void * | p | ) |
Definition at line 331 of file cbdata.cc.
References assert, debugs, cbdata::FromUserData(), INT_MAX, and NULL.
Referenced by logfile_mod_daemon_open().
◆ cbdataInternalReferenceDoneValid()
int cbdataInternalReferenceDoneValid | ( | void ** | p, |
void ** | tp | ||
) |
Removes a reference created by cbdataReference() and checks it for validity. Meant to be used on the last dereference, usually to make a callback.
- Parameters
-
var The reference variable. Will be automatically cleared to nullptr ptr A temporary pointer to the referenced data (if valid).
Definition at line 418 of file cbdata.cc.
References cbdataInternalUnlock(), cbdataReferenceValid(), and NULL.
◆ cbdataInternalUnlock()
void cbdataInternalUnlock | ( | const void * | p | ) |
Definition at line 357 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, cbdata::FromUserData(), and NULL.
Referenced by cbdataInternalReferenceDoneValid(), and logfile_mod_daemon_close().
◆ cbdataReferenceValid()
int cbdataReferenceValid | ( | const void * | p | ) |
- Parameters
-
p A cbdata entry reference pointer.
- Return values
-
0 A reference is stale. The pointer refers to a entry already freed. true The reference is valid and active.
Definition at line 398 of file cbdata.cc.
References assert, debugs, cbdata::FromUserData(), and NULL.
Referenced by CbcPointer< Cbc >::CbcPointer(), ConnStateData::borrowPinnedConnection(), ACLChecklist::calcImplicitAnswer(), ACLChecklist::callerGone(), AsyncJob::callException(), AsyncJob::callStart(), StoreIOStateCb::canDial(), EventDialer::canDial(), CommCbFunPtrCallT< Dialer >::canFire(), cbdataInternalReferenceDoneValid(), EventScheduler::checkEvents(), helper_server::checkForTimedOutRequests(), clientGetMoreData(), clientSocketDetach(), clientSocketRecipient(), clientStreamDetach(), ACLFilledChecklist::conn(), diskHandleRead(), downloaderRecipient(), EventScheduler::dump(), esiBufferRecipient(), esiProcessStream(), esiStreamDetach(), esiStreamRead(), esiStreamStatus(), externalAclHandleReply(), ACLChecklist::fastCheck(), store_client::finishCallback(), ftpSendReply(), CbcPointer< Cbc >::get(), ClientHttpRequest::getConn(), Comm::Connection::getPeer(), DiskdIOStrategy::handle(), helperDispatch(), helperHandleRead(), helperReturnBuffer(), helperStatefulDispatch(), helperStatefulHandleRead(), ClientRequestContext::httpStateIsValid(), idnsCallbackOneWithAnswer(), ConnStateData::isOpen(), TunnelStateData::keepGoingAfterRead(), ClientHttpRequest::noteAdaptationAnswer(), CbcPointer< Cbc >::operator=(), peerCountMcastPeersAbort(), peerDigestCheck(), peerDigestFetchedEnough(), peerDigestHandleReply(), ACLChecklist::prepNonBlocking(), TunnelStateData::ReadClient(), TunnelStateData::ReadServer(), clientReplyContext::sendMoreData(), SslBumpEstablish(), tunnelStartShoveling(), CallbackData::valid(), PeerPoolMgr::validPeer(), TunnelStateData::writeClientDone(), TunnelStateData::WriteClientDone(), TunnelStateData::writeServerDone(), and TunnelStateData::WriteServerDone().
◆ cbdataRegisterWithCacheManager()
void cbdataRegisterWithCacheManager | ( | void | ) |
Create a run-time registration of CBDATA component with the Squid cachemgr
Definition at line 209 of file cbdata.cc.
References cbdataDump, and Mgr::RegisterAction().
Referenced by mainInitialize().
Variable Documentation
◆ CBDATA_UNKNOWN
|
static |