--------------------- PatchSet 5215 Date: 2002/10/04 11:09:07 Author: rbcollins Branch: rbcollins_cxxtest Tag: (none) Log: convert client_side_reply.c->cc Members: src/Makefile.am:1.29.2.3->1.29.2.4 src/Store.h:1.1.2.1->1.1.2.2 src/StoreClient.h:1.2->1.2.18.1 src/clientStream.h:1.2->1.2.18.1 src/enums.h:1.40.2.1->1.40.2.2 src/mem.c:1.21.6.2->1.21.6.3 src/protos.h:1.63.2.3->1.63.2.4 src/stat.c:1.19.2.1->1.19.2.2 src/store.cc:1.1.2.1->1.1.2.2 src/store_digest.c:1.10.44.1->1.10.44.2 src/store_dir.c:1.20.22.1->1.20.22.2 Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.29.2.3 retrieving revision 1.29.2.4 diff -u -r1.29.2.3 -r1.29.2.4 --- squid/src/Makefile.am 4 Oct 2002 07:07:19 -0000 1.29.2.3 +++ squid/src/Makefile.am 4 Oct 2002 11:09:07 -0000 1.29.2.4 @@ -126,7 +126,7 @@ cbdata.c \ client_db.c \ client_side.c \ - client_side_reply.c \ + client_side_reply.cc \ client_side_request.c \ client_side_request.h \ clientStream.c \ Index: squid/src/Store.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/Store.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/Store.h 4 Oct 2002 07:07:19 -0000 1.1.2.1 +++ squid/src/Store.h 4 Oct 2002 11:09:07 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.1.2.1 2002/10/04 07:07:19 rbcollins Exp $ + * $Id: Store.h,v 1.1.2.2 2002/10/04 11:09:07 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,7 +34,14 @@ #ifndef SQUID_STORE_H #define SQUID_STORE_H +#ifdef __cplusplus +class StoreClient; +#endif + struct _StoreEntry { +#ifdef __cplusplus +public: +#endif hash_link hash; /* must be first */ MemObject *mem_obj; RemovalPolicyNode repl; @@ -54,9 +61,31 @@ ping_status_t ping_status:3; store_status_t store_status:3; swap_status_t swap_status:3; +#ifdef __cplusplus +public: + static size_t inUseCount(); + static void getPublicByRequestMethod (StoreClient *aClient, request_t * request, const method_t method); + virtual bool isNull() {return false;} + void *operator new (unsigned int byteCount); + void operator delete (void *address); +private: + static MemPool *pool; +#endif }; +#ifdef __cplusplus +class NullStoreEntry : public _StoreEntry +{ +public: + static NullStoreEntry *getInstance(); + bool isNull() {return true;} + void operator delete (void *address); +private: + static NullStoreEntry _instance; +}; +#endif +SQUIDCEXTERN size_t storeEntryInUse(); SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *); SQUIDCEXTERN int storeEntryLocked(const StoreEntry *); Index: squid/src/StoreClient.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/StoreClient.h,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -u -r1.2 -r1.2.18.1 --- squid/src/StoreClient.h 24 Sep 2002 10:59:12 -0000 1.2 +++ squid/src/StoreClient.h 4 Oct 2002 11:09:07 -0000 1.2.18.1 @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.2 2002/09/24 10:59:12 rbcollins Exp $ + * $Id: StoreClient.h,v 1.2.18.1 2002/10/04 11:09:07 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,6 +38,18 @@ typedef void STCB(void *, StoreIOBuffer); /* store callback */ +#ifdef __cplusplus +class _StoreEntry; +#endif + +#ifdef __cplusplus +class StoreClient { +public: + virtual void created (_StoreEntry *newEntry) = 0; +private: +}; +#endif + /* keep track each client receiving data from that particular StoreEntry */ struct _store_client { int type; @@ -60,9 +72,11 @@ dlink_node node; /* Below here is private - do no alter outside storeClient calls */ StoreIOBuffer copyInto; +#ifdef __cplusplus +#endif }; -extern void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *); -extern void storeClientDumpStats(store_client * thisClient, StoreEntry * output, int clientNumber); +SQUIDCEXTERN void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *); +SQUIDCEXTERN void storeClientDumpStats(store_client * thisClient, StoreEntry * output, int clientNumber); #endif /* SQUID_STORECLIENT_H */ Index: squid/src/clientStream.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/clientStream.h,v retrieving revision 1.2 retrieving revision 1.2.18.1 diff -u -r1.2 -r1.2.18.1 --- squid/src/clientStream.h 24 Sep 2002 10:59:14 -0000 1.2 +++ squid/src/clientStream.h 4 Oct 2002 11:09:07 -0000 1.2.18.1 @@ -1,6 +1,6 @@ /* - * $Id: clientStream.h,v 1.2 2002/09/24 10:59:14 rbcollins Exp $ + * $Id: clientStream.h,v 1.2.18.1 2002/10/04 11:09:07 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -58,13 +58,13 @@ }; /* clientStream.c */ -extern void clientStreamInit(dlink_list *, CSR *, CSD *, CSS *, void *, CSCB *, CSD *, void *, StoreIOBuffer tailBuffer); -extern void clientStreamInsertHead(dlink_list *, CSR *, CSCB *, CSD *, CSS *, void *); -extern clientStreamNode *clientStreamNew(CSR *, CSCB *, CSD *, CSS *, void *); -extern void clientStreamCallback(clientStreamNode *, clientHttpRequest *, HttpReply *, StoreIOBuffer replyBuffer); -extern void clientStreamRead(clientStreamNode *, clientHttpRequest *, StoreIOBuffer readBuffer); -extern void clientStreamDetach(clientStreamNode *, clientHttpRequest *); -extern void clientStreamAbort(clientStreamNode *, clientHttpRequest *); -extern clientStream_status_t clientStreamStatus(clientStreamNode *, clientHttpRequest *); +SQUIDCEXTERN void clientStreamInit(dlink_list *, CSR *, CSD *, CSS *, void *, CSCB *, CSD *, void *, StoreIOBuffer tailBuffer); +SQUIDCEXTERN void clientStreamInsertHead(dlink_list *, CSR *, CSCB *, CSD *, CSS *, void *); +SQUIDCEXTERN clientStreamNode *clientStreamNew(CSR *, CSCB *, CSD *, CSS *, void *); +SQUIDCEXTERN void clientStreamCallback(clientStreamNode *, clientHttpRequest *, HttpReply *, StoreIOBuffer replyBuffer); +SQUIDCEXTERN void clientStreamRead(clientStreamNode *, clientHttpRequest *, StoreIOBuffer readBuffer); +SQUIDCEXTERN void clientStreamDetach(clientStreamNode *, clientHttpRequest *); +SQUIDCEXTERN void clientStreamAbort(clientStreamNode *, clientHttpRequest *); +SQUIDCEXTERN clientStream_status_t clientStreamStatus(clientStreamNode *, clientHttpRequest *); #endif /* SQUID_CLIENTSTREAM_H */ Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.40.2.1 retrieving revision 1.40.2.2 diff -u -r1.40.2.1 -r1.40.2.2 --- squid/src/enums.h 3 Oct 2002 01:04:35 -0000 1.40.2.1 +++ squid/src/enums.h 4 Oct 2002 11:09:07 -0000 1.40.2.2 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.40.2.1 2002/10/03 01:04:35 rbcollins Exp $ + * $Id: enums.h,v 1.40.2.2 2002/10/04 11:09:07 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -620,7 +620,6 @@ MEM_NET_DB_NAME, MEM_RELIST, MEM_REQUEST_T, - MEM_STOREENTRY, MEM_WORDLIST, #if !USE_DNSSERVERS MEM_IDNS_QUERY, Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mem.c,v retrieving revision 1.21.6.2 retrieving revision 1.21.6.3 diff -u -r1.21.6.2 -r1.21.6.3 --- squid/src/mem.c 4 Oct 2002 07:07:26 -0000 1.21.6.2 +++ squid/src/mem.c 4 Oct 2002 11:09:07 -0000 1.21.6.3 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.21.6.2 2002/10/04 07:07:26 rbcollins Exp $ + * $Id: mem.c,v 1.21.6.3 2002/10/04 11:09:07 rbcollins Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -377,8 +377,6 @@ memDataInit(MEM_RELIST, "relist", sizeof(relist), 0); memDataInit(MEM_REQUEST_T, "request_t", sizeof(request_t), Squid_MaxFD >> 3); - memDataInit(MEM_STOREENTRY, "StoreEntry", sizeof(StoreEntry), 0); - memPoolSetChunkSize(MemPools[MEM_STOREENTRY], 2048 * 1024); memDataInit(MEM_WORDLIST, "wordlist", sizeof(wordlist), 0); memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0); memDataInit(MEM_MD5_DIGEST, "MD5 digest", MD5_DIGEST_CHARS, 0); Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.63.2.3 retrieving revision 1.63.2.4 diff -u -r1.63.2.3 -r1.63.2.4 --- squid/src/protos.h 4 Oct 2002 07:07:27 -0000 1.63.2.3 +++ squid/src/protos.h 4 Oct 2002 11:09:07 -0000 1.63.2.4 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.63.2.3 2002/10/04 07:07:27 rbcollins Exp $ + * $Id: protos.h,v 1.63.2.4 2002/10/04 11:09:07 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1217,7 +1217,7 @@ SQUIDCEXTERN StatCounters *snmpStatGet(int); /* Vary support functions */ -int varyEvaluateMatch(StoreEntry * entry, request_t * req); +SQUIDCEXTERN int varyEvaluateMatch(StoreEntry * entry, request_t * req); /* CygWin & Windows NT Port */ /* win32.c */ Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.19.2.1 retrieving revision 1.19.2.2 diff -u -r1.19.2.1 -r1.19.2.2 --- squid/src/stat.c 4 Oct 2002 07:07:28 -0000 1.19.2.1 +++ squid/src/stat.c 4 Oct 2002 11:09:08 -0000 1.19.2.2 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.19.2.1 2002/10/04 07:07:28 rbcollins Exp $ + * $Id: stat.c,v 1.19.2.2 2002/10/04 11:09:08 rbcollins Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -615,7 +615,7 @@ storeAppendPrintf(sentry, "Internal Data Structures:\n"); storeAppendPrintf(sentry, "\t%6d StoreEntries\n", - memInUse(MEM_STOREENTRY)); + storeEntryInUse()); storeAppendPrintf(sentry, "\t%6d StoreEntries with MemObjects\n", memInUse(MEM_MEMOBJECT)); storeAppendPrintf(sentry, "\t%6d Hot Object Cache Items\n", Index: squid/src/store.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/store.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/store.cc 4 Oct 2002 07:07:28 -0000 1.1.2.1 +++ squid/src/store.cc 4 Oct 2002 11:09:08 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.1.2.1 2002/10/04 07:07:28 rbcollins Exp $ + * $Id: store.cc,v 1.1.2.2 2002/10/04 11:09:08 rbcollins Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -35,6 +35,7 @@ #include "squid.h" #include "Store.h" +#include "StoreClient.h" #define REBUILD_TIMESTAMP_DELTA_MAX 2 @@ -95,6 +96,40 @@ * local variables */ static Stack LateReleaseStack; +MemPool *_StoreEntry::pool = NULL; + +void * +_StoreEntry::operator new (unsigned int bytecount) +{ + assert (bytecount == sizeof (_StoreEntry)); + if (!pool) { + pool = memPoolCreate ("StoreEntry", bytecount); + memPoolSetChunkSize(pool, 2048 * 1024); + } + return memPoolAlloc (pool); +} + +void +_StoreEntry::operator delete (void *address) +{ + memPoolFree(pool, address); +} + +size_t +_StoreEntry::inUseCount() +{ + if (!pool) + return 0; + MemPoolStats stats; + memPoolGetStats (&stats, pool); + return stats.items_inuse; +} + +size_t +storeEntryInUse () +{ + return _StoreEntry::inUseCount(); +} #if URL_CHECKSUM_DEBUG unsigned int @@ -132,7 +167,7 @@ new_StoreEntry(int mem_obj_flag, const char *url, const char *log_url) { StoreEntry *e = NULL; - e = static_cast(memAllocate(MEM_STOREENTRY)); + e = new _StoreEntry; if (mem_obj_flag) e->mem_obj = new_MemObject(url, log_url); debug(20, 3) ("new_StoreEntry: returning %p\n", e); @@ -177,11 +212,13 @@ StoreEntry *e = static_cast(data); debug(20, 3) ("destroy_StoreEntry: destroying %p\n", e); assert(e != NULL); + if (e == NullStoreEntry::getInstance()) + return; if (e->mem_obj) destroy_MemObject(e); storeHashDelete(e); assert(e->hash.key == NULL); - memFree(e, MEM_STOREENTRY); + delete e; } /* ----- INTERFACE BETWEEN STORAGE MANAGER AND HASH TABLE FUNCTIONS --------- */ @@ -325,6 +362,17 @@ return (StoreEntry *) p; } +void +_StoreEntry::getPublicByRequestMethod (StoreClient *aClient, request_t * request, const method_t method) +{ + assert (aClient); + _StoreEntry *result = storeGetPublicByRequestMethod( request, method); + if (!result) + aClient->created (NullStoreEntry::getInstance()); + else + aClient->created (result); +} + StoreEntry * storeGetPublic(const char *uri, const method_t method) { @@ -1412,3 +1460,14 @@ } } #endif + + +/* NullStoreEntry */ + +NullStoreEntry NullStoreEntry::_instance; + +NullStoreEntry * +NullStoreEntry::getInstance() +{ + return &_instance; +} Index: squid/src/store_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_digest.c,v retrieving revision 1.10.44.1 retrieving revision 1.10.44.2 diff -u -r1.10.44.1 -r1.10.44.2 --- squid/src/store_digest.c 4 Oct 2002 07:07:28 -0000 1.10.44.1 +++ squid/src/store_digest.c 4 Oct 2002 11:09:08 -0000 1.10.44.2 @@ -1,6 +1,6 @@ /* - * $Id: store_digest.c,v 1.10.44.1 2002/10/04 07:07:28 rbcollins Exp $ + * $Id: store_digest.c,v 1.10.44.2 2002/10/04 11:09:08 rbcollins Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -468,7 +468,7 @@ */ const int hi_cap = Config.Swap.maxSize / Config.Store.avgObjectSize; const int lo_cap = 1 + store_swap_size / Config.Store.avgObjectSize; - const int e_count = memInUse(MEM_STOREENTRY); + const int e_count = storeEntryInUse(); int cap = e_count ? e_count : hi_cap; debug(71, 2) ("storeDigestCalcCap: have: %d, want %d entries; limits: [%d, %d]\n", e_count, cap, lo_cap, hi_cap); Index: squid/src/store_dir.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_dir.c,v retrieving revision 1.20.22.1 retrieving revision 1.20.22.2 diff -u -r1.20.22.1 -r1.20.22.2 --- squid/src/store_dir.c 4 Oct 2002 07:07:28 -0000 1.20.22.1 +++ squid/src/store_dir.c 4 Oct 2002 11:09:08 -0000 1.20.22.2 @@ -1,6 +1,6 @@ /* - * $Id: store_dir.c,v 1.20.22.1 2002/10/04 07:07:28 rbcollins Exp $ + * $Id: store_dir.c,v 1.20.22.2 2002/10/04 11:09:08 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -291,7 +291,7 @@ storeAppendPrintf(sentry, "Store Directory Statistics:\n"); storeAppendPrintf(sentry, "Store Entries : %d\n", - memInUse(MEM_STOREENTRY)); + storeEntryInUse()); storeAppendPrintf(sentry, "Maximum Swap Size : %8ld KB\n", (long int) Config.Swap.maxSize); storeAppendPrintf(sentry, "Current Store Swap Size: %8d KB\n",