From: Amos Jeffries Date: Sun, 2 Nov 2014 00:10:01 +0000 (-0700) Subject: Cleanup: Simplify CBDATA API and rename CBDATA_CLASS X-Git-Tag: merge-candidate-3-v1~514 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c2f68b760b3a732efc6aaacad2472758558bdd2;p=thirdparty%2Fsquid.git Cleanup: Simplify CBDATA API and rename CBDATA_CLASS 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. --- diff --git a/include/CbDataList.h b/include/CbDataList.h index 67964f7014..62fb7d97a2 100644 --- a/include/CbDataList.h +++ b/include/CbDataList.h @@ -6,19 +6,19 @@ * 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 CbDataList { + CBDATA_CLASS(CbDataList); public: - CbDataList (C const &); + CbDataList(C const &); ~CbDataList(); /// If element is already in the list, returns false. @@ -32,12 +32,8 @@ public: CbDataList *next; C element; bool empty() const { return this == NULL; } - -private: - CBDATA_CLASS2(CbDataList); }; -/// \ingroup POD template class CbDataListContainer { @@ -52,7 +48,6 @@ public: CbDataList *head; }; -/// \ingroup POD template class CbDataListIterator { @@ -72,8 +67,6 @@ private: CbDataList *next_entry; }; -/* implementation follows */ - /** \cond AUTODOCS_IGNORE */ template cbdata_type CbDataList::CBDATA_CbDataList = CBDATA_UNKNOWN; @@ -203,4 +196,4 @@ CbDataListContainer::empty() const return head == NULL; } -#endif /* SQUID_LIST_H */ +#endif /* SQUID_CBDATALIST_H */ diff --git a/squid3.dox b/squid3.dox index f90955c55d..3b173e4346 100644 --- a/squid3.dox +++ b/squid3.dox @@ -1310,7 +1310,7 @@ EXPAND_AS_DEFINED = AsyncCallWrapper \ AsyncCall \ AsyncCallEnter \ AsyncCallExit \ - CBDATA_CLASS2 \ + CBDATA_CLASS \ CBDATA_CLASS_INIT \ CBDATA_NAMESPACED_CLASS_INIT \ MEMPROXY_CLASS \ diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index 8a73a6ce56..f90ef99bac 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -17,6 +17,8 @@ CBDATA_CLASS_INIT(BodyPipe); // 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); } @@ -35,8 +37,6 @@ public: private: BodyPipe::Pointer body_pipe; ///< the pipe we are consuming from - - CBDATA_CLASS2(BodySink); }; CBDATA_CLASS_INIT(BodySink); diff --git a/src/BodyPipe.h b/src/BodyPipe.h index 7ee8d38ab0..83f7bcfc35 100644 --- a/src/BodyPipe.h +++ b/src/BodyPipe.h @@ -89,6 +89,8 @@ private: */ class BodyPipe: public RefCountable { + CBDATA_CLASS(BodyPipe); + public: typedef RefCount Pointer; typedef BodyProducer Producer; @@ -164,8 +166,6 @@ private: 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 */ diff --git a/src/ClientInfo.h b/src/ClientInfo.h index 7fb081bdd1..4c356e48a3 100644 --- a/src/ClientInfo.h +++ b/src/ClientInfo.h @@ -88,6 +88,8 @@ public: // a queue of Comm clients waiting for I/O quota controlled by delay pools class CommQuotaQueue { + CBDATA_CLASS(CommQuotaQueue); + public: CommQuotaQueue(ClientInfo *info); ~CommQuotaQueue(); @@ -108,8 +110,6 @@ private: // TODO: optimize using a Ring- or List-based store? typedef std::deque Store; Store fds; ///< descriptor queue - - CBDATA_CLASS2(CommQuotaQueue); }; #endif /* USE_DELAY_POOLS */ diff --git a/src/ClientRequestContext.h b/src/ClientRequestContext.h index 91a6129427..709a8ef923 100644 --- a/src/ClientRequestContext.h +++ b/src/ClientRequestContext.h @@ -25,6 +25,7 @@ class ErrorState; class ClientRequestContext : public RefCountable { + CBDATA_CLASS(ClientRequestContext); public: ClientRequestContext(ClientHttpRequest *); @@ -89,9 +90,6 @@ public: #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 */ diff --git a/src/DiskIO/AIO/AIODiskFile.h b/src/DiskIO/AIO/AIODiskFile.h index ba357a1fc5..7b613cca5a 100644 --- a/src/DiskIO/AIO/AIODiskFile.h +++ b/src/DiskIO/AIO/AIODiskFile.h @@ -20,6 +20,7 @@ class AIODiskIOStrategy; class AIODiskFile : public DiskFile { + CBDATA_CLASS(AIODiskFile); public: @@ -53,7 +54,6 @@ private: RefCount ioRequestor; bool closed; bool error_; - CBDATA_CLASS2(AIODiskFile); }; #endif /* USE_DISKIO_AIO */ diff --git a/src/DiskIO/Blocking/BlockingFile.h b/src/DiskIO/Blocking/BlockingFile.h index 02707fbc2d..75f2fee3b1 100644 --- a/src/DiskIO/Blocking/BlockingFile.h +++ b/src/DiskIO/Blocking/BlockingFile.h @@ -17,6 +17,7 @@ class BlockingFile : public DiskFile { + CBDATA_CLASS(BlockingFile); public: BlockingFile(char const *path); @@ -46,8 +47,6 @@ private: 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 */ diff --git a/src/DiskIO/DiskDaemon/DiskdFile.h b/src/DiskIO/DiskDaemon/DiskdFile.h index 3055c7aef1..6d82f856ae 100644 --- a/src/DiskIO/DiskDaemon/DiskdFile.h +++ b/src/DiskIO/DiskDaemon/DiskdFile.h @@ -23,6 +23,7 @@ struct diomsg; */ class DiskdFile : public DiskFile { + CBDATA_CLASS(DiskdFile); public: DiskdFile(char const *path, DiskdIOStrategy *); @@ -58,8 +59,6 @@ private: void ioAway(); void ioCompleted(); size_t inProgressIOs; - - CBDATA_CLASS2(DiskdFile); }; #endif diff --git a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h index 59da4a5ecf..7906776e0c 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h +++ b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.h @@ -16,6 +16,7 @@ class DiskThreadsDiskFile : public DiskFile { + CBDATA_CLASS(DiskThreadsDiskFile); public: DiskThreadsDiskFile(char const *path, DiskThreadsIOStrategy *); @@ -60,8 +61,6 @@ private: void readDone(int fd, const char *buf, int len, int errflag, RefCount request); void writeDone(int fd, int errflag, size_t len, RefCount request); - - CBDATA_CLASS2(DiskThreadsDiskFile); }; #include "DiskIO/ReadRequest.h" @@ -69,15 +68,13 @@ private: template class IoResult { + CBDATA_CLASS(IoResult); public: IoResult(RefCount aFile, RefCount aRequest) : file(aFile), request(aRequest) {} RefCount file; RefCount request; - -private: - CBDATA_CLASS2(IoResult); }; template diff --git a/src/DiskIO/IpcIo/IpcIoFile.h b/src/DiskIO/IpcIo/IpcIoFile.h index dded3873ee..0bddd239e7 100644 --- a/src/DiskIO/IpcIo/IpcIoFile.h +++ b/src/DiskIO/IpcIo/IpcIoFile.h @@ -57,6 +57,7 @@ class IpcIoPendingRequest; class IpcIoFile: public DiskFile { + CBDATA_CLASS(IpcIoFile); public: typedef RefCount Pointer; @@ -143,8 +144,6 @@ private: /// 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 diff --git a/src/DiskIO/Mmapped/MmappedFile.h b/src/DiskIO/Mmapped/MmappedFile.h index dc14f52cde..b473bf8a86 100644 --- a/src/DiskIO/Mmapped/MmappedFile.h +++ b/src/DiskIO/Mmapped/MmappedFile.h @@ -15,6 +15,7 @@ class MmappedFile : public DiskFile { + CBDATA_CLASS(MmappedFile); public: MmappedFile(char const *path); @@ -45,8 +46,6 @@ private: bool error_; void doClose(); - - CBDATA_CLASS2(MmappedFile); }; #endif /* SQUID_MMAPPEDFILE_H */ diff --git a/src/DiskIO/ReadRequest.h b/src/DiskIO/ReadRequest.h index c337666976..bbd8e3d67b 100644 --- a/src/DiskIO/ReadRequest.h +++ b/src/DiskIO/ReadRequest.h @@ -14,6 +14,7 @@ class ReadRequest : public RefCountable { + CBDATA_CLASS(ReadRequest); public: typedef RefCount Pointer; @@ -23,9 +24,6 @@ public: char *buf; off_t offset; size_t len; - -private: - CBDATA_CLASS2(ReadRequest); }; #endif /* SQUID_READREQUEST_H */ diff --git a/src/DiskIO/WriteRequest.h b/src/DiskIO/WriteRequest.h index bb56478d03..3ae9365468 100644 --- a/src/DiskIO/WriteRequest.h +++ b/src/DiskIO/WriteRequest.h @@ -14,6 +14,7 @@ class WriteRequest : public RefCountable { + CBDATA_CLASS(WriteRequest); public: typedef RefCount Pointer; @@ -24,9 +25,6 @@ public: off_t offset; size_t len; FREE *free_func; - -private: - CBDATA_CLASS2(WriteRequest); }; #endif /* SQUID_WRITEREQUEST_H */ diff --git a/src/FwdState.h b/src/FwdState.h index e8ca030c45..b7bead3ffd 100644 --- a/src/FwdState.h +++ b/src/FwdState.h @@ -57,6 +57,8 @@ class HelperReply; class FwdState : public RefCountable { + CBDATA_CLASS(FwdState); + public: typedef RefCount Pointer; ~FwdState(); @@ -153,9 +155,6 @@ private: /// 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); diff --git a/src/MemBuf.h b/src/MemBuf.h index b652ad2549..337c53b4a3 100644 --- a/src/MemBuf.h +++ b/src/MemBuf.h @@ -18,6 +18,8 @@ */ class MemBuf { + CBDATA_CLASS(MemBuf); + public: MemBuf(): buf(NULL), @@ -155,9 +157,6 @@ public: unsigned valid:1; /* to be used for debugging only! */ #endif - -private: - CBDATA_CLASS2(MemBuf); }; /** returns free() function to be used, _freezes_ the object! */ diff --git a/src/PeerDigest.h b/src/PeerDigest.h index 9fabde9cc9..6e2de11a33 100644 --- a/src/PeerDigest.h +++ b/src/PeerDigest.h @@ -70,6 +70,7 @@ public: class PeerDigest { + CBDATA_CLASS(PeerDigest); public: CachePeer *peer; /**< pointer back to peer structure, argh */ @@ -104,9 +105,6 @@ public: kb_t kbytes; } sent, recv; } stats; - -private: - CBDATA_CLASS2(PeerDigest); }; extern const Version CacheDigestVer; diff --git a/src/PeerPoolMgr.h b/src/PeerPoolMgr.h index 323b587d56..6fa33a7e32 100644 --- a/src/PeerPoolMgr.h +++ b/src/PeerPoolMgr.h @@ -26,6 +26,8 @@ class PeerConnectorAnswer; /// Maintains an fixed-size "standby" PconnPool for a single CachePeer. class PeerPoolMgr: public AsyncJob { + CBDATA_CLASS(PeerPoolMgr); + public: typedef CbcPointer Pointer; @@ -70,8 +72,6 @@ private: 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 */ diff --git a/src/PeerSelectState.h b/src/PeerSelectState.h index 78ec00a74e..d18b3e83a8 100644 --- a/src/PeerSelectState.h +++ b/src/PeerSelectState.h @@ -45,6 +45,7 @@ public: class ps_state { + CBDATA_CLASS(ps_state); public: ps_state(); @@ -86,8 +87,6 @@ public: peer_t hit_type; ping_data ping; ACLChecklist *acl_checklist; -private: - CBDATA_CLASS2(ps_state); }; #endif /* SQUID_PEERSELECTSTATE_H */ diff --git a/src/RemovalPolicy.h b/src/RemovalPolicy.h index 8c40002ebf..d4d35ce076 100644 --- a/src/RemovalPolicy.h +++ b/src/RemovalPolicy.h @@ -35,6 +35,8 @@ public: class RemovalPolicy { + CBDATA_CLASS(RemovalPolicy); + public: const char *_type; void *_data; @@ -46,31 +48,29 @@ public: 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); diff --git a/src/StoreClient.h b/src/StoreClient.h index 7fd869adcd..28c37d7d1e 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -34,6 +34,7 @@ public: class store_client { + CBDATA_CLASS(store_client); public: store_client(StoreEntry *); @@ -97,9 +98,6 @@ public: STCB *callback_handler; void *callback_data; } _callback; - -private: - CBDATA_CLASS2(store_client); }; void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *); diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index 1ad74a6a3d..5d0a646afe 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -70,6 +70,7 @@ class StoreHashIndexEntry : public StoreEntry class StoreSearchHashIndex : public StoreSearch { + CBDATA_CLASS(StoreSearchHashIndex); public: StoreSearchHashIndex(RefCount sd); @@ -95,9 +96,6 @@ private: bool _done; int bucket; std::vector entries; - - // keep this last. it plays with private/public - CBDATA_CLASS2(StoreSearchHashIndex); }; #endif /* SQUID_STOREHASHINDEX_H */ diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index b8a79bd706..10cc067cee 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -67,6 +67,8 @@ struct as_info { class ASState { + CBDATA_CLASS(ASState); + public: ASState(); ~ASState(); @@ -79,8 +81,6 @@ public: int reqofs; char reqbuf[AS_REQBUF_SZ]; bool dataRead; -private: - CBDATA_CLASS2(ASState); }; CBDATA_CLASS_INIT(ASState); diff --git a/src/acl/FilledChecklist.h b/src/acl/FilledChecklist.h index 3b40a12350..fe5be22711 100644 --- a/src/acl/FilledChecklist.h +++ b/src/acl/FilledChecklist.h @@ -28,9 +28,12 @@ class HttpReply; /** \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); @@ -97,8 +100,6 @@ private: 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 diff --git a/src/acl/Tree.h b/src/acl/Tree.h index 5b7a6b39f3..339b1acc18 100644 --- a/src/acl/Tree.h +++ b/src/acl/Tree.h @@ -19,6 +19,10 @@ namespace Acl /// 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 tuples /// action.kind is mapped to a string using the supplied conversion table @@ -41,11 +45,6 @@ protected: /// if not empty, contains actions corresponding to InnerNode::nodes typedef std::vector 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 diff --git a/src/adaptation/AccessCheck.h b/src/adaptation/AccessCheck.h index 5f3104808b..15735b2eb5 100644 --- a/src/adaptation/AccessCheck.h +++ b/src/adaptation/AccessCheck.h @@ -29,6 +29,8 @@ class AccessRule; // 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); @@ -67,9 +69,6 @@ protected: bool usedDynamicRules(); void check(); - -private: - CBDATA_CLASS2(AccessCheck); }; } // namespace Adaptation diff --git a/src/adaptation/Iterator.h b/src/adaptation/Iterator.h index 60e085ecc9..11c49e8607 100644 --- a/src/adaptation/Iterator.h +++ b/src/adaptation/Iterator.h @@ -32,6 +32,8 @@ 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, @@ -71,8 +73,6 @@ protected: CbcPointer theLauncher; ///< current transaction launcher int iterations; ///< number of steps initiated bool adapted; ///< whether the virgin message has been replaced - - CBDATA_CLASS2(Iterator); }; } // namespace Adaptation diff --git a/src/adaptation/ecap/XactionRep.h b/src/adaptation/ecap/XactionRep.h index 4a74d78cbb..5601636f17 100644 --- a/src/adaptation/ecap/XactionRep.h +++ b/src/adaptation/ecap/XactionRep.h @@ -32,6 +32,8 @@ namespace Ecap 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(); @@ -69,7 +71,7 @@ public: virtual void noteBodyProductionEnded(RefCount bp); virtual void noteBodyProducerAborted(RefCount bp); - // Initiate API + // Initiate API virtual void noteInitiatorAborted(); // AsyncJob API (via Initiate) @@ -121,8 +123,6 @@ private: 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 diff --git a/src/adaptation/icap/ModXact.h b/src/adaptation/icap/ModXact.h index b47c16050c..78d18db621 100644 --- a/src/adaptation/icap/ModXact.h +++ b/src/adaptation/icap/ModXact.h @@ -108,6 +108,7 @@ private: class ModXact: public Xaction, public BodyProducer, public BodyConsumer { + CBDATA_CLASS(ModXact); public: ModXact(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, ServiceRep::Pointer &s); @@ -316,13 +317,14 @@ private: } 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); @@ -337,9 +339,6 @@ protected: InOut virgin; AccessLogEntry::Pointer al; - -private: - CBDATA_CLASS2(ModXactLauncher); }; } // namespace Icap diff --git a/src/adaptation/icap/OptXact.h b/src/adaptation/icap/OptXact.h index d16dd0bd15..e6b0f3b5a9 100644 --- a/src/adaptation/icap/OptXact.h +++ b/src/adaptation/icap/OptXact.h @@ -24,6 +24,7 @@ namespace Icap class OptXact: public Xaction { + CBDATA_CLASS(OptXact); public: OptXact(ServiceRep::Pointer &aService); @@ -46,22 +47,19 @@ private: 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 diff --git a/src/adaptation/icap/ServiceRep.h b/src/adaptation/icap/ServiceRep.h index bb2723238d..27c4824da8 100644 --- a/src/adaptation/icap/ServiceRep.h +++ b/src/adaptation/icap/ServiceRep.h @@ -59,6 +59,7 @@ class OptXact; class ServiceRep : public RefCountable, public Adaptation::Service, public Adaptation::Initiator { + CBDATA_CLASS(ServiceRep); public: typedef RefCount Pointer; @@ -182,7 +183,6 @@ private: mutable bool wasAnnouncedUp; // prevent sequential same-state announcements bool isDetached; - CBDATA_CLASS2(ServiceRep); }; class ModXact; diff --git a/src/adaptation/icap/Xaction.h b/src/adaptation/icap/Xaction.h index 756484d8de..f9c051358e 100644 --- a/src/adaptation/icap/Xaction.h +++ b/src/adaptation/icap/Xaction.h @@ -164,7 +164,6 @@ protected: private: Comm::ConnOpener *cs; - //CBDATA_CLASS2(Xaction); }; } // namespace Icap diff --git a/src/auth/State.h b/src/auth/State.h index f33c38b0f8..6be0965ef4 100644 --- a/src/auth/State.h +++ b/src/auth/State.h @@ -22,6 +22,8 @@ namespace Auth */ class StateData { + CBDATA_CLASS(StateData); + public: StateData(const UserRequest::Pointer &r, AUTHCB *h, void *d) : data(cbdataReference(d)), @@ -36,9 +38,6 @@ public: void *data; UserRequest::Pointer auth_user_request; AUTHCB *handler; - -private: - CBDATA_CLASS2(StateData); }; } // namespace Auth diff --git a/src/base/AsyncCall.h b/src/base/AsyncCall.h index 145f81242d..062109da6f 100644 --- a/src/base/AsyncCall.h +++ b/src/base/AsyncCall.h @@ -38,7 +38,7 @@ class AsyncCallQueue; /** \todo add unique call IDs - \todo CBDATA_CLASS2 kids + \todo CBDATA_CLASS kids \ingroup AsyncCallsAPI */ class AsyncCall: public RefCountable diff --git a/src/cbdata.cc b/src/cbdata.cc index 382a68fec8..48882fb00e 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -259,11 +259,7 @@ cbdataRegisterWithCacheManager(void) } 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; @@ -302,11 +298,7 @@ cbdataInternalAlloc(cbdata_type type) } 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 diff --git a/src/cbdata.h b/src/cbdata.h index af6bafb30f..c4fa4f2dbb 100644 --- a/src/cbdata.h +++ b/src/cbdata.h @@ -158,7 +158,7 @@ * \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 @@ -177,86 +177,41 @@ static const cbdata_type CBDATA_UNKNOWN = 0; /// \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. @@ -271,31 +226,42 @@ cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, \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 @@ -322,13 +288,13 @@ cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, #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 @@ -346,14 +312,14 @@ cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, #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) @@ -366,6 +332,8 @@ cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, */ class generic_cbdata { + CBDATA_CLASS(generic_cbdata); + public: generic_cbdata(void * aData) : data(aData) {} @@ -383,9 +351,6 @@ public: \todo CODE: make this a private field. */ void *data; /* the wrapped data */ - -private: - CBDATA_CLASS2(generic_cbdata); }; #endif /* SQUID_CBDATA_H */ diff --git a/src/client_side.h b/src/client_side.h index ca59a36a88..fc6c1a8825 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -67,6 +67,7 @@ class PortCfg; */ class ClientSocketContext : public RefCountable { + CBDATA_CLASS(ClientSocketContext); public: typedef RefCount Pointer; @@ -144,8 +145,6 @@ private: bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */ bool connRegistered_; - - CBDATA_CLASS2(ClientSocketContext); }; class ConnectionDetail; diff --git a/src/client_side_reply.h b/src/client_side_reply.h index 8b88bc2479..b1c7d80720 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -21,6 +21,7 @@ class ErrorState; class clientReplyContext : public RefCountable, public StoreClient { + CBDATA_CLASS(clientReplyContext); public: static STCB CacheHit; @@ -132,8 +133,6 @@ private: StoreEntry *old_entry; store_client *old_sc; /* ... for entry to be validated */ bool deleting; - - CBDATA_CLASS2(clientReplyContext); }; #endif /* SQUID_CLIENTSIDEREPLY_H */ diff --git a/src/client_side_request.h b/src/client_side_request.h index c8d2cd80d8..d448265e97 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -35,6 +35,7 @@ class ClientHttpRequest public BodyConsumer // to receive reply bodies in request satisf. mode #endif { + CBDATA_CLASS(ClientHttpRequest); public: ClientHttpRequest(ConnStateData *csd); @@ -167,9 +168,6 @@ private: bool request_satisfaction_mode; int64_t request_satisfaction_offset; #endif - -private: - CBDATA_CLASS2(ClientHttpRequest); }; /* client http based routines */ diff --git a/src/clients/FtpClient.h b/src/clients/FtpClient.h index 028aa61458..453cc5d07f 100644 --- a/src/clients/FtpClient.h +++ b/src/clients/FtpClient.h @@ -91,6 +91,8 @@ public: /// FTP client functionality shared among FTP Gateway and Relay clients. class Client: public ::Client { + CBDATA_CLASS(Client); + public: explicit Client(FwdState *fwdState); virtual ~Client(); @@ -189,8 +191,6 @@ private: /// 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 diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 1ce0f7ac84..7e605b0df4 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -92,6 +92,8 @@ typedef void (StateMethod)(Ftp::Gateway *); /// converts one or more FTP responses into the final HTTP response. class Gateway : public Ftp::Client { + CBDATA_CLASS(Gateway); + public: Gateway(FwdState *); virtual ~Gateway(); @@ -169,8 +171,6 @@ private: virtual bool mayReadVirginReplyBody() const; // BodyConsumer for HTTP: consume request body. virtual void handleRequestBodyProducerAborted(); - - CBDATA_CLASS2(Gateway); }; } // namespace Ftp diff --git a/src/clients/FtpRelay.cc b/src/clients/FtpRelay.cc index 190595f266..1b62d35ed3 100644 --- a/src/clients/FtpRelay.cc +++ b/src/clients/FtpRelay.cc @@ -31,6 +31,8 @@ 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(); @@ -95,8 +97,6 @@ protected: 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 diff --git a/src/comm/ConnOpener.h b/src/comm/ConnOpener.h index 238c7aa78e..49465d3626 100644 --- a/src/comm/ConnOpener.h +++ b/src/comm/ConnOpener.h @@ -24,6 +24,8 @@ namespace Comm */ class ConnOpener : public AsyncJob { + CBDATA_CLASS(ConnOpener); + protected: virtual void start(); virtual void swanSong(); @@ -85,8 +87,6 @@ private: /// [that we can cancel], but it will probably become one eventually. bool sleep_; } calls_; - - CBDATA_CLASS2(ConnOpener); }; }; // namespace Comm diff --git a/src/comm/TcpAcceptor.h b/src/comm/TcpAcceptor.h index 2de17bb8dd..f8c45578be 100644 --- a/src/comm/TcpAcceptor.h +++ b/src/comm/TcpAcceptor.h @@ -37,6 +37,8 @@ class AcceptLimiter; */ class TcpAcceptor : public AsyncJob { + CBDATA_CLASS(TcpAcceptor); + public: typedef CbcPointer Pointer; @@ -102,8 +104,6 @@ private: Comm::Flag oldAccept(Comm::ConnectionPointer &details); void setListen(); void handleClosure(const CommCloseCbParams &io); - - CBDATA_CLASS2(TcpAcceptor); }; } // namespace Comm diff --git a/src/errorpage.h b/src/errorpage.h index 561f9eae43..3f69e4893d 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -73,6 +73,8 @@ class MemBuf; /// \ingroup ErrorPageAPI class ErrorState { + CBDATA_CLASS(ErrorState); + public: ErrorState(err_type type, Http::StatusCode, HttpRequest * request); ErrorState(); // not implemented. @@ -166,8 +168,6 @@ public: /// type-specific detail about the transaction error; /// overwrites xerrno; overwritten by detail, if any. int detailCode; -private: - CBDATA_CLASS2(ErrorState); }; /** diff --git a/src/esi/Context.h b/src/esi/Context.h index 030c0c2d97..d9091ec4b9 100644 --- a/src/esi/Context.h +++ b/src/esi/Context.h @@ -22,6 +22,7 @@ class ClientHttpRequest; class ESIContext : public esiTreeParent, public ESIParserClient { + CBDATA_CLASS(ESIContext); public: typedef RefCount Pointer; @@ -155,8 +156,6 @@ private: virtual void parserDefault (const char *s, int len); virtual void parserComment (const char *s); bool processing; - - CBDATA_CLASS2(ESIContext); }; #endif /* SQUID_ESICONTEXT_H */ diff --git a/src/esi/Include.h b/src/esi/Include.h index 22b0175cb9..bef8f30768 100644 --- a/src/esi/Include.h +++ b/src/esi/Include.h @@ -20,6 +20,7 @@ typedef RefCount ESIIncludePtr; class ESIStreamContext : public RefCountable { + CBDATA_CLASS(ESIStreamContext); public: typedef RefCount Pointer; @@ -30,9 +31,6 @@ public: ESIIncludePtr include; ESISegment::Pointer localbuffer; ESISegment::Pointer buffer; - -private: - CBDATA_CLASS2(ESIStreamContext); }; class ESIInclude : public ESIElement diff --git a/src/fs/rock/RockIoRequests.h b/src/fs/rock/RockIoRequests.h index 9e1b3b0cfd..a5193e03fa 100644 --- a/src/fs/rock/RockIoRequests.h +++ b/src/fs/rock/RockIoRequests.h @@ -18,20 +18,19 @@ class DiskFile; 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; @@ -44,9 +43,6 @@ public: /// whether this is the last request for the entry bool eof; - -private: - CBDATA_CLASS2(WriteRequest); }; } // namespace Rock diff --git a/src/fs/rock/RockRebuild.h b/src/fs/rock/RockRebuild.h index 07340ae02d..30103bd743 100644 --- a/src/fs/rock/RockRebuild.h +++ b/src/fs/rock/RockRebuild.h @@ -24,6 +24,8 @@ class LoadingEntry; /// manages store rebuild process: loading meta information from db on disk class Rebuild: public AsyncJob { + CBDATA_CLASS(Rebuild); + public: Rebuild(SwapDir *dir); ~Rebuild(); @@ -76,8 +78,6 @@ private: StoreRebuildData counts; static void Steps(void *data); - - CBDATA_CLASS2(Rebuild); }; } // namespace Rock diff --git a/src/fs/ufs/RebuildState.h b/src/fs/ufs/RebuildState.h index 2584ef8d6d..4be3edc0c7 100644 --- a/src/fs/ufs/RebuildState.h +++ b/src/fs/ufs/RebuildState.h @@ -21,9 +21,10 @@ namespace Fs namespace Ufs { -/// \ingroup UFS class RebuildState : public RefCountable { + CBDATA_CLASS(RebuildState); + public: static EVH RebuildStep; @@ -59,7 +60,6 @@ public: StoreRebuildData counts; private: - CBDATA_CLASS2(RebuildState); void rebuildFromDirectory(); void rebuildFromSwapLog(); void rebuildStep(); diff --git a/src/fs/ufs/StoreSearchUFS.h b/src/fs/ufs/StoreSearchUFS.h index e8badcd0e1..fa9df4739f 100644 --- a/src/fs/ufs/StoreSearchUFS.h +++ b/src/fs/ufs/StoreSearchUFS.h @@ -17,9 +17,10 @@ namespace Fs namespace Ufs { -/// \ingroup UFS class StoreSearchUFS : public StoreSearch { + CBDATA_CLASS(StoreSearchUFS); + public: StoreSearchUFS(RefCount sd); virtual ~StoreSearchUFS(); @@ -45,7 +46,6 @@ public: RemovalPolicyWalker *walker; private: - CBDATA_CLASS2(StoreSearchUFS); /// \bug (callback) should be hidden behind a proper human readable name void (callback)(void *cbdata); void *cbdata; diff --git a/src/fs/ufs/UFSStoreState.h b/src/fs/ufs/UFSStoreState.h index 7095d325f1..69c5c9eb50 100644 --- a/src/fs/ufs/UFSStoreState.h +++ b/src/fs/ufs/UFSStoreState.h @@ -17,9 +17,11 @@ namespace Fs { 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(); @@ -96,7 +98,6 @@ private: void openDone(); void freePending(); void doWrite(); - CBDATA_CLASS2(UFSStoreState); }; } //namespace Ufs diff --git a/src/gopher.cc b/src/gopher.cc index 141aea5ee1..f5634cbaeb 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -78,6 +78,8 @@ */ class GopherStateData { + CBDATA_CLASS(GopherStateData); + public: GopherStateData(FwdState *aFwd) : entry(aFwd->entry), @@ -120,9 +122,6 @@ public: Comm::ConnectionPointer serverConn; FwdState::Pointer fwd; char replybuf[BUFSIZ]; - -private: - CBDATA_CLASS2(GopherStateData); }; CBDATA_CLASS_INIT(GopherStateData); diff --git a/src/helper.h b/src/helper.h index 16c24a0b68..074f51ebba 100644 --- a/src/helper.h +++ b/src/helper.h @@ -22,6 +22,8 @@ class helper { + CBDATA_CLASS(helper); + public: inline helper(const char *name) : cmdline(NULL), @@ -52,24 +54,20 @@ public: 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); }; /** @@ -132,19 +130,20 @@ class MemBuf; 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; */ @@ -153,9 +152,6 @@ public: Helper::Request *request; void *data; /* State data used by the calling routines */ - -private: - CBDATA_CLASS2(helper_stateful_server); }; /* helper.c */ diff --git a/src/http.h b/src/http.h index a710c36601..e4606e5e9a 100644 --- a/src/http.h +++ b/src/http.h @@ -19,6 +19,7 @@ class HttpHeader; class HttpStateData : public Client { + CBDATA_CLASS(HttpStateData); public: HttpStateData(FwdState *); @@ -110,8 +111,6 @@ private: bool peerSupportsConnectionPinning() const; ChunkedCodingParser *httpChunkDecoder; -private: - CBDATA_CLASS2(HttpStateData); }; int httpCachable(const HttpRequestMethod&); diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index 09c42e6bbc..3169c1ef3a 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -38,6 +38,11 @@ typedef struct _IdentClient { class IdentStateData { +public: + hash_link hash; /* must be first */ +private: + CBDATA_CLASS(IdentStateData); + public: /* AsyncJob API emulated */ void deleteThis(const char *aReason); @@ -46,14 +51,10 @@ public: /// 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); diff --git a/src/ipc/Coordinator.h b/src/ipc/Coordinator.h index bd90750e20..d5ae68190c 100644 --- a/src/ipc/Coordinator.h +++ b/src/ipc/Coordinator.h @@ -29,6 +29,8 @@ namespace Ipc /// Coordinates shared activities of Strands (Squid processes or threads) class Coordinator: public Port { + CBDATA_CLASS(Coordinator); + public: static Coordinator* Instance(); @@ -77,8 +79,6 @@ private: private: Coordinator(const Coordinator&); // not implemented Coordinator& operator =(const Coordinator&); // not implemented - - CBDATA_CLASS2(Coordinator); }; } // namespace Ipc diff --git a/src/ipc/Forwarder.h b/src/ipc/Forwarder.h index 212b48ef73..93af9b9c01 100644 --- a/src/ipc/Forwarder.h +++ b/src/ipc/Forwarder.h @@ -27,6 +27,8 @@ namespace Ipc */ class Forwarder: public AsyncJob { + CBDATA_CLASS(Forwarder); + public: Forwarder(Request::Pointer aRequest, double aTimeout); virtual ~Forwarder(); @@ -64,8 +66,6 @@ protected: static RequestsMap TheRequestsMap; ///< pending Coordinator requests static unsigned int LastRequestId; ///< last requestId used - - CBDATA_CLASS2(Forwarder); }; } // namespace Ipc diff --git a/src/ipc/Inquirer.h b/src/ipc/Inquirer.h index 4a7a8f0a48..c4d1e37dfa 100644 --- a/src/ipc/Inquirer.h +++ b/src/ipc/Inquirer.h @@ -26,6 +26,8 @@ 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(); @@ -78,8 +80,6 @@ protected: static RequestsMap TheRequestsMap; ///< pending strand requests static unsigned int LastRequestId; ///< last requestId used - - CBDATA_CLASS2(Inquirer); }; } // namespace Ipc diff --git a/src/ipc/Strand.h b/src/ipc/Strand.h index bf41bbd4a0..9c16ea2fe4 100644 --- a/src/ipc/Strand.h +++ b/src/ipc/Strand.h @@ -26,6 +26,8 @@ class StrandCoord; /// Receives coordination messages on behalf of its process or thread class Strand: public Port { + CBDATA_CLASS(Strand); + public: Strand(); @@ -51,8 +53,6 @@ private: private: Strand(const Strand&); // not implemented Strand& operator =(const Strand&); // not implemented - - CBDATA_CLASS2(Strand); }; } diff --git a/src/ipc/UdsOp.h b/src/ipc/UdsOp.h index 84be3949d8..00459173a6 100644 --- a/src/ipc/UdsOp.h +++ b/src/ipc/UdsOp.h @@ -66,6 +66,8 @@ struct sockaddr_un PathToAddress(const String &pathAddr); /// 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); @@ -94,8 +96,6 @@ private: private: UdsSender(const UdsSender&); // not implemented UdsSender& operator= (const UdsSender&); // not implemented - - CBDATA_CLASS2(UdsSender); }; void SendMessage(const String& toAddress, const TypedMsgHdr& message); diff --git a/src/log/TcpLogger.h b/src/log/TcpLogger.h index 23d594633f..7798439c22 100644 --- a/src/log/TcpLogger.h +++ b/src/log/TcpLogger.h @@ -26,6 +26,8 @@ namespace Log */ class TcpLogger : public AsyncJob { + CBDATA_CLASS(TcpLogger); + public: typedef CbcPointer Pointer; @@ -103,8 +105,6 @@ private: uint64_t connectFailures; ///< number of sequential connection failures uint64_t drops; ///< number of records dropped during the current outage - - CBDATA_CLASS2(TcpLogger); }; } // namespace Log diff --git a/src/mgr/ActionWriter.h b/src/mgr/ActionWriter.h index 6266b0f509..471334c3cd 100644 --- a/src/mgr/ActionWriter.h +++ b/src/mgr/ActionWriter.h @@ -22,6 +22,8 @@ namespace Mgr /// Comm-writes it using parent StoreToCommWriter. class ActionWriter: public StoreToCommWriter { + CBDATA_CLASS(ActionWriter); + public: ActionWriter(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn); @@ -31,8 +33,6 @@ protected: private: Action::Pointer action; ///< action that fills the entry - - CBDATA_CLASS2(ActionWriter); }; } // namespace Mgr diff --git a/src/mgr/Filler.h b/src/mgr/Filler.h index 202ab3d2b1..10590f412a 100644 --- a/src/mgr/Filler.h +++ b/src/mgr/Filler.h @@ -22,6 +22,8 @@ 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); @@ -33,8 +35,6 @@ protected: 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 diff --git a/src/mgr/Forwarder.h b/src/mgr/Forwarder.h index df4f927d31..20d1c59395 100644 --- a/src/mgr/Forwarder.h +++ b/src/mgr/Forwarder.h @@ -29,6 +29,8 @@ namespace Mgr */ class Forwarder: public Ipc::Forwarder { + CBDATA_CLASS(Forwarder); + public: Forwarder(const Comm::ConnectionPointer &aConn, const ActionParams &aParams, HttpRequest* aRequest, StoreEntry* anEntry); @@ -51,8 +53,6 @@ private: 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 diff --git a/src/mgr/Inquirer.h b/src/mgr/Inquirer.h index c786ec81ea..6ba0f67275 100644 --- a/src/mgr/Inquirer.h +++ b/src/mgr/Inquirer.h @@ -25,6 +25,8 @@ 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); @@ -52,8 +54,6 @@ private: AsyncCall::Pointer writer; ///< comm_write callback AsyncCall::Pointer closer; ///< comm_close handler - - CBDATA_CLASS2(Inquirer); }; } // namespace Mgr diff --git a/src/mgr/StoreToCommWriter.h b/src/mgr/StoreToCommWriter.h index 3a07d90dc1..fcd140d3fe 100644 --- a/src/mgr/StoreToCommWriter.h +++ b/src/mgr/StoreToCommWriter.h @@ -27,6 +27,8 @@ 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(); @@ -64,8 +66,6 @@ protected: AsyncCall::Pointer closer; ///< comm_close handler char buffer[HTTP_REQBUF_SZ]; ///< action results; Store fills, Comm writes - - CBDATA_CLASS2(StoreToCommWriter); }; } // namespace Mgr diff --git a/src/pconn.h b/src/pconn.h index d94f8cf11c..eb995dfa3f 100644 --- a/src/pconn.h +++ b/src/pconn.h @@ -22,9 +22,7 @@ class PconnPool; class PeerPoolMgr; -/* for CBDATA_CLASS2() macros */ #include "cbdata.h" -/* for hash_link */ #include "hash.h" /* for IOCB */ #include "comm.h" @@ -37,6 +35,8 @@ class PeerPoolMgr; */ class IdleConnList { + CBDATA_CLASS(IdleConnList); + public: IdleConnList(const char *key, PconnPool *parent); ~IdleConnList(); @@ -92,8 +92,6 @@ private: PconnPool *parent_; char fakeReadBuf_[4096]; // TODO: kill magic number. - - CBDATA_CLASS2(IdleConnList); }; #include "ip/forward.h" diff --git a/src/redirect.cc b/src/redirect.cc index 2932be1184..f13bd7f8f7 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -38,6 +38,8 @@ class RedirectStateData { + CBDATA_CLASS(RedirectStateData); + public: explicit RedirectStateData(const char *url); ~RedirectStateData(); @@ -46,9 +48,6 @@ public: SBuf orig_url; HLPCB *handler; - -private: - CBDATA_CLASS2(RedirectStateData); }; static HLPCB redirectHandleReply; diff --git a/src/servers/FtpServer.h b/src/servers/FtpServer.h index 0d42d51666..bf85cd6294 100644 --- a/src/servers/FtpServer.h +++ b/src/servers/FtpServer.h @@ -52,6 +52,8 @@ public: /// Manages a control connection from an FTP client. class Server: public ConnStateData { + CBDATA_CLASS(Server); + public: explicit Server(const MasterXaction::Pointer &xact); virtual ~Server(); @@ -166,8 +168,6 @@ private: 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 diff --git a/src/servers/HttpServer.cc b/src/servers/HttpServer.cc index 50f6abefdf..c3523c5223 100644 --- a/src/servers/HttpServer.cc +++ b/src/servers/HttpServer.cc @@ -23,6 +23,8 @@ namespace Http /// 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() {} @@ -53,8 +55,6 @@ private: /// temporary hack to avoid creating a true HttpsServer class const bool isHttpsServer; - - CBDATA_CLASS2(Server); }; } // namespace Http diff --git a/src/snmp/Forwarder.h b/src/snmp/Forwarder.h index 05a8052118..df3d9bf1f3 100644 --- a/src/snmp/Forwarder.h +++ b/src/snmp/Forwarder.h @@ -26,6 +26,8 @@ namespace Snmp */ class Forwarder: public Ipc::Forwarder { + CBDATA_CLASS(Forwarder); + public: Forwarder(const Pdu& aPdu, const Session& aSession, int aFd, const Ip::Address& anAddress); @@ -43,8 +45,6 @@ private: 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); diff --git a/src/snmp/Inquirer.h b/src/snmp/Inquirer.h index f06feb8595..b7313430bb 100644 --- a/src/snmp/Inquirer.h +++ b/src/snmp/Inquirer.h @@ -25,6 +25,8 @@ namespace Snmp /// 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); @@ -48,8 +50,6 @@ private: AsyncCall::Pointer writer; ///< comm_write callback AsyncCall::Pointer closer; ///< comm_close handler - - CBDATA_CLASS2(Inquirer); }; } // namespace Snmp diff --git a/src/ssl/PeerConnector.h b/src/ssl/PeerConnector.h index 1f453cdaf6..182dfbfb70 100644 --- a/src/ssl/PeerConnector.h +++ b/src/ssl/PeerConnector.h @@ -69,6 +69,8 @@ public: */ class PeerConnector: virtual public AsyncJob { + CBDATA_CLASS(PeerConnector); + public: /// Callback dialier API to allow PeerConnector to set the answer. class CbDialer @@ -171,8 +173,6 @@ private: 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); diff --git a/src/ssl/ServerBump.h b/src/ssl/ServerBump.h index 23fbceadb2..6276e6b245 100644 --- a/src/ssl/ServerBump.h +++ b/src/ssl/ServerBump.h @@ -22,11 +22,12 @@ namespace Ssl { /** - \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(); @@ -46,8 +47,6 @@ public: private: store_client *sc; ///< dummy client to prevent entry trimming - - CBDATA_CLASS2(ServerBump); }; } // namespace Ssl diff --git a/src/ssl/helper.cc b/src/ssl/helper.cc index 4d8df65ffe..23e36955ea 100644 --- a/src/ssl/helper.cc +++ b/src/ssl/helper.cc @@ -204,12 +204,15 @@ void Ssl::CertValidationHelper::Shutdown() 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); diff --git a/src/stat.cc b/src/stat.cc index 545b3bbaac..feb5c6ef36 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -65,14 +65,12 @@ typedef int STOBJFLT(const StoreEntry *); class StatObjectsState { + CBDATA_CLASS(StatObjectsState); public: StoreEntry *sentry; STOBJFLT *filter; StoreSearchPointer theSearch; - -private: - CBDATA_CLASS2(StatObjectsState); }; /* LOCALS */ diff --git a/src/tunnel.cc b/src/tunnel.cc index a9651e11ec..9f282d4bed 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -61,6 +61,7 @@ */ class TunnelStateData { + CBDATA_CLASS(TunnelStateData); public: TunnelStateData(); @@ -185,7 +186,7 @@ private: 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); diff --git a/src/urn.cc b/src/urn.cc index b938035336..dc741c82e1 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -30,6 +30,7 @@ class UrnState : public StoreClient { + CBDATA_CLASS(UrnState); public: void created (StoreEntry *newEntry); @@ -56,8 +57,6 @@ public: private: char *urlres; - - CBDATA_CLASS2(UrnState); }; typedef struct { diff --git a/src/whois.cc b/src/whois.cc index a5e69f5090..7cd4802b16 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -27,6 +27,8 @@ 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); @@ -35,9 +37,6 @@ public: FwdState::Pointer fwd; char buf[BUFSIZ+1]; /* readReply adds terminating NULL */ bool dataWritten; - -private: - CBDATA_CLASS2(WhoisState); }; CBDATA_CLASS_INIT(WhoisState);