cbdata.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


class  CbdataParent
class  generic_cbdata
class  CallbackData
 an old-style void* callback parameter More...


#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 = NULL;}} while(0)


typedef int cbdata_type


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)


static const cbdata_type CBDATA_UNKNOWN = 0

Macro Definition Documentation


#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

Definition at line 307 of file cbdata.h.


#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

Definition at line 302 of file cbdata.h.


#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.

Definition at line 318 of file cbdata.h.

Referenced by ClientRequestContext::ClientRequestContext(), CallbackData::operator=(), PeerDigest::PeerDigest(), STUB_RETVAL(), and TunnelStateData::usePinned().


#define CBDATA_DECL_ (   type,
public: \
void *operator new(size_t size) { \
assert(size == sizeof(type)); \
if (!CBDATA_##type) CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type)); \
return (type *)cbdataInternalAlloc(CBDATA_##type,__FILE__,__LINE__); \
} \
void operator delete (void *address) { \
if (address) cbdataInternalFree(address,__FILE__,__LINE__); \
} \
void *toCbdata() methodSpecifiers { return this; } \
private: \
static cbdata_type CBDATA_##type;
int type
Definition: errorpage.cc:152
int cbdata_type
Definition: cbdata.h:195
void * cbdataInternalFree(void *p, const char *, int)
Definition: cbdata.cc:298
cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size)
Definition: cbdata.cc:197
void * cbdataInternalAlloc(cbdata_type type, const char *, int)
Definition: cbdata.cc:224
int size
Definition: ModDevPoll.cc:77

Definition at line 276 of file cbdata.h.


#define CBDATA_NAMESPACED_CLASS_INIT (   namespace,
)    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.

Definition at line 326 of file cbdata.h.

◆ 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().

Prefer the use of CbcPointer<> smart pointer.
varThe 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 *".

Definition at line 341 of file cbdata.h.

Referenced by aioOpen(), aioRead(), aioStat(), aioUnlink(), aioWrite(), ConnStateData::buildSslCertGenerationParams(), carpInit(), CbcPointer< Adaptation::Initiate >::CbcPointer(), ACLChecklist::changeAcl(), Ident::ClientAdd(), clientStreamDetach(), clientStreamInit(), clientStreamInsertHead(), ACLFilledChecklist::conn(), constructHelperQuery(), store_client::copy(), Comm::Connection::copyDetails(), ESIAssign::ESIAssign(), ESIInclude::ESIInclude(), esiLiteral::esiLiteral(), esiWhen::esiWhen(), EventDialer::EventDialer(), ACLChecklist::fastCheck(), file_read(), file_write(), fqdncache_nbgethostbyaddr(), helperOpenServers(), helperStatefulOpenServers(), HttpStateData::HttpStateData(), idnsCachedLookup(), idnsStartQuery(), esiLiteral::makeUsable(), ESIInclude::makeUsable(), ESIAssign::makeUsable(), esiWhen::makeUsable(), ACLChecklist::nonBlockingCheck(), CbcPointer< Adaptation::Initiate >::operator=(), CallbackData::operator=(), peerCountMcastPeersStart(), PeerDigest::PeerDigest(), peerDigestCreate(), peerSourceHashInit(), peerUserHashInit(), ConnStateData::pinConnection(), Rock::IoState::read_(), Fs::Ufs::UFSStoreState::read_(), StoreEntry::registerAbort(), DiskdIOStrategy::send(), ESIContext::send(), ClientHttpRequest::setConn(), Comm::Connection::setPeer(), ExternalACLLookup::Start(), and StoreIOStateCb::StoreIOStateCb().

◆ cbdataReferenceDone

#define cbdataReferenceDone (   var)    do {if (var) {cbdataInternalUnlock(var); var = NULL;}} while(0)

Removes a reference created by cbdataReference().

Prefer the use of CbcPointer<> smart pointer.
varThe reference variable. Will be automatically cleared to NULL.

Definition at line 350 of file cbdata.h.

Referenced by store_client::callback(), Rock::IoState::callBack(), carpInit(), ACLChecklist::changeAcl(), CbcPointer< Adaptation::Initiate >::clear(), clientStreamDetach(), ACLChecklist::completeNonBlocking(), diskHandleRead(), ClientHttpRequest::doCallouts(), ACLChecklist::fastCheck(), ESIAssign::finish(), DiskdIOStrategy::handle(), ClientRequestContext::httpStateIsValid(), CallbackData::operator=(), peerCountMcastPeersDone(), peerDigestDestroy(), peerDigestPDFinish(), peerSourceHashInit(), peerUserHashInit(), ACLChecklist::prepNonBlocking(), DiskdIOStrategy::SEND(), ESIContext::send(), ClientHttpRequest::setConn(), Comm::Connection::setPeer(), storeUnregister(), ConnStateData::unpinConnection(), StoreEntry::unregisterAbort(), Fs::Ufs::UFSStoreState::_queued_read::~_queued_read(), ACLFilledChecklist::~ACLFilledChecklist(), CachePeer::~CachePeer(), CallbackData::~CallbackData(), ClientHttpRequest::~ClientHttpRequest(), clientReplyContext::~clientReplyContext(), ClientRequestContext::~ClientRequestContext(), CommCommonCbParams::~CommCommonCbParams(), Comm::Connection::~Connection(), ESIInclude::~ESIInclude(), esiLiteral::~esiLiteral(), esiWhen::~esiWhen(), ev_entry::~ev_entry(), EventDialer::~EventDialer(), external_acl_data::~external_acl_data(), externalAclState::~externalAclState(), helper_server::~helper_server(), helper_stateful_server::~helper_stateful_server(), HttpStateData::~HttpStateData(), idns_query::~idns_query(), Rock::IoState::~IoState(), PeerPoolMgr::~PeerPoolMgr(), Auth::QueueNode::~QueueNode(), Helper::Request::~Request(), Auth::StateData::~StateData(), StoreIOState::~StoreIOState(), and StoreIOStateCb::~StoreIOStateCb().

◆ cbdataReferenceValidDone

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().

Definition at line 195 of file cbdata.h.

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.

For internal CBDATA use only.

Definition at line 197 of file cbdata.cc.

References cbdataInternalInitType(), and type.

Referenced by cbdataInternalFree().

◆ cbdataInternalAlloc()

void* cbdataInternalAlloc ( cbdata_type  type,
const char *  ,

Allocates a new entry of a registered CBDATA type.

For internal CBDATA use only.

Definition at line 224 of file cbdata.cc.

References MemAllocator::alloc(), assert, cbdata_index, cbdataCount, cbdata::cookie, cbdata::Cookie, cbdata::data, debugs, dlinkAdd(), cbdata::locks, p, CBDataIndex::pool, cbdata::type, type, and cbdata::valid.

◆ cbdataInternalFree()

void* cbdataInternalFree ( void *  p,
const char *  ,

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.

For internal CBDATA use only.

Definition at line 298 of file cbdata.cc.

References assert, CBDATA_UNKNOWN, cbdataInternalAddType(), cbdataInternalLock(), cbdataInternalReferenceDoneValid(), cbdataInternalUnlock(), cbdataRealFree(), cbdataReferenceValid(), cbdata::check(), debugs, cbdata::locks, NULL, p, STUB, STUB_RETVAL(), cbdata::valid, and xfree.

◆ cbdataInternalLock()

void cbdataInternalLock ( const void *  p)

Definition at line 333 of file cbdata.cc.

References assert, cbdata::check(), debugs, INT_MAX, cbdata::locks, 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.

void *cbdata;
if (cbdataReferenceValidDone(reference, &cbdata)) != NULL)
callback(..., cbdata);
varThe reference variable. Will be automatically cleared to NULL.
ptrA temporary pointer to the referenced data (if valid).

Definition at line 438 of file cbdata.cc.

References cbdataInternalUnlock(), cbdataReferenceValid(), data, NULL, p, storeAppendPrintf(), and type.

Referenced by cbdataInternalFree().

◆ cbdataInternalUnlock()

void cbdataInternalUnlock ( const void *  p)

◆ cbdataReferenceValid()

int cbdataReferenceValid ( const void *  p)
pA cbdata entry reference pointer.
Return values
0A reference is stale. The pointer refers to a entry already freed.
trueThe reference is valid and active.

Definition at line 412 of file cbdata.cc.

References assert, cbdata::check(), debugs, cbdata::locks, NULL, and cbdata::valid.

Referenced by StoreEntry::abort(), Ftp::Relay::abort(), ConnStateData::borrowPinnedConnection(), ACLChecklist::calcImplicitAnswer(), store_client::callback(), ACLChecklist::callerGone(), AsyncJob::callException(), AsyncJob::callStart(), EventDialer::canDial(), StoreIOStateCb::canDial(), CommCbFunPtrCallT< Dialer >::canFire(), CbcPointer< Adaptation::Initiate >::CbcPointer(), cbdataInternalFree(), cbdataInternalReferenceDoneValid(), EventScheduler::checkEvents(), helper_server::checkForTimedOutRequests(), clientAclChecklistFill(), clientGetMoreData(), clientSocketDetach(), clientSocketRecipient(), clientStreamDetach(), ACLFilledChecklist::conn(), DeferredReadManager::delayRead(), diskHandleRead(), downloaderRecipient(), EventScheduler::dump(), esiBufferRecipient(), esiProcessStream(), esiStreamDetach(), esiStreamRead(), esiStreamStatus(), externalAclHandleReply(), ACLChecklist::fastCheck(), ftpSendReply(), CbcPointer< Adaptation::Initiate >::get(), ClientHttpRequest::getConn(), Comm::Connection::getPeer(), DiskdIOStrategy::handle(), helperDispatch(), helperHandleRead(), helperReturnBuffer(), helperStatefulDispatch(), helperStatefulHandleRead(), ClientRequestContext::httpStateIsValid(), idnsCallbackOneWithAnswer(), ConnStateData::isOpen(), TunnelStateData::keepGoingAfterRead(), ClientHttpRequest::noteAdaptationAnswer(), Ident::IdentStateData::notify(), CbcPointer< Adaptation::Initiate >::operator=(), peerCountMcastPeersDone(), 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 210 of file cbdata.cc.

References Mgr::RegisterAction().

Referenced by mainInitialize().

Variable Documentation


const cbdata_type CBDATA_UNKNOWN = 0

Definition at line 196 of file cbdata.h.

Referenced by cbdataInternalFree(), and DiskThreadsDiskFile::writeDone().






Web Site Translations