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.

#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;
#define assert(EX)
Definition: assert.h:17
int type
Definition: errorpage.cc:79
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.

#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< Cbc >::CbcPointer(), 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< Cbc >::operator=(), CbcPointer< Adaptation::Initiate >::operator=(), CallbackData::operator=(), parse_peer(), peerCountMcastPeersStart(), peerDigestCreate(), peerDigestInit(), 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().

#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< Cbc >::clear(), clientStreamDetach(), ACLChecklist::completeNonBlocking(), diskHandleRead(), ClientHttpRequest::doCallouts(), ACLChecklist::fastCheck(), ESIAssign::finish(), DiskdIOStrategy::handle(), helperServerFree(), helperStatefulServerFree(), ClientRequestContext::httpStateIsValid(), CallbackData::operator=(), peerCountMcastPeersDone(), peerDigestPDFinish(), peerNoteDigestGone(), 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(), 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().

Typedef Documentation

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

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.

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, type, cbdata::type, and cbdata::valid.

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, cbdataRealFree(), cbdata::check(), debugs, cbdata::locks, NULL, cbdata::valid, and xfree.

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

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(), NULL, and p.

void cbdataInternalUnlock ( const void *  p)
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(), ACLChecklist::calcImplicitAnswer(), store_client::callback(), ACLChecklist::callerGone(), AsyncJob::callException(), AsyncJob::callStart(), EventDialer::canDial(), StoreIOStateCb::canDial(), CommCbFunPtrCallT< Dialer >::canFire(), CbcPointer< Cbc >::CbcPointer(), cbdataInternalReferenceDoneValid(), EventScheduler::checkEvents(), helper_server::checkForTimedOutRequests(), clientAclChecklistCreate(), clientGetMoreData(), clientSocketDetach(), clientSocketRecipient(), clientStreamDetach(), ACLFilledChecklist::conn(), diskHandleRead(), downloaderRecipient(), EventScheduler::dump(), esiBufferRecipient(), esiProcessStream(), esiStreamDetach(), esiStreamRead(), esiStreamStatus(), externalAclHandleReply(), ACLChecklist::fastCheck(), 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=(), peerCountMcastPeersDone(), peerDigestCheck(), peerDigestFetchedEnough(), peerDigestHandleReply(), ACLChecklist::prepNonBlocking(), TunnelStateData::ReadClient(), TunnelStateData::ReadConnectResponseDone(), TunnelStateData::ReadServer(), helper_server::requestTimeout(), clientReplyContext::sendMoreData(), SslBumpEstablish(), tunnelStartShoveling(), CallbackData::valid(), ConnStateData::validatePinnedConnection(), PeerPoolMgr::validPeer(), TunnelStateData::WriteClientDone(), TunnelStateData::writeClientDone(), TunnelStateData::WriteServerDone(), and TunnelStateData::writeServerDone().

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.






Web Site Translations