There are no logic changes here.
* Rename CBDATA_CLASS2() to CBDATA_CLASS()
* Remove cbdata*Dbg() duplicate interface for CBDATA.
Inline it with the CBDATA_CLASS() API
* update public:/private: class section handling in CBDATA_CLASS() and
place all uses at the top of class definition as with MEMPROXY_CLASS()
and typedef coding style.
- this highlights TunnelStateData API as previously broken in regards
to private members. Leave it public: for now with TODO on fixing.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
-#ifndef SQUID_LIST_H
-#define SQUID_LIST_H
+#ifndef SQUID_CBDATALIST_H
+#define SQUID_CBDATALIST_H
-/** \todo FUBAR: cbdata.h is over in src/ */
+/* XXX: layering violation. cbdata.h is over in src/ */
#include "../src/cbdata.h"
-/// \ingroup POD
template <class C>
class CbDataList
{
+ CBDATA_CLASS(CbDataList);
public:
- CbDataList (C const &);
+ CbDataList(C const &);
~CbDataList();
/// If element is already in the list, returns false.
CbDataList *next;
C element;
bool empty() const { return this == NULL; }
-
-private:
- CBDATA_CLASS2(CbDataList);
};
-/// \ingroup POD
template<class C>
class CbDataListContainer
{
CbDataList<C> *head;
};
-/// \ingroup POD
template<class C>
class CbDataListIterator
{
CbDataList<C> *next_entry;
};
-/* implementation follows */
-
/** \cond AUTODOCS_IGNORE */
template <class C>
cbdata_type CbDataList<C>::CBDATA_CbDataList = CBDATA_UNKNOWN;
return head == NULL;
}
-#endif /* SQUID_LIST_H */
+#endif /* SQUID_CBDATALIST_H */
AsyncCall \
AsyncCallEnter \
AsyncCallExit \
- CBDATA_CLASS2 \
+ CBDATA_CLASS \
CBDATA_CLASS_INIT \
CBDATA_NAMESPACED_CLASS_INIT \
MEMPROXY_CLASS \
// data from a BodyPipe
class BodySink: public BodyConsumer
{
+ CBDATA_CLASS(BodySink);
+
public:
BodySink(const BodyPipe::Pointer &bp): AsyncJob("BodySink"), body_pipe(bp) {}
virtual ~BodySink() { assert(!body_pipe); }
private:
BodyPipe::Pointer body_pipe; ///< the pipe we are consuming from
-
- CBDATA_CLASS2(BodySink);
};
CBDATA_CLASS_INIT(BodySink);
*/
class BodyPipe: public RefCountable
{
+ CBDATA_CLASS(BodyPipe);
+
public:
typedef RefCount<BodyPipe> Pointer;
typedef BodyProducer Producer;
bool mustAutoConsume; // consume when there is no consumer
bool abortedConsumption; ///< called BodyProducer::noteBodyConsumerAborted
bool isCheckedOut; // to keep track of checkout violations
-
- CBDATA_CLASS2(BodyPipe);
};
#endif /* SQUID_BODY_PIPE_H */
// a queue of Comm clients waiting for I/O quota controlled by delay pools
class CommQuotaQueue
{
+ CBDATA_CLASS(CommQuotaQueue);
+
public:
CommQuotaQueue(ClientInfo *info);
~CommQuotaQueue();
// TODO: optimize using a Ring- or List-based store?
typedef std::deque<int> Store;
Store fds; ///< descriptor queue
-
- CBDATA_CLASS2(CommQuotaQueue);
};
#endif /* USE_DELAY_POOLS */
class ClientRequestContext : public RefCountable
{
+ CBDATA_CLASS(ClientRequestContext);
public:
ClientRequestContext(ClientHttpRequest *);
#endif
ErrorState *error; ///< saved error page for centralized/delayed processing
bool readNextRequest; ///< whether Squid should read after error handling
-
-private:
- CBDATA_CLASS2(ClientRequestContext);
};
#endif /* SQUID_CLIENTREQUESTCONTEXT_H */
class AIODiskFile : public DiskFile
{
+ CBDATA_CLASS(AIODiskFile);
public:
RefCount<IORequestor> ioRequestor;
bool closed;
bool error_;
- CBDATA_CLASS2(AIODiskFile);
};
#endif /* USE_DISKIO_AIO */
class BlockingFile : public DiskFile
{
+ CBDATA_CLASS(BlockingFile);
public:
BlockingFile(char const *path);
void doClose();
void readDone(int fd, const char *buf, int len, int errflag);
void writeDone(int fd, int errflag, size_t len);
-
- CBDATA_CLASS2(BlockingFile);
};
#endif /* SQUID_BLOCKINGFILE_H */
*/
class DiskdFile : public DiskFile
{
+ CBDATA_CLASS(DiskdFile);
public:
DiskdFile(char const *path, DiskdIOStrategy *);
void ioAway();
void ioCompleted();
size_t inProgressIOs;
-
- CBDATA_CLASS2(DiskdFile);
};
#endif
class DiskThreadsDiskFile : public DiskFile
{
+ CBDATA_CLASS(DiskThreadsDiskFile);
public:
DiskThreadsDiskFile(char const *path, DiskThreadsIOStrategy *);
void readDone(int fd, const char *buf, int len, int errflag, RefCount<ReadRequest> request);
void writeDone(int fd, int errflag, size_t len, RefCount<WriteRequest> request);
-
- CBDATA_CLASS2(DiskThreadsDiskFile);
};
#include "DiskIO/ReadRequest.h"
template <class RT>
class IoResult
{
+ CBDATA_CLASS(IoResult);
public:
IoResult(RefCount<DiskThreadsDiskFile> aFile, RefCount<RT> aRequest) : file(aFile), request(aRequest) {}
RefCount<DiskThreadsDiskFile> file;
RefCount<RT> request;
-
-private:
- CBDATA_CLASS2(IoResult);
};
template <class RT>
class IpcIoFile: public DiskFile
{
+ CBDATA_CLASS(IpcIoFile);
public:
typedef RefCount<IpcIoFile> Pointer;
/// whether we are waiting for an event to handle still queued I/O requests
static bool DiskerHandleMoreRequestsScheduled;
-
- CBDATA_CLASS2(IpcIoFile);
};
/// keeps original I/O request parameters while disker is handling the request
class MmappedFile : public DiskFile
{
+ CBDATA_CLASS(MmappedFile);
public:
MmappedFile(char const *path);
bool error_;
void doClose();
-
- CBDATA_CLASS2(MmappedFile);
};
#endif /* SQUID_MMAPPEDFILE_H */
class ReadRequest : public RefCountable
{
+ CBDATA_CLASS(ReadRequest);
public:
typedef RefCount<ReadRequest> Pointer;
char *buf;
off_t offset;
size_t len;
-
-private:
- CBDATA_CLASS2(ReadRequest);
};
#endif /* SQUID_READREQUEST_H */
class WriteRequest : public RefCountable
{
+ CBDATA_CLASS(WriteRequest);
public:
typedef RefCount<WriteRequest> Pointer;
off_t offset;
size_t len;
FREE *free_func;
-
-private:
- CBDATA_CLASS2(WriteRequest);
};
#endif /* SQUID_WRITEREQUEST_H */
class FwdState : public RefCountable
{
+ CBDATA_CLASS(FwdState);
+
public:
typedef RefCount<FwdState> Pointer;
~FwdState();
/// possible pconn race states
typedef enum { raceImpossible, racePossible, raceHappened } PconnRace;
PconnRace pconnRace; ///< current pconn race state
-
- // NP: keep this last. It plays with private/public
- CBDATA_CLASS2(FwdState);
};
void getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn);
*/
class MemBuf
{
+ CBDATA_CLASS(MemBuf);
+
public:
MemBuf():
buf(NULL),
unsigned valid:1; /* to be used for debugging only! */
#endif
-
-private:
- CBDATA_CLASS2(MemBuf);
};
/** returns free() function to be used, _freezes_ the object! */
class PeerDigest
{
+ CBDATA_CLASS(PeerDigest);
public:
CachePeer *peer; /**< pointer back to peer structure, argh */
kb_t kbytes;
} sent, recv;
} stats;
-
-private:
- CBDATA_CLASS2(PeerDigest);
};
extern const Version CacheDigestVer;
/// Maintains an fixed-size "standby" PconnPool for a single CachePeer.
class PeerPoolMgr: public AsyncJob
{
+ CBDATA_CLASS(PeerPoolMgr);
+
public:
typedef CbcPointer<PeerPoolMgr> Pointer;
AsyncCall::Pointer securer; ///< whether we are securing a connection
AsyncCall::Pointer closer; ///< monitors conn while we are securing it
unsigned int addrUsed; ///< counter for cycling through peer addresses
-
- CBDATA_CLASS2(PeerPoolMgr);
};
#endif /* SQUID_PEERPOOLMGR_H */
class ps_state
{
+ CBDATA_CLASS(ps_state);
public:
ps_state();
peer_t hit_type;
ping_data ping;
ACLChecklist *acl_checklist;
-private:
- CBDATA_CLASS2(ps_state);
};
#endif /* SQUID_PEERSELECTSTATE_H */
class RemovalPolicy
{
+ CBDATA_CLASS(RemovalPolicy);
+
public:
const char *_type;
void *_data;
RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
-private:
- CBDATA_CLASS2(RemovalPolicy);
};
class RemovalPolicyWalker
{
+ CBDATA_CLASS(RemovalPolicyWalker);
+
public:
RemovalPolicy *_policy;
void *_data;
const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
void (*Done) (RemovalPolicyWalker * walker);
-private:
- CBDATA_CLASS2(RemovalPolicyWalker);
};
class RemovalPurgeWalker
{
+ CBDATA_CLASS(RemovalPurgeWalker);
+
public:
RemovalPolicy *_policy;
void *_data;
int scanned, max_scan, locked;
StoreEntry *(*Next) (RemovalPurgeWalker * walker);
void (*Done) (RemovalPurgeWalker * walker);
-private:
- CBDATA_CLASS2(RemovalPurgeWalker);
};
RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings);
class store_client
{
+ CBDATA_CLASS(store_client);
public:
store_client(StoreEntry *);
STCB *callback_handler;
void *callback_data;
} _callback;
-
-private:
- CBDATA_CLASS2(store_client);
};
void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *);
class StoreSearchHashIndex : public StoreSearch
{
+ CBDATA_CLASS(StoreSearchHashIndex);
public:
StoreSearchHashIndex(RefCount<StoreHashIndex> sd);
bool _done;
int bucket;
std::vector<StoreEntry *> entries;
-
- // keep this last. it plays with private/public
- CBDATA_CLASS2(StoreSearchHashIndex);
};
#endif /* SQUID_STOREHASHINDEX_H */
class ASState
{
+ CBDATA_CLASS(ASState);
+
public:
ASState();
~ASState();
int reqofs;
char reqbuf[AS_REQBUF_SZ];
bool dataRead;
-private:
- CBDATA_CLASS2(ASState);
};
CBDATA_CLASS_INIT(ASState);
/** \ingroup ACLAPI
ACLChecklist filled with specific data, representing Squid and transaction
- state for access checks along with some data-specific checking methods */
+ state for access checks along with some data-specific checking methods
+ */
class ACLFilledChecklist: public ACLChecklist
{
+ CBDATA_CLASS(ACLFilledChecklist);
+
public:
ACLFilledChecklist();
ACLFilledChecklist(const acl_access *, HttpRequest *, const char *ident);
ACLFilledChecklist(const ACLFilledChecklist &);
/// not implemented; will cause link failures if used
ACLFilledChecklist &operator=(const ACLFilledChecklist &);
-
- CBDATA_CLASS2(ACLFilledChecklist);
};
/// convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
/// unique properties: cbdata protection and optional rule actions.
class Tree: public OrNode
{
+ // XXX: We should use refcounting instead, but it requires making ACLs
+ // refcounted as well. Otherwise, async lookups will reach deleted ACLs.
+ CBDATA_CLASS(Tree);
+
public:
/// dumps <name, action, rule, new line> tuples
/// action.kind is mapped to a string using the supplied conversion table
/// if not empty, contains actions corresponding to InnerNode::nodes
typedef std::vector<allow_t> Actions;
Actions actions;
-
-private:
- // XXX: We should use refcounting instead, but it requires making ACLs
- // refcounted as well. Otherwise, async lookups will reach deleted ACLs.
- CBDATA_CLASS2(Tree);
};
} // namespace Acl
// checks adaptation_access rules to find a matching adaptation service
class AccessCheck: public virtual AsyncJob
{
+ CBDATA_CLASS(AccessCheck);
+
public:
typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
bool usedDynamicRules();
void check();
-
-private:
- CBDATA_CLASS2(AccessCheck);
};
} // namespace Adaptation
/// iterates services in ServiceGroup, starting adaptation launchers
class Iterator: public Initiate, public Initiator
{
+ CBDATA_CLASS(Iterator);
+
public:
Iterator(HttpMsg *virginHeader, HttpRequest *virginCause,
AccessLogEntry::Pointer &alp,
CbcPointer<Adaptation::Initiate> theLauncher; ///< current transaction launcher
int iterations; ///< number of steps initiated
bool adapted; ///< whether the virgin message has been replaced
-
- CBDATA_CLASS2(Iterator);
};
} // namespace Adaptation
class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction,
public BodyConsumer, public BodyProducer
{
+ CBDATA_CLASS(XactionRep);
+
public:
XactionRep(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, const Adaptation::ServicePointer &service);
virtual ~XactionRep();
virtual void noteBodyProductionEnded(RefCount<BodyPipe> bp);
virtual void noteBodyProducerAborted(RefCount<BodyPipe> bp);
- // Initiate API
+ // Initiate API
virtual void noteInitiatorAborted();
// AsyncJob API (via Initiate)
bool abProductionFinished; // whether adapter has finished producing ab
bool abProductionAtEnd; // whether adapter produced a complete ab
AccessLogEntry::Pointer al; ///< Master transaction AccessLogEntry
-
- CBDATA_CLASS2(XactionRep);
};
} // namespace Ecap
class ModXact: public Xaction, public BodyProducer, public BodyConsumer
{
+ CBDATA_CLASS(ModXact);
public:
ModXact(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, ServiceRep::Pointer &s);
} state;
AccessLogEntry::Pointer alMaster; ///< Master transaction AccessLogEntry
- CBDATA_CLASS2(ModXact);
};
// An Launcher that stores ModXact construction info and
// creates ModXact when needed
class ModXactLauncher: public Launcher
{
+ CBDATA_CLASS(ModXactLauncher);
+
public:
ModXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, Adaptation::ServicePointer s);
InOut virgin;
AccessLogEntry::Pointer al;
-
-private:
- CBDATA_CLASS2(ModXactLauncher);
};
} // namespace Icap
class OptXact: public Xaction
{
+ CBDATA_CLASS(OptXact);
public:
OptXact(ServiceRep::Pointer &aService);
virtual void finalizeLogInfo();
bool readAll; ///< read the entire OPTIONS response
-
- CBDATA_CLASS2(OptXact);
};
// An Launcher that stores OptXact construction info and
// creates OptXact when needed
class OptXactLauncher: public Launcher
{
+ CBDATA_CLASS(OptXactLauncher);
+
public:
OptXactLauncher(Adaptation::ServicePointer aService);
protected:
virtual Xaction *createXaction();
-
-private:
- CBDATA_CLASS2(OptXactLauncher);
};
} // namespace Icap
class ServiceRep : public RefCountable, public Adaptation::Service,
public Adaptation::Initiator
{
+ CBDATA_CLASS(ServiceRep);
public:
typedef RefCount<ServiceRep> Pointer;
mutable bool wasAnnouncedUp; // prevent sequential same-state announcements
bool isDetached;
- CBDATA_CLASS2(ServiceRep);
};
class ModXact;
private:
Comm::ConnOpener *cs;
- //CBDATA_CLASS2(Xaction);
};
} // namespace Icap
*/
class StateData
{
+ CBDATA_CLASS(StateData);
+
public:
StateData(const UserRequest::Pointer &r, AUTHCB *h, void *d) :
data(cbdataReference(d)),
void *data;
UserRequest::Pointer auth_user_request;
AUTHCB *handler;
-
-private:
- CBDATA_CLASS2(StateData);
};
} // namespace Auth
/**
\todo add unique call IDs
- \todo CBDATA_CLASS2 kids
+ \todo CBDATA_CLASS kids
\ingroup AsyncCallsAPI
*/
class AsyncCall: public RefCountable
}
void *
-#if USE_CBDATA_DEBUG
-cbdataInternalAllocDbg(cbdata_type type, const char *file, int line)
-#else
-cbdataInternalAlloc(cbdata_type type)
-#endif
+cbdataInternalAlloc(cbdata_type type, const char *file, int line)
{
cbdata *c;
void *p;
}
void *
-#if USE_CBDATA_DEBUG
-cbdataInternalFreeDbg(void *p, const char *file, int line)
-#else
-cbdataInternalFree(void *p)
-#endif
+cbdataInternalFree(void *p, const char *file, int line)
{
cbdata *c;
#if HASHED_CBDATA
*
\par
* To add new module specific data types to the allocator one uses the
- * macro CBDATA_CLASS2() in the class private section, and CBDATA_CLASS_INIT()
+ * macro CBDATA_CLASS() in the class private section, and CBDATA_CLASS_INIT()
* or CBDATA_NAMESPACED_CLASS_INIT() in the .cc file.
* This creates new(), delete() and toCbdata() methods
* definition in class scope. Any allocate calls must be made with
/// \ingroup CBDATAAPI
void cbdataRegisterWithCacheManager(void);
-#if USE_CBDATA_DEBUG
-void *cbdataInternalAllocDbg(cbdata_type type, const char *, int);
-void *cbdataInternalFreeDbg(void *p, const char *, int);
-void cbdataInternalLockDbg(const void *p, const char *, int);
-void cbdataInternalUnlockDbg(const void *p, const char *, int);
-int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int);
-#else
-
-/// \ingroup CBDATAAPI
-void *cbdataInternalAlloc(cbdata_type type);
-
-/// \ingroup CBDATAAPI
-void *cbdataInternalFree(void *p);
-
-/// \ingroup CBDATAAPI
-void cbdataInternalLock(const void *p);
-
-/// \ingroup CBDATAAPI
-void cbdataInternalUnlock(const void *p);
-
-/// \ingroup CBDATAAPI
-int cbdataInternalReferenceDoneValid(void **p, void **tp);
-
-#endif /* !CBDATA_DEBUG */
-
/**
- \ingroup CBDATAAPI
- *
- \param p A cbdata entry reference pointer.
- *
- \retval 0 A reference is stale. The pointer refers to a entry freed by cbdataFree().
- \retval true The reference is valid and active.
- */
-int cbdataReferenceValid(const void *p);
-
-/// \ingroup CBDATAAPI
-cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func);
-
-/* cbdata macros */
-#if USE_CBDATA_DEBUG
-#define cbdataAlloc(type) ((type *)cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__))
-#define cbdataFree(var) do {if (var) {cbdataInternalFreeDbg(var,__FILE__,__LINE__); var = NULL;}} while(0)
-#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__)
-#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__)
-#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValidDbg((void **)&(var), (ptr), __FILE__,__LINE__)
-#define CBDATA_CLASS2(type) \
- private: \
- static cbdata_type CBDATA_##type; \
- public: \
- void *operator new(size_t size) { \
- assert(size == sizeof(type)); \
- if (!CBDATA_##type) \
- CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL); \
- return cbdataInternalAllocDbg(CBDATA_##type,__FILE__,__LINE__); \
- } \
- void operator delete (void *address) { \
- if (address) cbdataInternalFreeDbg(address,__FILE__,__LINE__); \
- } \
- void *toCbdata() { return this; }
-#else /* USE_CBDATA_DEBUG */
-
-/**
- \ingroup CBDATAAPI
* Allocates a new entry of a registered CBDATA type.
+ * \deprecated use CBDATA_CLASS() instead
*/
-#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type))
+void *cbdataInternalAlloc(cbdata_type type, const char *, int);
+/// \deprecated use CBDATA_CLASS() instead
+#define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type,__FILE__,__LINE__))
/**
- \ingroup CBDATAAPI
- \par
- * Frees a entry allocated by cbdataAlloc().
+ * Frees a entry allocated by cbdataAlloc().
*
\note If there are active references to the entry then the entry
* will be freed with the last reference is removed. However,
* cbdataReferenceValid() will return false for those references.
+ * \deprecated use CBDATA_CLASS() instead
*/
-#define cbdataFree(var) do {if (var) {cbdataInternalFree(var); var = NULL;}} while(0)
+void *cbdataInternalFree(void *p, const char *, int);
+/// \deprecated use CBDATA_CLASS() instead
+#define cbdataFree(var) do {if (var) {cbdataInternalFree(var,__FILE__,__LINE__); var = NULL;}} while(0)
+
+#if USE_CBDATA_DEBUG
+void cbdataInternalLockDbg(const void *p, const char *, int);
+#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__)
+
+void cbdataInternalUnlockDbg(const void *p, const char *, int);
+#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__)
+
+int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int);
+#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValidDbg((void **)&(var), (ptr), __FILE__,__LINE__)
+
+#else
+void cbdataInternalLock(const void *p);
+void cbdataInternalUnlock(const void *p);
/**
- \ingroup CBDATAAPI
* Removes a reference created by cbdataReference() and checks
* it for validity. Meant to be used on the last dereference,
* usually to make a callback.
\param var The reference variable. Will be automatically cleared to NULL.
\param ptr A temporary pointer to the referenced data (if valid).
*/
+int cbdataInternalReferenceDoneValid(void **p, void **tp);
#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr))
+#endif /* !CBDATA_DEBUG */
+
/**
- * \ingroup CBDATAAPI
+ * \param p A cbdata entry reference pointer.
*
- * This needs to be defined LAST in the class definition. It plays with private/public states in C++.
+ * \retval 0 A reference is stale. The pointer refers to a entry freed by cbdataFree().
+ * \retval true The reference is valid and active.
*/
-#define CBDATA_CLASS2(type) \
- private: \
- static cbdata_type CBDATA_##type; \
+int cbdataReferenceValid(const void *p);
+
+/// \ingroup CBDATAAPI
+cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func);
+
+/**
+ * This needs to be defined FIRST in the class definition.
+ * It plays with private/public states in C++.
+ */
+#define CBDATA_CLASS(type) \
public: \
void *operator new(size_t size) { \
assert(size == sizeof(type)); \
if (!CBDATA_##type) \
CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL); \
- return (type *)cbdataInternalAlloc(CBDATA_##type); \
+ return (type *)cbdataInternalAlloc(CBDATA_##type,__FILE__,__LINE__); \
} \
void operator delete (void *address) { \
- if (address) cbdataInternalFree(address);\
+ if (address) cbdataInternalFree(address,__FILE__,__LINE__);\
} \
- void *toCbdata() { return this; }
-#endif /* !CBDATA_DEBUG */
+ void *toCbdata() { return this; } \
+ private: \
+ static cbdata_type CBDATA_##type;
/**
- \ingroup CBDATAAPI
\par
* Creates a new reference to a cbdata entry. Used when you need to
* store a reference in another structure. The reference can later
#define CBDATA_NAMESPACED_CLASS_INIT(namespace, type) cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN
/**
- \ingroup CBDATAAPI
* Macro that defines a new cbdata datatype. Similar to a variable
* or struct definition. Scope is always local to the file/block
* where it is defined and all calls to cbdataAlloc() for this type
* must be within the same scope as the CBDATA_TYPE declaration.
* Allocated entries may be referenced or freed anywhere with no
* restrictions on scope.
+ * \deprecated Use CBDATA_CLASS() instead
*/
#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = CBDATA_UNKNOWN
#define CBDATA_INIT_TYPE_FREECB(type, free_func) do { if (!CBDATA_##type) CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), free_func); } while (false)
/**
- \ingroup CBDATAAPI
- *
* Initializes the cbdatatype. Must be called prior to the first use of cbdataAlloc() for the type.
*
\par
* Alternative to CBDATA_INIT_TYPE_FREECB()
*
\param type Type being initialized
+ *
+ * \deprecated Use CBDATA_CLASS() instead
*/
#define CBDATA_INIT_TYPE(type) CBDATA_INIT_TYPE_FREECB(type, NULL)
*/
class generic_cbdata
{
+ CBDATA_CLASS(generic_cbdata);
+
public:
generic_cbdata(void * aData) : data(aData) {}
\todo CODE: make this a private field.
*/
void *data; /* the wrapped data */
-
-private:
- CBDATA_CLASS2(generic_cbdata);
};
#endif /* SQUID_CBDATA_H */
*/
class ClientSocketContext : public RefCountable
{
+ CBDATA_CLASS(ClientSocketContext);
public:
typedef RefCount<ClientSocketContext> Pointer;
bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */
bool connRegistered_;
-
- CBDATA_CLASS2(ClientSocketContext);
};
class ConnectionDetail;
class clientReplyContext : public RefCountable, public StoreClient
{
+ CBDATA_CLASS(clientReplyContext);
public:
static STCB CacheHit;
StoreEntry *old_entry;
store_client *old_sc; /* ... for entry to be validated */
bool deleting;
-
- CBDATA_CLASS2(clientReplyContext);
};
#endif /* SQUID_CLIENTSIDEREPLY_H */
public BodyConsumer // to receive reply bodies in request satisf. mode
#endif
{
+ CBDATA_CLASS(ClientHttpRequest);
public:
ClientHttpRequest(ConnStateData *csd);
bool request_satisfaction_mode;
int64_t request_satisfaction_offset;
#endif
-
-private:
- CBDATA_CLASS2(ClientHttpRequest);
};
/* client http based routines */
/// FTP client functionality shared among FTP Gateway and Relay clients.
class Client: public ::Client
{
+ CBDATA_CLASS(Client);
+
public:
explicit Client(FwdState *fwdState);
virtual ~Client();
/// XXX: An old hack for FTP servers like ftp.netscape.com that may not
/// respond to PASV. Use faster connect timeout instead of read timeout.
bool shortenReadTimeout;
-
- CBDATA_CLASS2(Client);
};
} // namespace Ftp
/// converts one or more FTP responses into the final HTTP response.
class Gateway : public Ftp::Client
{
+ CBDATA_CLASS(Gateway);
+
public:
Gateway(FwdState *);
virtual ~Gateway();
virtual bool mayReadVirginReplyBody() const;
// BodyConsumer for HTTP: consume request body.
virtual void handleRequestBodyProducerAborted();
-
- CBDATA_CLASS2(Gateway);
};
} // namespace Ftp
/// and then relaying FTP replies back to our FTP server.
class Relay: public Ftp::Client
{
+ CBDATA_CLASS(Relay);
+
public:
explicit Relay(FwdState *const fwdState);
virtual ~Relay();
char *lastReply; ///< last line of reply: reply status plus message
int replyCode; ///< the reply status
} savedReply; ///< set and delayed while we are tracking using PWD
-
- CBDATA_CLASS2(Relay);
};
} // namespace Ftp
*/
class ConnOpener : public AsyncJob
{
+ CBDATA_CLASS(ConnOpener);
+
protected:
virtual void start();
virtual void swanSong();
/// [that we can cancel], but it will probably become one eventually.
bool sleep_;
} calls_;
-
- CBDATA_CLASS2(ConnOpener);
};
}; // namespace Comm
*/
class TcpAcceptor : public AsyncJob
{
+ CBDATA_CLASS(TcpAcceptor);
+
public:
typedef CbcPointer<Comm::TcpAcceptor> Pointer;
Comm::Flag oldAccept(Comm::ConnectionPointer &details);
void setListen();
void handleClosure(const CommCloseCbParams &io);
-
- CBDATA_CLASS2(TcpAcceptor);
};
} // namespace Comm
/// \ingroup ErrorPageAPI
class ErrorState
{
+ CBDATA_CLASS(ErrorState);
+
public:
ErrorState(err_type type, Http::StatusCode, HttpRequest * request);
ErrorState(); // not implemented.
/// type-specific detail about the transaction error;
/// overwrites xerrno; overwritten by detail, if any.
int detailCode;
-private:
- CBDATA_CLASS2(ErrorState);
};
/**
class ESIContext : public esiTreeParent, public ESIParserClient
{
+ CBDATA_CLASS(ESIContext);
public:
typedef RefCount<ESIContext> Pointer;
virtual void parserDefault (const char *s, int len);
virtual void parserComment (const char *s);
bool processing;
-
- CBDATA_CLASS2(ESIContext);
};
#endif /* SQUID_ESICONTEXT_H */
class ESIStreamContext : public RefCountable
{
+ CBDATA_CLASS(ESIStreamContext);
public:
typedef RefCount<ESIStreamContext> Pointer;
ESIIncludePtr include;
ESISegment::Pointer localbuffer;
ESISegment::Pointer buffer;
-
-private:
- CBDATA_CLASS2(ESIStreamContext);
};
class ESIInclude : public ESIElement
namespace Rock
{
-/// \ingroup Rock
class ReadRequest: public ::ReadRequest
{
+ CBDATA_CLASS(ReadRequest);
+
public:
ReadRequest(const ::ReadRequest &base, const IoState::Pointer &anSio);
IoState::Pointer sio;
-
-private:
- CBDATA_CLASS2(ReadRequest);
};
-/// \ingroup Rock
class WriteRequest: public ::WriteRequest
{
+ CBDATA_CLASS(WriteRequest);
+
public:
WriteRequest(const ::WriteRequest &base, const IoState::Pointer &anSio);
IoState::Pointer sio;
/// whether this is the last request for the entry
bool eof;
-
-private:
- CBDATA_CLASS2(WriteRequest);
};
} // namespace Rock
/// manages store rebuild process: loading meta information from db on disk
class Rebuild: public AsyncJob
{
+ CBDATA_CLASS(Rebuild);
+
public:
Rebuild(SwapDir *dir);
~Rebuild();
StoreRebuildData counts;
static void Steps(void *data);
-
- CBDATA_CLASS2(Rebuild);
};
} // namespace Rock
namespace Ufs
{
-/// \ingroup UFS
class RebuildState : public RefCountable
{
+ CBDATA_CLASS(RebuildState);
+
public:
static EVH RebuildStep;
StoreRebuildData counts;
private:
- CBDATA_CLASS2(RebuildState);
void rebuildFromDirectory();
void rebuildFromSwapLog();
void rebuildStep();
namespace Ufs
{
-/// \ingroup UFS
class StoreSearchUFS : public StoreSearch
{
+ CBDATA_CLASS(StoreSearchUFS);
+
public:
StoreSearchUFS(RefCount<UFSSwapDir> sd);
virtual ~StoreSearchUFS();
RemovalPolicyWalker *walker;
private:
- CBDATA_CLASS2(StoreSearchUFS);
/// \bug (callback) should be hidden behind a proper human readable name
void (callback)(void *cbdata);
void *cbdata;
{
namespace Ufs
{
-/// \ingroup UFS
+
class UFSStoreState : public StoreIOState, public IORequestor
{
+ CBDATA_CLASS(UFSStoreState);
+
public:
UFSStoreState(SwapDir * SD, StoreEntry * anEntry, STIOCB * callback_, void *callback_data_);
~UFSStoreState();
void openDone();
void freePending();
void doWrite();
- CBDATA_CLASS2(UFSStoreState);
};
} //namespace Ufs
*/
class GopherStateData
{
+ CBDATA_CLASS(GopherStateData);
+
public:
GopherStateData(FwdState *aFwd) :
entry(aFwd->entry),
Comm::ConnectionPointer serverConn;
FwdState::Pointer fwd;
char replybuf[BUFSIZ];
-
-private:
- CBDATA_CLASS2(GopherStateData);
};
CBDATA_CLASS_INIT(GopherStateData);
class helper
{
+ CBDATA_CLASS(helper);
+
public:
inline helper(const char *name) :
cmdline(NULL),
int queue_size;
int avg_svc_time;
} stats;
-
-private:
- CBDATA_CLASS2(helper);
};
class statefulhelper : public helper
{
+ CBDATA_CLASS(statefulhelper);
+
public:
- inline statefulhelper(const char *name) : helper(name), datapool(NULL), IsAvailable(NULL), OnEmptyQueue(NULL) {};
- inline ~statefulhelper() {};
+ inline statefulhelper(const char *name) : helper(name), datapool(NULL), IsAvailable(NULL), OnEmptyQueue(NULL) {}
+ inline ~statefulhelper() {}
public:
MemAllocator *datapool;
HLPSAVAIL *IsAvailable;
HLPSONEQ *OnEmptyQueue;
-
-private:
- CBDATA_CLASS2(statefulhelper);
};
/**
class helper_server : public HelperServerBase
{
+ CBDATA_CLASS(helper_server);
+
public:
MemBuf *wqueue;
MemBuf *writebuf;
helper *parent;
Helper::Request **requests;
-
-private:
- CBDATA_CLASS2(helper_server);
};
class helper_stateful_server : public HelperServerBase
{
+ CBDATA_CLASS(helper_stateful_server);
+
public:
/* MemBuf wqueue; */
/* MemBuf writebuf; */
Helper::Request *request;
void *data; /* State data used by the calling routines */
-
-private:
- CBDATA_CLASS2(helper_stateful_server);
};
/* helper.c */
class HttpStateData : public Client
{
+ CBDATA_CLASS(HttpStateData);
public:
HttpStateData(FwdState *);
bool peerSupportsConnectionPinning() const;
ChunkedCodingParser *httpChunkDecoder;
-private:
- CBDATA_CLASS2(HttpStateData);
};
int httpCachable(const HttpRequestMethod&);
class IdentStateData
{
+public:
+ hash_link hash; /* must be first */
+private:
+ CBDATA_CLASS(IdentStateData);
+
public:
/* AsyncJob API emulated */
void deleteThis(const char *aReason);
/// notify all waiting IdentClient callbacks
void notify(const char *result);
- hash_link hash; /* must be first */
Comm::ConnectionPointer conn;
MemBuf queryMsg; ///< the lookup message sent to IDENT server
IdentClient *clients;
char buf[IDENT_BUFSIZE];
-
-private:
- CBDATA_CLASS2(IdentStateData);
};
CBDATA_CLASS_INIT(IdentStateData);
/// Coordinates shared activities of Strands (Squid processes or threads)
class Coordinator: public Port
{
+ CBDATA_CLASS(Coordinator);
+
public:
static Coordinator* Instance();
private:
Coordinator(const Coordinator&); // not implemented
Coordinator& operator =(const Coordinator&); // not implemented
-
- CBDATA_CLASS2(Coordinator);
};
} // namespace Ipc
*/
class Forwarder: public AsyncJob
{
+ CBDATA_CLASS(Forwarder);
+
public:
Forwarder(Request::Pointer aRequest, double aTimeout);
virtual ~Forwarder();
static RequestsMap TheRequestsMap; ///< pending Coordinator requests
static unsigned int LastRequestId; ///< last requestId used
-
- CBDATA_CLASS2(Forwarder);
};
} // namespace Ipc
/// aggregating individual strand responses and dumping the result if needed
class Inquirer: public AsyncJob
{
+ CBDATA_CLASS(Inquirer);
+
public:
Inquirer(Request::Pointer aRequest, const Ipc::StrandCoords& coords, double aTimeout);
virtual ~Inquirer();
static RequestsMap TheRequestsMap; ///< pending strand requests
static unsigned int LastRequestId; ///< last requestId used
-
- CBDATA_CLASS2(Inquirer);
};
} // namespace Ipc
/// Receives coordination messages on behalf of its process or thread
class Strand: public Port
{
+ CBDATA_CLASS(Strand);
+
public:
Strand();
private:
Strand(const Strand&); // not implemented
Strand& operator =(const Strand&); // not implemented
-
- CBDATA_CLASS2(Strand);
};
}
/// attempts to send an IPC message a few times, with a timeout
class UdsSender: public UdsOp
{
+ CBDATA_CLASS(UdsSender);
+
public:
UdsSender(const String& pathAddr, const TypedMsgHdr& aMessage);
private:
UdsSender(const UdsSender&); // not implemented
UdsSender& operator= (const UdsSender&); // not implemented
-
- CBDATA_CLASS2(UdsSender);
};
void SendMessage(const String& toAddress, const TypedMsgHdr& message);
*/
class TcpLogger : public AsyncJob
{
+ CBDATA_CLASS(TcpLogger);
+
public:
typedef CbcPointer<TcpLogger> Pointer;
uint64_t connectFailures; ///< number of sequential connection failures
uint64_t drops; ///< number of records dropped during the current outage
-
- CBDATA_CLASS2(TcpLogger);
};
} // namespace Log
/// Comm-writes it using parent StoreToCommWriter.
class ActionWriter: public StoreToCommWriter
{
+ CBDATA_CLASS(ActionWriter);
+
public:
ActionWriter(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn);
private:
Action::Pointer action; ///< action that fills the entry
-
- CBDATA_CLASS2(ActionWriter);
};
} // namespace Mgr
/// provides Coordinator with a local cache manager response
class Filler: public StoreToCommWriter
{
+ CBDATA_CLASS(Filler);
+
public:
Filler(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn, unsigned int aRequestId);
private:
Action::Pointer action; ///< action that will run() and sendResponse()
unsigned int requestId; ///< the ID of the Request we are responding to
-
- CBDATA_CLASS2(Filler);
};
} // namespace Mgr
*/
class Forwarder: public Ipc::Forwarder
{
+ CBDATA_CLASS(Forwarder);
+
public:
Forwarder(const Comm::ConnectionPointer &aConn, const ActionParams &aParams, HttpRequest* aRequest,
StoreEntry* anEntry);
StoreEntry* entry; ///< Store entry expecting the response
Comm::ConnectionPointer conn; ///< HTTP client connection descriptor
AsyncCall::Pointer closer; ///< comm_close handler for the HTTP connection
-
- CBDATA_CLASS2(Forwarder);
};
} // namespace Mgr
/// aggregating individual strand responses and dumping the result if needed
class Inquirer: public Ipc::Inquirer
{
+ CBDATA_CLASS(Inquirer);
+
public:
Inquirer(Action::Pointer anAction, const Request &aCause,
const Ipc::StrandCoords &coords);
AsyncCall::Pointer writer; ///< comm_write callback
AsyncCall::Pointer closer; ///< comm_close handler
-
- CBDATA_CLASS2(Inquirer);
};
} // namespace Mgr
/// for the given StoreEntry and client FD
class StoreToCommWriter: public AsyncJob
{
+ CBDATA_CLASS(StoreToCommWriter);
+
public:
StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry *anEntry);
virtual ~StoreToCommWriter();
AsyncCall::Pointer closer; ///< comm_close handler
char buffer[HTTP_REQBUF_SZ]; ///< action results; Store fills, Comm writes
-
- CBDATA_CLASS2(StoreToCommWriter);
};
} // namespace Mgr
class PconnPool;
class PeerPoolMgr;
-/* for CBDATA_CLASS2() macros */
#include "cbdata.h"
-/* for hash_link */
#include "hash.h"
/* for IOCB */
#include "comm.h"
*/
class IdleConnList
{
+ CBDATA_CLASS(IdleConnList);
+
public:
IdleConnList(const char *key, PconnPool *parent);
~IdleConnList();
PconnPool *parent_;
char fakeReadBuf_[4096]; // TODO: kill magic number.
-
- CBDATA_CLASS2(IdleConnList);
};
#include "ip/forward.h"
class RedirectStateData
{
+ CBDATA_CLASS(RedirectStateData);
+
public:
explicit RedirectStateData(const char *url);
~RedirectStateData();
SBuf orig_url;
HLPCB *handler;
-
-private:
- CBDATA_CLASS2(RedirectStateData);
};
static HLPCB redirectHandleReply;
/// Manages a control connection from an FTP client.
class Server: public ConnStateData
{
+ CBDATA_CLASS(Server);
+
public:
explicit Server(const MasterXaction::Pointer &xact);
virtual ~Server();
AsyncCall::Pointer listener; ///< set when we are passively listening
AsyncCall::Pointer connector; ///< set when we are actively connecting
AsyncCall::Pointer reader; ///< set when we are reading FTP data
-
- CBDATA_CLASS2(Server);
};
} // namespace Ftp
/// Manages a connection from an HTTP client.
class Server: public ConnStateData
{
+ CBDATA_CLASS(Server);
+
public:
Server(const MasterXaction::Pointer &xact, const bool beHttpsServer);
virtual ~Server() {}
/// temporary hack to avoid creating a true HttpsServer class
const bool isHttpsServer;
-
- CBDATA_CLASS2(Server);
};
} // namespace Http
*/
class Forwarder: public Ipc::Forwarder
{
+ CBDATA_CLASS(Forwarder);
+
public:
Forwarder(const Pdu& aPdu, const Session& aSession, int aFd,
const Ip::Address& anAddress);
private:
int fd; ///< client connection descriptor
AsyncCall::Pointer closer; ///< comm_close handler for the connection
-
- CBDATA_CLASS2(Forwarder);
};
void SendResponse(unsigned int requestId, const Pdu& pdu);
/// aggregates strand responses and send back the result to client
class Inquirer: public Ipc::Inquirer
{
+ CBDATA_CLASS(Inquirer);
+
public:
Inquirer(const Request& aRequest, const Ipc::StrandCoords& coords);
AsyncCall::Pointer writer; ///< comm_write callback
AsyncCall::Pointer closer; ///< comm_close handler
-
- CBDATA_CLASS2(Inquirer);
};
} // namespace Snmp
*/
class PeerConnector: virtual public AsyncJob
{
+ CBDATA_CLASS(PeerConnector);
+
public:
/// Callback dialier API to allow PeerConnector to set the answer.
class CbDialer
time_t negotiationTimeout; ///< the ssl connection timeout to use
time_t startTime; ///< when the peer connector negotiation started
bool splice; ///< Whether we are going to splice or not
-
- CBDATA_CLASS2(PeerConnector);
};
std::ostream &operator <<(std::ostream &os, const Ssl::PeerConnectorAnswer &a);
{
/**
- \ingroup ServerProtocolSSLAPI
* Maintains bump-server-first related information.
*/
class ServerBump
{
+ CBDATA_CLASS(ServerBump);
+
public:
explicit ServerBump(HttpRequest *fakeRequest, StoreEntry *e = NULL, Ssl::BumpMode mode = Ssl::bumpServerFirst);
~ServerBump();
private:
store_client *sc; ///< dummy client to prevent entry trimming
-
- CBDATA_CLASS2(ServerBump);
};
} // namespace Ssl
HelperCache = NULL;
}
-struct submitData {
+class submitData
+{
+ CBDATA_CLASS(submitData);
+
+public:
std::string query;
Ssl::CertValidationHelper::CVHCB *callback;
void *data;
SSL *ssl;
- CBDATA_CLASS2(submitData);
};
CBDATA_CLASS_INIT(submitData);
class StatObjectsState
{
+ CBDATA_CLASS(StatObjectsState);
public:
StoreEntry *sentry;
STOBJFLT *filter;
StoreSearchPointer theSearch;
-
-private:
- CBDATA_CLASS2(StatObjectsState);
};
/* LOCALS */
*/
class TunnelStateData
{
+ CBDATA_CLASS(TunnelStateData);
public:
TunnelStateData();
void connectedToPeer(Ssl::PeerConnectorAnswer &answer);
#endif
- CBDATA_CLASS2(TunnelStateData);
+public:
bool keepGoingAfterRead(size_t len, Comm::Flag errcode, int xerrno, Connection &from, Connection &to);
void copy(size_t len, Connection &from, Connection &to, IOCB *);
void handleConnectResponse(const size_t chunkSize);
class UrnState : public StoreClient
{
+ CBDATA_CLASS(UrnState);
public:
void created (StoreEntry *newEntry);
private:
char *urlres;
-
- CBDATA_CLASS2(UrnState);
};
typedef struct {
class WhoisState
{
+ CBDATA_CLASS(WhoisState);
+
public:
void readReply(const Comm::ConnectionPointer &, char *aBuffer, size_t aBufferLength, Comm::Flag flag, int xerrno);
void setReplyToOK(StoreEntry *sentry);
FwdState::Pointer fwd;
char buf[BUFSIZ+1]; /* readReply adds terminating NULL */
bool dataWritten;
-
-private:
- CBDATA_CLASS2(WhoisState);
};
CBDATA_CLASS_INIT(WhoisState);