cbdata.cc File Reference
#include "squid.h"
#include "cbdata.h"
#include "Generic.h"
#include "mem/Pool.h"
#include "mgr/Registration.h"
#include "Store.h"
#include <climits>
#include <map>
Include dependency graph for cbdata.cc:

Go to the source code of this file.

Classes

class  cbdata
 
struct  CBDataIndex
 

Macros

#define OFFSET_OF(TYPE, MEMBER)   ((size_t) &(((TYPE) *)0)->(MEMBER))
 

Functions

static void cbdataInternalInitType (cbdata_type type, const char *name, int size)
 
cbdata_type cbdataInternalAddType (cbdata_type type, const char *name, int size)
 
void cbdataRegisterWithCacheManager (void)
 
void * cbdataInternalAlloc (cbdata_type type, const char *file, int line)
 
void cbdataRealFree (cbdata *c, const char *file, const int line)
 
void * cbdataInternalFree (void *p, const char *file, int line)
 
void cbdataInternalLock (const void *p)
 
void cbdataInternalUnlock (const void *p)
 
int cbdataReferenceValid (const void *p)
 
int cbdataInternalReferenceDoneValid (void **pp, void **tp)
 
static void cbdataDump (StoreEntry *sentry)
 

Variables

static int cbdataCount = 0
 
static OBJH cbdataDump
 
struct CBDataIndexcbdata_index = NULL
 
int cbdata_types = 0
 
static std::map< const void
*, cbdata * > 
cbdata_htable
 

Macro Definition Documentation

#define OFFSET_OF (   TYPE,
  MEMBER 
)    ((size_t) &(((TYPE) *)0)->(MEMBER))

Definition at line 49 of file cbdata.cc.

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.

Note
For internal CBDATA use only.

Definition at line 197 of file cbdata.cc.

References cbdataInternalInitType(), and type.

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 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 *  ,
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 298 of file cbdata.cc.

static void cbdataInternalInitType ( cbdata_type  type,
const char *  name,
int  size 
)
static

Definition at line 175 of file cbdata.cc.

References assert, cbdata_index, memPoolCreate, NULL, CBDataIndex::pool, type, xmalloc, and xrealloc().

Referenced by cbdataInternalAddType().

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);
Parameters
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)
void cbdataRealFree ( cbdata c,
const char *  file,
const int  line 
)

Definition at line 263 of file cbdata.cc.

References cbdataCount, cbdata::data, debugs, dlinkDelete(), and p.

Referenced by cbdataInternalFree(), and cbdataInternalUnlock().

int cbdataReferenceValid ( const void *  p)
Parameters
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.

Referenced by mainInitialize().

Variable Documentation

std::map<const void *, cbdata *> cbdata_htable
static

Definition at line 152 of file cbdata.cc.

int cbdata_types = 0

Definition at line 149 of file cbdata.cc.

Referenced by cbdataDump().

int cbdataCount = 0
static

Definition at line 29 of file cbdata.cc.

Referenced by cbdataDump(), cbdataInternalAlloc(), and cbdataRealFree().

OBJH cbdataDump
static

Definition at line 139 of file cbdata.cc.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors