From: Amos Jeffries Date: Mon, 1 Dec 2014 04:05:48 +0000 (-0800) Subject: SourceLayout: shuffle memory pool allocators to mem/libmem.la X-Git-Tag: merge-candidate-3-v1~469 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed6e9fb98fc07037d14cedcac6a279ea3e8c9ee8;p=thirdparty%2Fsquid.git SourceLayout: shuffle memory pool allocators to mem/libmem.la There are no logic changes in this patch. * Some code is using the 'old' or internal pool allocation APIs directly. These have been marked with XXX for future logic changes to update. * The memory pools API and MEMPROXY_CLASS() definition are now available through the mem/forward.h header file. * Mem:: namespace has been added for library contents. * MemAllocatorProxy class has been moved into Mem:: namespace and extracted from mem.cc but should only be used via the MEMPROXY_CLASS() macro. * Extended the memory STUB file to define all mem/forward.h symbols and a few others needed currently by code using the older deprecated memory APIs. Also, some time API functions exported by util.h instead of SquidTime.h have been marked as needing work. --- diff --git a/configure.ac b/configure.ac index 818d065236..98a26e7ff8 100644 --- a/configure.ac +++ b/configure.ac @@ -3771,6 +3771,7 @@ AC_CONFIG_FILES([ src/ident/Makefile src/ip/Makefile src/log/Makefile + src/mem/Makefile src/ipc/Makefile src/ssl/Makefile src/mgr/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am index dce561a6a4..751545fcea 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -65,9 +65,6 @@ libmisccontainers_la_SOURCES = \ hash.cc libmiscutil_la_SOURCES = \ - MemPool.cc \ - MemPoolChunked.cc \ - MemPoolMalloc.cc \ getfullhostname.c \ heap.c \ iso3307.c \ diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index 9242e4bdc4..82f3eeb0d3 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -10,7 +10,6 @@ #include "squid.h" #include "md5.h" -#include "Mem.h" #include "StatCounters.h" #include "Store.h" #include "store_key_md5.h" @@ -18,6 +17,7 @@ #if USE_CACHE_DIGESTS #include "CacheDigest.h" +#include "util.h" /* local types */ diff --git a/src/DiskIO/DiskThreads/CommIO.h b/src/DiskIO/DiskThreads/CommIO.h index 098852b2c8..e6d416979f 100644 --- a/src/DiskIO/DiskThreads/CommIO.h +++ b/src/DiskIO/DiskThreads/CommIO.h @@ -9,6 +9,7 @@ #ifndef SQUID_SRC_DISKIO_DISKTHREADS_COMMIO_H #define SQUID_SRC_DISKIO_DISKTHREADS_COMMIO_H +#include "fatal.h" #include "fde.h" #include "globals.h" diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index 9bd7478c1d..5e882dd180 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -9,7 +9,6 @@ /* DEBUG: section 79 Squid-side Disk I/O functions. */ #include "squid.h" - #include "DiskThreadsDiskFile.h" #include "DiskThreadsIOStrategy.h" #include "fde.h" @@ -18,6 +17,11 @@ #include "StatCounters.h" #include "Store.h" +/* squidaio_ctrl_t uses explicit alloc()/freeOne(). + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + void DiskThreadsIOStrategy::init(void) { diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index a21c8681d7..86c5d4be7b 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -19,6 +19,12 @@ #include "SquidTime.h" #include "Store.h" +/* + * struct stat and squidaio_xstrdup use explicit pool alloc()/freeOne(). + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + #include #include #include diff --git a/src/DiskIO/DiskThreads/async_io.cc b/src/DiskIO/DiskThreads/async_io.cc index 8468e848fc..290e72cbe2 100644 --- a/src/DiskIO/DiskThreads/async_io.cc +++ b/src/DiskIO/DiskThreads/async_io.cc @@ -15,6 +15,12 @@ #include "Generic.h" #include "Store.h" +/* + * squidaio_ctrl_t uses explicit alloc()/freeOne() allocators + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + AIOCounts squidaio_counts; typedef struct squidaio_unlinkq_t { diff --git a/src/EventLoop.cc b/src/EventLoop.cc index df750d2ec9..f831bef178 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -13,6 +13,7 @@ #include "base/AsyncCallQueue.h" #include "Debug.h" #include "EventLoop.h" +#include "fatal.h" #include "SquidTime.h" EventLoop *EventLoop::Running = NULL; diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index 98de14a6ac..70ed06c4a9 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -18,6 +18,7 @@ #include "StatHist.h" #include "Store.h" #include "StrList.h" +#include "util.h" #include diff --git a/src/HttpHdrCc.h b/src/HttpHdrCc.h index 3448ad56b5..88262c5f0b 100644 --- a/src/HttpHdrCc.h +++ b/src/HttpHdrCc.h @@ -10,7 +10,7 @@ #define SQUID_HTTPHDRCC_H #include "enums.h" -#include "MemPool.h" +#include "mem/forward.h" #include "SquidString.h" class Packer; diff --git a/src/HttpHdrContRange.cc b/src/HttpHdrContRange.cc index d369be820b..d28057c3f6 100644 --- a/src/HttpHdrContRange.cc +++ b/src/HttpHdrContRange.cc @@ -13,7 +13,6 @@ #include "enums.h" #include "HttpHdrContRange.h" #include "HttpHeaderTools.h" -#include "Mem.h" /* * Currently only byte ranges are supported diff --git a/src/HttpHdrSc.cc b/src/HttpHdrSc.cc index a0eb608d30..1343835fd5 100644 --- a/src/HttpHdrSc.cc +++ b/src/HttpHdrSc.cc @@ -17,6 +17,7 @@ #include "HttpHeaderTools.h" #include "Store.h" #include "StrList.h" +#include "util.h" #include diff --git a/src/HttpHdrScTarget.h b/src/HttpHdrScTarget.h index 49d3040a93..234100df19 100644 --- a/src/HttpHdrScTarget.h +++ b/src/HttpHdrScTarget.h @@ -11,7 +11,7 @@ #include "defines.h" #include "dlink.h" -#include "MemPool.h" +#include "mem/forward.h" #include "SquidString.h" #include "typedefs.h" diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 68e1e84799..e029a8add7 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -28,6 +28,7 @@ #include "Store.h" #include "StrList.h" #include "TimeOrTag.h" +#include "util.h" #include diff --git a/src/HttpHeader.h b/src/HttpHeader.h index a8a8dcfb9e..63659fdcb5 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -12,7 +12,7 @@ #include "http/RegisteredHeaders.h" /* because we pass a spec by value */ #include "HttpHeaderMask.h" -#include "MemPool.h" +#include "mem/forward.h" #include "SquidString.h" #include diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index 20f101fc0c..482a21ec41 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -9,7 +9,7 @@ #ifndef SQUID_HTTPHEADERRANGE_H #define SQUID_HTTPHEADERRANGE_H -#include "MemPool.h" +#include "mem/forward.h" #include "Packer.h" #include "Range.h" #include "SquidString.h" diff --git a/src/Makefile.am b/src/Makefile.am index d565e6e3cb..955cad6513 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,8 +47,8 @@ LOADABLE_MODULES_SOURCES = \ LoadableModules.h \ LoadableModules.cc -SUBDIRS = base anyp helper ftp parser comm eui acl format clients servers fs repl -DIST_SUBDIRS = base anyp helper ftp parser comm eui acl format clients servers fs repl +SUBDIRS = mem base anyp helper ftp parser comm eui acl format clients servers fs repl +DIST_SUBDIRS = mem base anyp helper ftp parser comm eui acl format clients servers fs repl if ENABLE_AUTH SUBDIRS += auth @@ -428,11 +428,8 @@ squid_SOURCES = \ main.cc \ MasterXaction.cc \ MasterXaction.h \ - Mem.h \ - mem.cc \ mem_node.cc \ mem_node.h \ - Mem.h \ MemBuf.cc \ MemObject.cc \ MemObject.h \ @@ -640,6 +637,7 @@ squid_LDADD = \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SNMP_LIBS) \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -712,7 +710,6 @@ recv_announce_SOURCES = recv-announce.cc ## SwapDir wants ConfigOption ## tools.cc wants ip/libip.la ## client_side.cc wants ip/libip.la -## mem.cc wants ClientInfo.h ## libbase.la wants cbdata.* ## libbase.la wants MemBuf.* ufsdump_SOURCES = \ @@ -722,8 +719,7 @@ ufsdump_SOURCES = \ debug.cc \ int.h \ int.cc \ - Mem.h \ - mem.cc \ + mem/forward.h \ MemBuf.cc \ MemBuf.h \ Parsing.h \ @@ -1144,8 +1140,6 @@ tests_testHttpReply_SOURCES=\ HttpReply.h \ MasterXaction.cc \ MasterXaction.h \ - Mem.h \ - tests/stub_mem.cc \ RegexList.h \ RegexList.cc \ MemBuf.cc \ @@ -1212,6 +1206,7 @@ tests_testHttpReply_LDADD=\ ip/libip.la \ base/libbase.la \ ipc/libipc.la \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -1329,8 +1324,7 @@ tests_testACLMaxUserIP_SOURCES= \ tests/stub_time.cc \ url.cc \ URL.h \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ MemBuf.cc \ wordlist.h \ wordlist.cc @@ -1395,8 +1389,6 @@ tests_testCacheManager_SOURCES = \ RequestFlags.h \ RequestFlags.cc \ HttpRequest.cc \ - Mem.h \ - tests/stub_mem.cc \ String.cc \ tests/testCacheManager.cc \ tests/testCacheManager.h \ @@ -1617,6 +1609,7 @@ tests_testCacheManager_LDADD = \ ipc/libipc.la \ mgr/libmgr.la \ $(SNMP_LIBS) \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -1683,8 +1676,6 @@ tests_testDiskIO_SOURCES = \ MemBuf.cc \ MemObject.cc \ mem_node.cc \ - Mem.h \ - tests/stub_mem.cc \ Notes.h \ Notes.cc \ Packer.cc \ @@ -1800,6 +1791,7 @@ tests_testDiskIO_LDADD = \ $(SSL_LIBS) \ ipc/libipc.la \ base/libbase.la \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -1915,8 +1907,7 @@ tests_testEvent_SOURCES = \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ mem_node.cc \ MemBuf.cc \ MemObject.cc \ @@ -2162,8 +2153,7 @@ tests_testEventLoop_SOURCES = \ MasterXaction.h \ MemBuf.cc \ MemObject.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ mem_node.cc \ mime.h \ mime.cc \ @@ -2204,7 +2194,6 @@ tests_testEventLoop_SOURCES = \ StatCounters.cc \ StatHist.h \ StatHist.cc \ - Mem.h \ stmem.cc \ repl_modules.h \ store.cc \ @@ -2403,8 +2392,7 @@ tests_test_http_range_SOURCES = \ MasterXaction.h \ MemBuf.cc \ MemObject.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ mem_node.cc \ mime.h \ mime.cc \ @@ -2549,8 +2537,7 @@ tests_testHttp1Parser_SOURCES = \ MemBuf.cc \ MemBuf.h \ tests/stub_MemObject.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ mime_header.cc \ mime_header.h \ String.cc \ @@ -2599,8 +2586,7 @@ tests_testHttpRequest_SOURCES = \ RequestFlags.h \ RequestFlags.cc \ HttpRequest.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ String.cc \ tests/testHttpRequest.h \ tests/testHttpRequest.cc \ @@ -2878,8 +2864,6 @@ tests_testStore_SOURCES= \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ - Mem.h \ - tests/stub_mem.cc \ mem_node.cc \ MemBuf.cc \ MemObject.cc \ @@ -2993,6 +2977,7 @@ tests_testStore_LDADD= \ mgr/libmgr.la \ ipc/libipc.la \ anyp/libanyp.la \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -3013,8 +2998,7 @@ tests_testStore_DEPENDENCIES = \ ## libsquid pulls in SquidConfig and children. stub them. tests_testString_SOURCES = \ ClientInfo.h \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ MemBuf.cc \ String.cc \ $(SBUF_SOURCE) \ @@ -3166,8 +3150,6 @@ tests_testUfs_SOURCES = \ HttpHeaderTools.cc \ HttpHeader.h \ HttpHeader.cc \ - Mem.h \ - mem.cc \ ClientInfo.h \ MemBuf.cc \ HttpHdrContRange.cc \ @@ -3233,6 +3215,7 @@ tests_testUfs_LDADD = \ anyp/libanyp.la \ base/libbase.la \ ip/libip.la \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -3302,8 +3285,6 @@ tests_testRock_SOURCES = \ SquidList.cc \ MasterXaction.cc \ MasterXaction.h \ - Mem.h \ - mem.cc \ MemBuf.cc \ MemObject.cc \ mem_node.cc \ @@ -3413,6 +3394,7 @@ tests_testRock_LDADD = \ $(SSL_LIBS) \ ipc/libipc.la \ base/libbase.la \ + mem/libmem.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ @@ -3525,8 +3507,7 @@ tests_testURL_SOURCES = \ MasterXaction.h \ multicast.h \ multicast.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ mem_node.cc \ MemBuf.cc \ MemObject.cc \ @@ -3683,10 +3664,10 @@ tests_testSBuf_SOURCES= \ tests/stub_SBufDetailedStats.cc \ SBufStream.h \ tests/stub_time.cc \ - mem.cc \ tests/stub_debug.cc \ tests/stub_fatal.cc \ tests/stub_HelperChildConfig.cc \ + tests/stub_libmem.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_store.cc \ @@ -3722,7 +3703,6 @@ tests_testSBufList_SOURCES= \ tests/stub_SBufDetailedStats.cc \ SBufStream.h \ tests/stub_time.cc \ - mem.cc \ tests/stub_MemObject.cc \ tests/stub_cbdata.cc \ tests/stub_comm.cc \ @@ -3731,6 +3711,7 @@ tests_testSBufList_SOURCES= \ tests/stub_fatal.cc \ tests/stub_fd.cc \ tests/stub_HelperChildConfig.cc \ + tests/stub_libmem.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ tests/stub_store.cc \ @@ -3757,8 +3738,7 @@ tests_testSBufList_DEPENDENCIES= $(SQUID_CPPUNIT_LA) tests_testConfigParser_SOURCES = \ ClientInfo.h \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ tests/stub_MemBuf.cc \ tests/stub_time.cc \ $(SBUF_SOURCE) \ @@ -3813,8 +3793,7 @@ tests_testStatHist_SOURCES = \ tests/stub_debug.cc \ tests/stub_DelayId.cc \ tests/stub_HelperChildConfig.cc \ - Mem.h \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ tests/stub_MemObject.cc \ mime.h \ tests/stub_mime.cc \ diff --git a/src/MemBlob.cc b/src/MemBlob.cc index 276b248d18..8b34327647 100644 --- a/src/MemBlob.cc +++ b/src/MemBlob.cc @@ -9,7 +9,6 @@ #include "squid.h" #include "base/TextException.h" #include "Debug.h" -#include "Mem.h" #include "MemBlob.h" #include "SBufDetailedStats.h" diff --git a/src/MemBlob.h b/src/MemBlob.h index d57d333ba3..63b18802bd 100644 --- a/src/MemBlob.h +++ b/src/MemBlob.h @@ -13,7 +13,7 @@ #include "base/InstanceId.h" #include "base/RefCount.h" -#include "MemPool.h" +#include "mem/forward.h" /// Various MemBlob class-wide statistics. class MemBlobStats diff --git a/src/MemBuf.cc b/src/MemBuf.cc index 2759e0e0cb..051b19e163 100644 --- a/src/MemBuf.cc +++ b/src/MemBuf.cc @@ -72,7 +72,7 @@ */ #include "squid.h" -#include "Mem.h" +#include "mem/forward.h" #include "MemBuf.h" #include "profiler/Profiler.h" diff --git a/src/Notes.h b/src/Notes.h index 6f17e0f334..9a292d442c 100644 --- a/src/Notes.h +++ b/src/Notes.h @@ -12,7 +12,7 @@ #include "acl/forward.h" #include "base/RefCount.h" #include "format/Format.h" -#include "MemPool.h" +#include "mem/forward.h" #include "SquidString.h" #include "typedefs.h" diff --git a/src/SquidList.cc b/src/SquidList.cc index d7642676b6..124ed86d9a 100644 --- a/src/SquidList.cc +++ b/src/SquidList.cc @@ -9,7 +9,7 @@ /* DEBUG: none Linked list functions (deprecated) */ #include "squid.h" -#include "Mem.h" +#include "mem/forward.h" #include "SquidList.h" #include "typedefs.h" diff --git a/src/StoreMetaMD5.h b/src/StoreMetaMD5.h index 72e89b5f1f..b5b76231b2 100644 --- a/src/StoreMetaMD5.h +++ b/src/StoreMetaMD5.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETAMD5_H #define SQUID_STOREMETAMD5_H -#include "MemPool.h" #include "StoreMeta.h" /* for STORE_META_KEY_MD5 */ #include "enums.h" diff --git a/src/StoreMetaObjSize.h b/src/StoreMetaObjSize.h index a7b6c29873..fab1f25eb2 100644 --- a/src/StoreMetaObjSize.h +++ b/src/StoreMetaObjSize.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETAOBJSIZE_H #define SQUID_STOREMETAOBJSIZE_H -#include "MemPool.h" #include "StoreMeta.h" class StoreMetaObjSize : public StoreMeta diff --git a/src/StoreMetaSTD.h b/src/StoreMetaSTD.h index 377586a53d..327fb0a606 100644 --- a/src/StoreMetaSTD.h +++ b/src/StoreMetaSTD.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETASTD_H #define SQUID_STOREMETASTD_H -#include "MemPool.h" #include "StoreMeta.h" class StoreMetaSTD : public StoreMeta diff --git a/src/StoreMetaSTDLFS.h b/src/StoreMetaSTDLFS.h index df82ea3298..593e94e66b 100644 --- a/src/StoreMetaSTDLFS.h +++ b/src/StoreMetaSTDLFS.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETASTDLFS_H #define SQUID_STOREMETASTDLFS_H -#include "MemPool.h" #include "StoreMeta.h" class StoreMetaSTDLFS : public StoreMeta diff --git a/src/StoreMetaURL.h b/src/StoreMetaURL.h index f4c1f4a058..6be7fcdee5 100644 --- a/src/StoreMetaURL.h +++ b/src/StoreMetaURL.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETAURL_H #define SQUID_STOREMETAURL_H -#include "MemPool.h" #include "StoreMeta.h" class StoreMetaURL : public StoreMeta diff --git a/src/StoreMetaVary.h b/src/StoreMetaVary.h index e07c141591..f6a57c9f14 100644 --- a/src/StoreMetaVary.h +++ b/src/StoreMetaVary.h @@ -9,7 +9,6 @@ #ifndef SQUID_STOREMETAVARY_H #define SQUID_STOREMETAVARY_H -#include "MemPool.h" #include "StoreMeta.h" class StoreMetaVary : public StoreMeta diff --git a/src/StoreSwapLogData.h b/src/StoreSwapLogData.h index 3dcbfb5cf2..2b15f6b87d 100644 --- a/src/StoreSwapLogData.h +++ b/src/StoreSwapLogData.h @@ -36,7 +36,7 @@ */ #include "md5.h" -#include "MemPool.h" +#include "mem/forward.h" #include "typedefs.h" /// maintains a 24-bit checksum over integer fields diff --git a/src/String.cc b/src/String.cc index 0e0a0d90e7..91bab6b434 100644 --- a/src/String.cc +++ b/src/String.cc @@ -10,7 +10,6 @@ #include "squid.h" #include "base/TextException.h" -#include "Mem.h" #include "mgr/Registration.h" #include "profiler/Profiler.h" #include "Store.h" diff --git a/src/URL.h b/src/URL.h index e1300da253..f58835f071 100644 --- a/src/URL.h +++ b/src/URL.h @@ -10,7 +10,6 @@ #define SQUID_SRC_URL_H #include "anyp/UriScheme.h" -#include "MemPool.h" #include "SBuf.h" /** diff --git a/src/acl/Acl.cc b/src/acl/Acl.cc index cb34664c8f..83df0c8ff8 100644 --- a/src/acl/Acl.cc +++ b/src/acl/Acl.cc @@ -17,6 +17,7 @@ #include "ConfigParser.h" #include "Debug.h" #include "dlink.h" +#include "fatal.h" #include "globals.h" #include "profiler/Profiler.h" #include "SquidConfig.h" diff --git a/src/acl/Acl.h b/src/acl/Acl.h index 1c4582fcfb..3cdc4fbb1c 100644 --- a/src/acl/Acl.h +++ b/src/acl/Acl.h @@ -13,7 +13,6 @@ #include "cbdata.h" #include "defines.h" #include "dlink.h" -#include "MemPool.h" #include "SBufList.h" #include diff --git a/src/acl/DomainData.cc b/src/acl/DomainData.cc index aca71e699d..1924d66114 100644 --- a/src/acl/DomainData.cc +++ b/src/acl/DomainData.cc @@ -14,6 +14,7 @@ #include "cache_cf.h" #include "Debug.h" #include "src/URL.h" +#include "util.h" template inline void diff --git a/src/acl/Gadgets.cc b/src/acl/Gadgets.cc index 545ea3bc96..b42b20dc00 100644 --- a/src/acl/Gadgets.cc +++ b/src/acl/Gadgets.cc @@ -28,7 +28,6 @@ #include "errorpage.h" #include "globals.h" #include "HttpRequest.h" -#include "Mem.h" #include #include diff --git a/src/acl/HierCodeData.cc b/src/acl/HierCodeData.cc index 4587230049..8a6d1621ad 100644 --- a/src/acl/HierCodeData.cc +++ b/src/acl/HierCodeData.cc @@ -10,6 +10,7 @@ #include "acl/Checklist.h" #include "acl/HierCodeData.h" #include "cache_cf.h" +#include "fatal.h" #include "hier_code.h" ACLHierCodeData::ACLHierCodeData() diff --git a/src/acl/HttpHeaderData.h b/src/acl/HttpHeaderData.h index 8d7e259053..33aaed0e8b 100644 --- a/src/acl/HttpHeaderData.h +++ b/src/acl/HttpHeaderData.h @@ -11,7 +11,6 @@ #include "acl/Data.h" #include "HttpHeader.h" -#include "MemPool.h" #include "SquidString.h" class ACLHTTPHeaderData : public ACLData diff --git a/src/acl/IntRange.cc b/src/acl/IntRange.cc index d4dadff9e3..9c4566dc25 100644 --- a/src/acl/IntRange.cc +++ b/src/acl/IntRange.cc @@ -12,6 +12,7 @@ #include "acl/IntRange.h" #include "cache_cf.h" #include "Debug.h" +#include "fatal.h" #include "Parsing.h" void diff --git a/src/acl/NoteData.h b/src/acl/NoteData.h index 9bb8591b6e..cc362993e8 100644 --- a/src/acl/NoteData.h +++ b/src/acl/NoteData.h @@ -10,7 +10,6 @@ #define SQUID_ACLNOTEDATA_H #include "acl/Data.h" -#include "MemPool.h" #include "SquidString.h" class HttpRequest; diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc index 84b01332d2..3256d2d8ed 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -20,7 +20,6 @@ #include "acl/RegexData.h" #include "ConfigParser.h" #include "Debug.h" -#include "Mem.h" #include "RegexList.h" #include "wordlist.h" diff --git a/src/acl/RegexData.h b/src/acl/RegexData.h index d8a2a509b4..95f84fecb8 100644 --- a/src/acl/RegexData.h +++ b/src/acl/RegexData.h @@ -10,7 +10,6 @@ #define SQUID_ACLREGEXDATA_H #include "acl/Data.h" -#include "MemPool.h" class RegexList; diff --git a/src/acl/Strategised.h b/src/acl/Strategised.h index 57a78cb057..810cb31525 100644 --- a/src/acl/Strategised.h +++ b/src/acl/Strategised.h @@ -8,20 +8,19 @@ #ifndef SQUID_ACLSTRATEGISED_H #define SQUID_ACLSTRATEGISED_H + #include "acl/Acl.h" #include "acl/Data.h" #include "acl/FilledChecklist.h" #include "acl/Strategy.h" template - class ACLStrategised : public ACL { + MEMPROXY_CLASS(ACLStrategised); public: typedef M MatchType; - void *operator new(size_t); - void operator delete(void *); ~ACLStrategised(); ACLStrategised(ACLData *, ACLStrategy *, char const *, const ACLFlag flags[] = ACLFlags::NoFlags); @@ -44,7 +43,6 @@ public: virtual ACL *clone()const; private: - static MemAllocator *Pool; ACLData *data; char const *type_; ACLStrategy *matcher; @@ -52,29 +50,6 @@ private: /* implementation follows */ -template -MemAllocator *ACLStrategised::Pool = NULL; - -template -void * -ACLStrategised::operator new (size_t byteCount) -{ - /* derived classes with different sizes must implement their own new */ - assert (byteCount == sizeof (ACLStrategised)); - - if (!Pool) - Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised)); - - return Pool->alloc(); -} - -template -void -ACLStrategised::operator delete (void *address) -{ - Pool->freeOne(address); -} - template ACLStrategised::~ACLStrategised() { diff --git a/src/acl/UserData.cc b/src/acl/UserData.cc index 03412949e6..1ad700f481 100644 --- a/src/acl/UserData.cc +++ b/src/acl/UserData.cc @@ -13,6 +13,7 @@ #include "acl/UserData.h" #include "ConfigParser.h" #include "Debug.h" +#include "util.h" template inline void diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 17035440ef..e482dfca86 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -27,7 +27,6 @@ #include "HttpRequest.h" #include "icap_log.h" #include "ipcache.h" -#include "Mem.h" #include "pconn.h" #include "SquidConfig.h" #include "SquidTime.h" diff --git a/src/auth/Acl.cc b/src/auth/Acl.cc index 480601404b..9c4fef36f6 100644 --- a/src/auth/Acl.cc +++ b/src/auth/Acl.cc @@ -13,6 +13,7 @@ #include "auth/AclProxyAuth.h" #include "auth/UserRequest.h" #include "client_side.h" +#include "fatal.h" #include "HttpRequest.h" /** diff --git a/src/auth/Gadgets.h b/src/auth/Gadgets.h index a7ee818cc6..2f3b8a0b3b 100644 --- a/src/auth/Gadgets.h +++ b/src/auth/Gadgets.h @@ -14,7 +14,6 @@ #include "auth/Config.h" #include "auth/User.h" #include "hash.h" -#include "MemPool.h" /** \ingroup AuthAPI diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index 78b07e46bb..8f0cafe86a 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -19,6 +19,7 @@ #include "auth/UserRequest.h" #include "client_side.h" #include "comm/Connection.h" +#include "fatal.h" #include "format/Format.h" #include "HttpReply.h" #include "HttpRequest.h" diff --git a/src/auth/basic/Config.cc b/src/auth/basic/Config.cc index 1caa6f19bb..b93e4d4b57 100644 --- a/src/auth/basic/Config.cc +++ b/src/auth/basic/Config.cc @@ -28,6 +28,7 @@ #include "rfc1738.h" #include "SquidTime.h" #include "Store.h" +#include "util.h" #include "uudecode.h" #include "wordlist.h" diff --git a/src/auth/basic/UserRequest.h b/src/auth/basic/UserRequest.h index 7ef90696aa..e200440c81 100644 --- a/src/auth/basic/UserRequest.h +++ b/src/auth/basic/UserRequest.h @@ -10,7 +10,6 @@ #define _SQUID_SRC_AUTH_BASIC_USERREQUEST_H #include "auth/UserRequest.h" -#include "MemPool.h" class ConnStateData; class HttpRequest; diff --git a/src/auth/digest/Config.cc b/src/auth/digest/Config.cc index e58a29dd1a..586a32016c 100644 --- a/src/auth/digest/Config.cc +++ b/src/auth/digest/Config.cc @@ -34,7 +34,10 @@ #include "StrList.h" #include "wordlist.h" -/* Digest Scheme */ +/* digest_nonce_h still uses explicit alloc()/freeOne() MemPool calls. + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" static AUTHSSTATS authenticateDigestStats; diff --git a/src/auth/digest/UserRequest.h b/src/auth/digest/UserRequest.h index b1e0e317aa..3cb2b2e21f 100644 --- a/src/auth/digest/UserRequest.h +++ b/src/auth/digest/UserRequest.h @@ -10,7 +10,6 @@ #define _SQUID_SRC_AUTH_DIGEST_USERREQUEST_H #include "auth/UserRequest.h" -#include "MemPool.h" class ConnStateData; class HttpReply; diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index 6575f5a6d9..2f226f0676 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -13,6 +13,7 @@ #include "auth/State.h" #include "auth/User.h" #include "client_side.h" +#include "fatal.h" #include "format/Format.h" #include "globals.h" #include "helper.h" diff --git a/src/auth/negotiate/UserRequest.h b/src/auth/negotiate/UserRequest.h index c1f8db6f7a..7f586b1472 100644 --- a/src/auth/negotiate/UserRequest.h +++ b/src/auth/negotiate/UserRequest.h @@ -11,7 +11,6 @@ #include "auth/UserRequest.h" #include "helper/forward.h" -#include "MemPool.h" class ConnStateData; class HttpReply; diff --git a/src/auth/ntlm/UserRequest.cc b/src/auth/ntlm/UserRequest.cc index c73cfa83f8..055192aed9 100644 --- a/src/auth/ntlm/UserRequest.cc +++ b/src/auth/ntlm/UserRequest.cc @@ -13,6 +13,7 @@ #include "auth/State.h" #include "cbdata.h" #include "client_side.h" +#include "fatal.h" #include "format/Format.h" #include "globals.h" #include "helper.h" diff --git a/src/auth/ntlm/UserRequest.h b/src/auth/ntlm/UserRequest.h index 74d349246f..ea327c5575 100644 --- a/src/auth/ntlm/UserRequest.h +++ b/src/auth/ntlm/UserRequest.h @@ -11,7 +11,6 @@ #include "auth/UserRequest.h" #include "helper/forward.h" -#include "MemPool.h" class ConnStateData; class HttpReply; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 6372c26579..1ef519d1c1 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -40,7 +40,6 @@ #include "ipc/Kids.h" #include "log/Config.h" #include "log/CustomLog.h" -#include "Mem.h" #include "MemBuf.h" #include "mgr/ActionPasswordList.h" #include "mgr/Registration.h" @@ -60,6 +59,7 @@ #include "StoreFileSystem.h" #include "SwapDir.h" #include "tools.h" +#include "util.h" #include "wordlist.h" /* wccp2 has its own conditional definitions */ #include "wccp2.h" diff --git a/src/cbdata.cc b/src/cbdata.cc index 48882fb00e..2ebbdfc6c1 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -26,6 +26,7 @@ #include "Generic.h" #include "mgr/Registration.h" #include "Store.h" +#include "mem/Pool.h" #include #if USE_CBDATA_DEBUG diff --git a/src/client_db.cc b/src/client_db.cc index 7c4b19c201..a5aa55daf0 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -17,7 +17,6 @@ #include "fqdncache.h" #include "ip/Address.h" #include "log/access_log.h" -#include "Mem.h" #include "mgr/Registration.h" #include "SquidConfig.h" #include "SquidMath.h" diff --git a/src/client_side.cc b/src/client_side.cc index 32403ccd84..daffbc3c67 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -97,7 +97,6 @@ #include "ipc/FdNotes.h" #include "ipc/StartListening.h" #include "log/access_log.h" -#include "Mem.h" #include "MemBuf.h" #include "MemObject.h" #include "mime_header.h" @@ -134,6 +133,9 @@ #include "ssl/crtd_message.h" #endif +// for tvSubUsec() which should be in SquidTime.h +#include "util.h" + #include #include #include diff --git a/src/clients/FtpClient.cc b/src/clients/FtpClient.cc index 8466fbaf15..75e8372f73 100644 --- a/src/clients/FtpClient.cc +++ b/src/clients/FtpClient.cc @@ -20,7 +20,6 @@ #include "fd.h" #include "ftp/Parsing.h" #include "ip/tools.h" -#include "Mem.h" #include "SquidConfig.h" #include "SquidString.h" #include "StatCounters.h" diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 9409ea1865..c91ae56e0a 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -29,7 +29,6 @@ #include "HttpReply.h" #include "HttpRequest.h" #include "ip/tools.h" -#include "Mem.h" #include "MemBuf.h" #include "mime.h" #include "rfc1738.h" @@ -40,6 +39,7 @@ #include "Store.h" #include "tools.h" #include "URL.h" +#include "util.h" #include "wordlist.h" #if USE_DELAY_POOLS diff --git a/src/comm/Connection.h b/src/comm/Connection.h index 30dcb193d8..8a820318d5 100644 --- a/src/comm/Connection.h +++ b/src/comm/Connection.h @@ -15,7 +15,7 @@ #include "defines.h" #include "hier_code.h" #include "ip/Address.h" -#include "MemPool.h" +#include "mem/forward.h" #include "typedefs.h" #if USE_SQUID_EUI #include "eui/Eui48.h" diff --git a/src/disk.cc b/src/disk.cc index 2bd3d927c6..e05fddcbb6 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -14,7 +14,6 @@ #include "fd.h" #include "fde.h" #include "globals.h" -#include "Mem.h" #include "MemBuf.h" #include "profiler/Profiler.h" #include "StatCounters.h" diff --git a/src/dlink.cc b/src/dlink.cc index fd535a16c4..feb923f0db 100644 --- a/src/dlink.cc +++ b/src/dlink.cc @@ -9,8 +9,10 @@ #include "squid.h" #include "dlink.h" -/* dlink are Mem-pooled */ -#include "MemPool.h" +/* dlink_node use explicit alloc()/freeOne() + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" dlink_list ClientActiveRequests; diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 8650537dc8..3f899278d0 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -21,7 +21,6 @@ #include "fd.h" #include "fde.h" #include "ip/tools.h" -#include "Mem.h" #include "MemBuf.h" #include "mgr/Registration.h" #include "rfc3596.h" diff --git a/src/esi/Esi.cc b/src/esi/Esi.cc index 13f96a0279..b6044f9ce6 100644 --- a/src/esi/Esi.cc +++ b/src/esi/Esi.cc @@ -34,7 +34,6 @@ #include "HttpReply.h" #include "HttpRequest.h" #include "ip/Address.h" -#include "Mem.h" #include "MemBuf.h" #include "profiler/Profiler.h" #include "SquidConfig.h" diff --git a/src/esi/Sequence.h b/src/esi/Sequence.h index c3e2ed33d5..e668497831 100644 --- a/src/esi/Sequence.h +++ b/src/esi/Sequence.h @@ -13,7 +13,7 @@ #include "esi/Element.h" #include "esi/ElementList.h" -#include "MemPool.h" +#include "mem/forward.h" /* esiSequence */ diff --git a/src/esi/VarState.cc b/src/esi/VarState.cc index 9218a01d33..1091925a11 100644 --- a/src/esi/VarState.cc +++ b/src/esi/VarState.cc @@ -10,8 +10,8 @@ #include "squid.h" #include "esi/VarState.h" +#include "fatal.h" #include "HttpReply.h" -#include "Mem.h" CBDATA_TYPE (ESIVarState); FREE ESIVarStateFree; diff --git a/src/event.h b/src/event.h index 5967b7af00..4046a16dd3 100644 --- a/src/event.h +++ b/src/event.h @@ -10,7 +10,7 @@ #define SQUID_EVENT_H #include "AsyncEngine.h" -#include "MemPool.h" +#include "mem/forward.h" class StoreEntry; diff --git a/src/fd.cc b/src/fd.cc index 17d8d6ea12..96e37ae39a 100644 --- a/src/fd.cc +++ b/src/fd.cc @@ -11,6 +11,7 @@ #include "squid.h" #include "comm/Loops.h" #include "Debug.h" +#include "fatal.h" #include "fd.h" #include "fde.h" #include "globals.h" diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 5c0c3a6e90..45550ae4fc 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -13,13 +13,13 @@ #include "DnsLookupDetails.h" #include "event.h" #include "helper.h" -#include "Mem.h" #include "mgr/Registration.h" #include "SquidConfig.h" #include "SquidDns.h" #include "SquidTime.h" #include "StatCounters.h" #include "Store.h" +#include "util.h" #include "wordlist.h" #if SQUID_SNMP diff --git a/src/fs/rock/RockIoState.cc b/src/fs/rock/RockIoState.cc index 34964d2882..e9a5f5494f 100644 --- a/src/fs/rock/RockIoState.cc +++ b/src/fs/rock/RockIoState.cc @@ -18,7 +18,6 @@ #include "fs/rock/RockIoState.h" #include "fs/rock/RockSwapDir.h" #include "globals.h" -#include "Mem.h" #include "MemObject.h" #include "Parsing.h" #include "Transients.h" diff --git a/src/gopher.cc b/src/gopher.cc index f5634cbaeb..17d9e12996 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -19,7 +19,6 @@ #include "html_quote.h" #include "HttpReply.h" #include "HttpRequest.h" -#include "Mem.h" #include "MemBuf.h" #include "mime.h" #include "rfc1738.h" diff --git a/src/helper.cc b/src/helper.cc index 2be10ada3e..cc371c759e 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -20,7 +20,6 @@ #include "helper.h" #include "helper/Reply.h" #include "helper/Request.h" -#include "Mem.h" #include "MemBuf.h" #include "SquidIpc.h" #include "SquidMath.h" @@ -28,6 +27,9 @@ #include "Store.h" #include "wordlist.h" +// helper_stateful_server::data uses explicit alloc()/freeOne() */ +#include "mem/Pool.h" + #define HELPER_MAX_ARGS 64 /** Initial Squid input buffer size. Helper responses may exceed this, and diff --git a/src/htcp.cc b/src/htcp.cc index 1639f6db2f..ceed3637d9 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -37,6 +37,11 @@ #include "tools.h" #include "URL.h" +/** htcpDetail uses explicit alloc()/freeOne() + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + typedef struct _Countstr Countstr; typedef struct _htcpHeader htcpHeader; diff --git a/src/http.cc b/src/http.cc index d296989f66..2509a88eab 100644 --- a/src/http.cc +++ b/src/http.cc @@ -55,6 +55,7 @@ #include "StrList.h" #include "tools.h" #include "URL.h" +#include "util.h" #if USE_AUTH #include "auth/UserRequest.h" diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 550a304bfd..b87d51a5d2 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -29,7 +29,6 @@ #include "internal.h" #include "ip/Address.h" #include "log/File.h" -#include "Mem.h" #include "MemObject.h" #include "mgr/Registration.h" #include "mime_header.h" diff --git a/src/icp_v2.cc b/src/icp_v2.cc index bdb9f1f21b..9686aaae22 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -43,6 +43,9 @@ #include "tools.h" #include "wordlist.h" +// for tvSubUsec() which should be in SquidTime.h +#include "util.h" + #include static void icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo); diff --git a/src/internal.cc b/src/internal.cc index 31595950c1..0dc3edd3e1 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -21,6 +21,7 @@ #include "Store.h" #include "tools.h" #include "URL.h" +#include "util.h" #include "wordlist.h" /* called when we "miss" on an internal object; diff --git a/src/ipc/Port.cc b/src/ipc/Port.cc index 5a95a5aa57..0b0e213411 100644 --- a/src/ipc/Port.cc +++ b/src/ipc/Port.cc @@ -15,6 +15,7 @@ #include "CommCalls.h" #include "ipc/Port.h" #include "tools.h" +#include "util.h" static const char channelPathPfx[] = DEFAULT_STATEDIR "/"; static const char coordinatorAddrLabel[] = "-coordinator"; diff --git a/src/ipcache.cc b/src/ipcache.cc index d48b5fa9d6..8cdccb991d 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -17,7 +17,6 @@ #include "ip/Address.h" #include "ip/tools.h" #include "ipcache.h" -#include "Mem.h" #include "mgr/Registration.h" #include "rfc3596.h" #include "SquidConfig.h" @@ -25,6 +24,7 @@ #include "SquidTime.h" #include "StatCounters.h" #include "Store.h" +#include "util.h" #include "wordlist.h" #if SQUID_SNMP diff --git a/src/log/File.cc b/src/log/File.cc index 5d324220bf..a18718e801 100644 --- a/src/log/File.cc +++ b/src/log/File.cc @@ -9,6 +9,7 @@ /* DEBUG: section 50 Log file handling */ #include "squid.h" +#include "fatal.h" #include "fde.h" #include "log/File.h" #include "log/ModDaemon.h" diff --git a/src/log/ModDaemon.cc b/src/log/ModDaemon.cc index 6811b30667..92feda3a3a 100644 --- a/src/log/ModDaemon.cc +++ b/src/log/ModDaemon.cc @@ -11,6 +11,7 @@ #include "squid.h" #include "cbdata.h" #include "comm/Loops.h" +#include "fatal.h" #include "fde.h" #include "globals.h" #include "log/Config.h" diff --git a/src/log/ModStdio.cc b/src/log/ModStdio.cc index c5b0faa898..3b9b85c8fa 100644 --- a/src/log/ModStdio.cc +++ b/src/log/ModStdio.cc @@ -10,6 +10,7 @@ #include "squid.h" #include "disk.h" +#include "fatal.h" #include "fd.h" #include "fde.h" #include "globals.h" diff --git a/src/log/ModUdp.cc b/src/log/ModUdp.cc index 76a2d0237d..e295259d16 100644 --- a/src/log/ModUdp.cc +++ b/src/log/ModUdp.cc @@ -12,6 +12,7 @@ #include "comm.h" #include "comm/Connection.h" #include "disk.h" +#include "fatal.h" #include "fd.h" #include "log/File.h" #include "log/ModUdp.h" diff --git a/src/log/TcpLogger.cc b/src/log/TcpLogger.cc index 2077be80a7..8b58aa062f 100644 --- a/src/log/TcpLogger.cc +++ b/src/log/TcpLogger.cc @@ -12,6 +12,7 @@ #include "comm/ConnOpener.h" #include "comm/Loops.h" #include "comm/Write.h" +#include "fatal.h" #include "fde.h" #include "globals.h" // for shutting_down #include "log/CustomLog.h" diff --git a/src/main.cc b/src/main.cc index c070539970..1ed2e28733 100644 --- a/src/main.cc +++ b/src/main.cc @@ -47,8 +47,6 @@ #include "ipc/Kids.h" #include "ipc/Strand.h" #include "ipcache.h" -#include "Mem.h" -#include "MemPool.h" #include "mime.h" #include "neighbors.h" #include "parser/Tokenizer.h" diff --git a/src/mem/AllocatorProxy.cc b/src/mem/AllocatorProxy.cc new file mode 100644 index 0000000000..a180706251 --- /dev/null +++ b/src/mem/AllocatorProxy.cc @@ -0,0 +1,47 @@ +#include "squid.h" +#include "mem/AllocatorProxy.h" +#include "mem/Pool.h" + +void * +Mem::AllocatorProxy::alloc() +{ + return getAllocator()->alloc(); +} + +void +Mem::AllocatorProxy::freeOne(void *address) +{ + getAllocator()->freeOne(address); + /* TODO: check for empty, and if so, if the default type has altered, + * switch + */ +} + +MemAllocator * +Mem::AllocatorProxy::getAllocator() const +{ + if (!theAllocator) + theAllocator = MemPools::GetInstance().create(objectType(), size); + return theAllocator; +} + +int +Mem::AllocatorProxy::inUseCount() const +{ + if (!theAllocator) + return 0; + else + return memPoolInUseCount(theAllocator); +} + +MemPoolMeter const & +Mem::AllocatorProxy::getMeter() const +{ + return getAllocator()->getMeter(); +} + +int +Mem::AllocatorProxy::getStats(MemPoolStats * stats) +{ + return getAllocator()->getStats(stats); +} diff --git a/src/mem/AllocatorProxy.h b/src/mem/AllocatorProxy.h new file mode 100644 index 0000000000..371a37f5a1 --- /dev/null +++ b/src/mem/AllocatorProxy.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 1996-2014 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef _SQUID_SRC_MEM_ALLOCATORPROXY_H +#define _SQUID_SRC_MEM_ALLOCATORPROXY_H + +class MemAllocator; +class MemPoolStats; +class MemPoolMeter; + +/** + * \hideinitializer + * + * Pool and account the memory used for the CLASS object. + * This macro is intended for use within the declaration of a class. + */ +#define MEMPROXY_CLASS(CLASS) \ + private: \ + static inline Mem::AllocatorProxy &Pool() { \ + static Mem::AllocatorProxy thePool(#CLASS, sizeof(CLASS)); \ + return thePool; \ + } \ + public: \ + void *operator new(size_t byteCount) { \ + /* derived classes with different sizes must implement their own new */ \ + assert(byteCount == sizeof(CLASS)); \ + return Pool().alloc(); \ + } \ + void operator delete(void *address) {Pool().freeOne(address);} \ + private: + +namespace Mem +{ + +/** + * Support late binding of pool type for allocator agnostic classes + */ +class AllocatorProxy +{ +public: + AllocatorProxy(char const *aLabel, size_t const &aSize): + label(aLabel), + size(aSize), + theAllocator(NULL) + {} + + /// Allocate one element from the pool + void *alloc(); + + /// Free a element allocated by Mem::AllocatorProxy::alloc() + void freeOne(void *); + + int inUseCount() const; + size_t objectSize() const {return size;} + char const * objectType() const {return label;} + + MemPoolMeter const &getMeter() const; + + /** + * \param stats Object to be filled with statistical data about pool. + * \retval Number of objects in use, ie. allocated. + */ + int getStats(MemPoolStats * stats); + +private: + MemAllocator *getAllocator() const; + + const char *label; + size_t size; + mutable MemAllocator *theAllocator; +}; + +} // namespace Mem + +#endif /* _SQUID_SRC_MEM_ALLOCATORPROXY_H */ diff --git a/src/mem/Makefile.am b/src/mem/Makefile.am new file mode 100644 index 0000000000..e3a4cb51fa --- /dev/null +++ b/src/mem/Makefile.am @@ -0,0 +1,23 @@ +## Copyright (C) 1996-2014 The Squid Software Foundation and contributors +## +## Squid software is distributed under GPLv2+ license and includes +## contributions from numerous individuals and organizations. +## Please see the COPYING and CONTRIBUTORS files for details. +## + +include $(top_srcdir)/src/Common.am +include $(top_srcdir)/src/TestHeaders.am + +noinst_LTLIBRARIES = libmem.la + +libmem_la_SOURCES = \ + AllocatorProxy.cc \ + AllocatorProxy.h \ + forward.h \ + old_api.cc \ + Pool.cc \ + Pool.h \ + PoolChunked.cc \ + PoolChunked.h \ + PoolMalloc.cc \ + PoolMalloc.h diff --git a/lib/MemPool.cc b/src/mem/Pool.cc similarity index 88% rename from lib/MemPool.cc rename to src/mem/Pool.cc index 31be72e2d7..06aa4f828f 100644 --- a/lib/MemPool.cc +++ b/src/mem/Pool.cc @@ -12,27 +12,18 @@ */ #include "squid.h" +#include "mem/PoolChunked.h" +#include "mem/PoolMalloc.h" #include - -#include "MemPool.h" -#include "MemPoolChunked.h" -#include "MemPoolMalloc.h" +#include #define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */ -#include - -/* - * XXX This is a boundary violation between lib and src.. would be good - * if it could be solved otherwise, but left for now. - */ extern time_t squid_curtime; -/* local data */ static MemPoolMeter TheMeter; static MemPoolIterator Iterator; - static int Pool_id_counter = 0; MemPools & @@ -324,62 +315,6 @@ memPoolsTotalAllocated(void) return stats.TheMeter->alloc.level; } -void * -MemAllocatorProxy::alloc() -{ - return getAllocator()->alloc(); -} - -void -MemAllocatorProxy::freeOne(void *address) -{ - getAllocator()->freeOne(address); - /* TODO: check for empty, and if so, if the default type has altered, - * switch - */ -} - -MemAllocator * -MemAllocatorProxy::getAllocator() const -{ - if (!theAllocator) - theAllocator = MemPools::GetInstance().create(objectType(), size); - return theAllocator; -} - -int -MemAllocatorProxy::inUseCount() const -{ - if (!theAllocator) - return 0; - else - return memPoolInUseCount(theAllocator); -} - -size_t -MemAllocatorProxy::objectSize() const -{ - return size; -} - -char const * -MemAllocatorProxy::objectType() const -{ - return label; -} - -MemPoolMeter const & -MemAllocatorProxy::getMeter() const -{ - return getAllocator()->getMeter(); -} - -int -MemAllocatorProxy::getStats(MemPoolStats * stats) -{ - return getAllocator()->getStats(stats); -} - MemImplementingAllocator::MemImplementingAllocator(char const *aLabel, size_t aSize) : MemAllocator(aLabel), next(NULL), alloc_calls(0), diff --git a/include/MemPool.h b/src/mem/Pool.h similarity index 84% rename from include/MemPool.h rename to src/mem/Pool.h index 559c3a9863..1ea029cdc6 100644 --- a/include/MemPool.h +++ b/src/mem/Pool.h @@ -28,17 +28,15 @@ * might be the way to go. */ -#include "util.h" - #include "memMeter.h" #include "splay.h" +#include "util.h" #if HAVE_GNUMALLOC_H #include #elif HAVE_MALLOC_H #include #endif - #if HAVE_MEMORY_H #include #endif @@ -57,10 +55,6 @@ /// \ingroup MemPoolsAPI #define MEM_PAGE_SIZE 4096 /// \ingroup MemPoolsAPI -#define MEM_CHUNK_SIZE 4096 * 4 -/// \ingroup MemPoolsAPI -#define MEM_CHUNK_MAX_SIZE 256 * 1024 /* 2MB */ -/// \ingroup MemPoolsAPI #define MEM_MIN_FREE 32 /// \ingroup MemPoolsAPI #define MEM_MAX_FREE 65535 /* unsigned short is max number of items per chunk */ @@ -244,67 +238,6 @@ private: const char *label; }; -/** - \ingroup MemPoolsAPI - * Support late binding of pool type for allocator agnostic classes - */ -class MemAllocatorProxy -{ -public: - inline MemAllocatorProxy(char const *aLabel, size_t const &); - - /** - * Allocate one element from the pool - */ - void *alloc(); - - /** - * Free a element allocated by MemAllocatorProxy::alloc() - */ - void freeOne(void *); - - int inUseCount() const; - size_t objectSize() const; - MemPoolMeter const &getMeter() const; - - /** - \param stats Object to be filled with statistical data about pool. - \retval Number of objects in use, ie. allocated. - */ - int getStats(MemPoolStats * stats); - - char const * objectType() const; -private: - MemAllocator *getAllocator() const; - const char *label; - size_t size; - mutable MemAllocator *theAllocator; -}; - -/* help for classes */ - -/** - * \ingroup MemPoolsAPI - * \hideinitializer - * - * Pool and account the memory used for the CLASS object. - * This macro is intended for use within the declaration of a class. - */ -#define MEMPROXY_CLASS(CLASS) \ - private: \ - static inline MemAllocatorProxy &Pool() { \ - static MemAllocatorProxy thePool(#CLASS, sizeof(CLASS)); \ - return thePool; \ - } \ - public: \ - void *operator new(size_t byteCount) { \ - /* derived classes with different sizes must implement their own new */ \ - assert (byteCount == sizeof(CLASS)); \ - return Pool().alloc(); \ - } \ - void operator delete(void *address) {Pool().freeOne(address);} \ - private: - /// \ingroup MemPoolsAPI class MemImplementingAllocator : public MemAllocator { @@ -429,8 +362,4 @@ extern int memPoolInUseCount(MemAllocator *); /// \ingroup MemPoolsAPI extern int memPoolsTotalAllocated(void); -MemAllocatorProxy::MemAllocatorProxy(char const *aLabel, size_t const &aSize) : label (aLabel), size(aSize), theAllocator (NULL) -{ -} - #endif /* _MEM_POOL_H_ */ diff --git a/lib/MemPoolChunked.cc b/src/mem/PoolChunked.cc similarity index 98% rename from lib/MemPoolChunked.cc rename to src/mem/PoolChunked.cc index 89ba20c9eb..cee007256f 100644 --- a/lib/MemPoolChunked.cc +++ b/src/mem/PoolChunked.cc @@ -12,15 +12,13 @@ */ #include "squid.h" +#include "mem/PoolChunked.h" #include - -#include "MemPoolChunked.h" +#include #define MEM_MAX_MMAP_CHUNKS 2048 -#include - /* * Old way: * xmalloc each item separately, upon free stack into idle pool array. @@ -68,10 +66,6 @@ * Andres Kroonmaa. */ -/* - * XXX This is a boundary violation between lib and src.. would be good - * if it could be solved otherwise, but left for now. - */ extern time_t squid_curtime; /* local prototypes */ diff --git a/include/MemPoolChunked.h b/src/mem/PoolChunked.h similarity index 87% rename from include/MemPoolChunked.h rename to src/mem/PoolChunked.h index 0e5896748d..826504cb7b 100644 --- a/include/MemPoolChunked.h +++ b/src/mem/PoolChunked.h @@ -9,18 +9,10 @@ #ifndef _MEM_POOL_CHUNKED_H_ #define _MEM_POOL_CHUNKED_H_ -#include "MemPool.h" +#include "mem/Pool.h" -/// \ingroup MemPoolsAPI -#define MEM_PAGE_SIZE 4096 -/// \ingroup MemPoolsAPI -#define MEM_CHUNK_SIZE 4096 * 4 -/// \ingroup MemPoolsAPI +#define MEM_CHUNK_SIZE 4 * 4096 /* 16KB ... 4 * VM_PAGE_SZ */ #define MEM_CHUNK_MAX_SIZE 256 * 1024 /* 2MB */ -/// \ingroup MemPoolsAPI -#define MEM_MIN_FREE 32 -/// \ingroup MemPoolsAPI -#define MEM_MAX_FREE 65535 /* unsigned short is max number of items per chunk */ class MemChunk; diff --git a/lib/MemPoolMalloc.cc b/src/mem/PoolMalloc.cc similarity index 94% rename from lib/MemPoolMalloc.cc rename to src/mem/PoolMalloc.cc index c761c0e8ee..9bf19e3813 100644 --- a/lib/MemPoolMalloc.cc +++ b/src/mem/PoolMalloc.cc @@ -12,15 +12,11 @@ */ #include "squid.h" -#include "MemPoolMalloc.h" +#include "mem/PoolMalloc.h" #include #include -/* - * XXX This is a boundary violation between lib and src.. would be good - * if it could be solved otherwise, but left for now. - */ extern time_t squid_curtime; void * diff --git a/include/MemPoolMalloc.h b/src/mem/PoolMalloc.h similarity index 98% rename from include/MemPoolMalloc.h rename to src/mem/PoolMalloc.h index 8d1364ec71..0ee27411b9 100644 --- a/include/MemPoolMalloc.h +++ b/src/mem/PoolMalloc.h @@ -28,7 +28,7 @@ * might be the way to go. */ -#include "MemPool.h" +#include "mem/Pool.h" #include diff --git a/src/Mem.h b/src/mem/forward.h similarity index 71% rename from src/Mem.h rename to src/mem/forward.h index dc41654411..65d95e6bd5 100644 --- a/src/Mem.h +++ b/src/mem/forward.h @@ -8,11 +8,12 @@ /* DEBUG: section 13 High Level Memory Pool Management */ -#ifndef SQUID_MEM -#define SQUID_MEM +#ifndef _SQUID_SRC_MEM_FORWARD_H +#define _SQUID_SRC_MEM_FORWARD_H /* for mem_type */ #include "enums.h" +#include "mem/AllocatorProxy.h" /* for FREE */ #include "typedefs.h" @@ -22,19 +23,14 @@ class StoreEntry; class MemPoolStats; class MemPoolMeter; -class Mem +namespace Mem { - -public: - static void Init(); - static void Report(); - static void Stats(StoreEntry *); - static void CleanIdlePools(void *unused); - static void Report(std::ostream &); - static void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &); - -protected: - static void RegisterWithCacheManager(void); + void Init(); + void Report(); + void Stats(StoreEntry *); + void CleanIdlePools(void *unused); + void Report(std::ostream &); + void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &); }; extern const size_t squidSystemPageSize; @@ -54,6 +50,5 @@ FREE *memFreeBufFunc(size_t size); int memInUse(mem_type); void memDataInit(mem_type, const char *, size_t, int, bool doZero = true); void memCheckInit(void); -void memConfigure(void); -#endif /* SQUID_MEM */ +#endif /* _SQUID_SRC_MEM_FORWARD_H */ diff --git a/src/mem.cc b/src/mem/old_api.cc similarity index 99% rename from src/mem.cc rename to src/mem/old_api.cc index 5aba08010c..f264db09d1 100644 --- a/src/mem.cc +++ b/src/mem/old_api.cc @@ -18,9 +18,10 @@ #include "event.h" #include "icmp/net_db.h" #include "md5.h" -#include "Mem.h" +#include "mem/forward.h" #include "MemBuf.h" #include "memMeter.h" +#include "mem/Pool.h" #include "mgr/Registration.h" #include "RegexList.h" #include "SquidConfig.h" @@ -459,9 +460,9 @@ Mem::Init(void) } MemIsInitialized = true; - /** \par - * finally register with the cache manager */ - RegisterWithCacheManager(); + + // finally register with the cache manager + Mgr::RegisterAction("mem", "Memory Utilization", Mem::Stats, 0, 1); } void @@ -473,12 +474,6 @@ Mem::Report() " MB"); } -void -Mem::RegisterWithCacheManager(void) -{ - Mgr::RegisterAction("mem", "Memory Utilization", Mem::Stats, 0, 1); -} - mem_type &operator++ (mem_type &aMem) { int tmp = (int)aMem; diff --git a/src/mem_node.cc b/src/mem_node.cc index df261e04b9..f8e1fc860b 100644 --- a/src/mem_node.cc +++ b/src/mem_node.cc @@ -9,6 +9,7 @@ /* DEBUG: section 19 Store Memory Primitives */ #include "squid.h" +#include "mem/Pool.h" #include "mem_node.h" static ptrdiff_t makeMemNodeDataOffset(); diff --git a/src/mem_node.h b/src/mem_node.h index 9e3235aedd..d54da68588 100644 --- a/src/mem_node.h +++ b/src/mem_node.h @@ -10,7 +10,7 @@ #define SQUID_MEM_NODE_H #include "defines.h" -#include "MemPool.h" +#include "mem/forward.h" #include "Range.h" #include "StoreIOBuffer.h" diff --git a/src/mime.cc b/src/mime.cc index cdc0caf693..1b5372b66f 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -16,7 +16,6 @@ #include "HttpReply.h" #include "HttpRequest.h" #include "internal.h" -#include "Mem.h" #include "MemBuf.h" #include "MemObject.h" #include "mime.h" diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am index 09d1e148a2..d3574ae5cd 100644 --- a/src/parser/Makefile.am +++ b/src/parser/Makefile.am @@ -41,7 +41,7 @@ testTokenizer_SOURCES = \ Tokenizer.h nodist_testTokenizer_SOURCES = \ $(top_srcdir)/src/tests/testMain.cc \ - $(top_srcdir)/src/tests/stub_mem.cc \ + $(top_srcdir)/src/tests/stub_libmem.cc \ $(top_srcdir)/src/tests/stub_debug.cc \ $(top_srcdir)/src/tests/stub_time.cc \ $(top_srcdir)/src/tests/stub_SBufDetailedStats.cc diff --git a/src/peer_digest.cc b/src/peer_digest.cc index c3f81954cd..cb7690e5e3 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -27,6 +27,7 @@ #include "store_key_md5.h" #include "StoreClient.h" #include "tools.h" +#include "util.h" /* local types */ diff --git a/src/peer_select.cc b/src/peer_select.cc index def4c94e6c..0470784e86 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -25,7 +25,6 @@ #include "ICP.h" #include "ip/tools.h" #include "ipcache.h" -#include "Mem.h" #include "neighbors.h" #include "peer_sourcehash.h" #include "peer_userhash.h" diff --git a/src/refresh.cc b/src/refresh.cc index e58917b918..9ccb62a5e9 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -23,6 +23,7 @@ #include "SquidTime.h" #include "Store.h" #include "URL.h" +#include "util.h" typedef enum { rcHTTP, diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index dbc2e319f0..3e0a9553eb 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -13,6 +13,11 @@ #include "SquidTime.h" #include "Store.h" +/* because LruNode use explicit memory alloc()/freeOne() calls. + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + REMOVALPOLICYCREATE createRemovalPolicy_lru; struct LruPolicyData { diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index 588858cddb..b7e0aec3a3 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -24,6 +24,8 @@ #include "StatHist.h" #include "Store.h" #include "tools.h" +// for tvSubDsec() which should be in SquidTime.h +#include "util.h" /************************************************************************ diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 483be13d06..352832a613 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -17,6 +17,7 @@ #include "comm/Connection.h" #include "comm/Loops.h" #include "comm/UdpOpenDialer.h" +#include "fatal.h" #include "ip/Address.h" #include "ip/tools.h" #include "snmp/Forwarder.h" diff --git a/src/ssl/ErrorDetail.cc b/src/ssl/ErrorDetail.cc index 2684a94e24..b59f1d1f57 100644 --- a/src/ssl/ErrorDetail.cc +++ b/src/ssl/ErrorDetail.cc @@ -8,6 +8,7 @@ #include "squid.h" #include "errorpage.h" +#include "fatal.h" #include "ssl/ErrorDetail.h" #include diff --git a/src/ssl/bio.cc b/src/ssl/bio.cc index 75c810d07e..6d37124032 100644 --- a/src/ssl/bio.cc +++ b/src/ssl/bio.cc @@ -18,7 +18,6 @@ #include "fde.h" #include "globals.h" #include "ip/Address.h" -#include "Mem.h" #include "ssl/bio.h" #if HAVE_OPENSSL_SSL_H diff --git a/src/ssl/cert_validate_message.cc b/src/ssl/cert_validate_message.cc index f0d9f8ebdc..d9037aa5e4 100644 --- a/src/ssl/cert_validate_message.cc +++ b/src/ssl/cert_validate_message.cc @@ -13,6 +13,7 @@ #include "ssl/cert_validate_message.h" #include "ssl/ErrorDetail.h" #include "ssl/support.h" +#include "util.h" void Ssl::CertValidationMsg::composeRequest(CertValidationRequest const &vcert) diff --git a/src/ssl/support.cc b/src/ssl/support.cc index 550c093c59..86ff058366 100644 --- a/src/ssl/support.cc +++ b/src/ssl/support.cc @@ -17,6 +17,7 @@ #include "acl/FilledChecklist.h" #include "anyp/PortCfg.h" +#include "fatal.h" #include "fd.h" #include "fde.h" #include "globals.h" diff --git a/src/stat.cc b/src/stat.cc index feb5c6ef36..2d3f3cc8de 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -21,6 +21,7 @@ #include "globals.h" #include "HttpRequest.h" #include "IoStats.h" +#include "mem/Pool.h" #include "mem_node.h" #include "MemBuf.h" #include "MemObject.h" @@ -42,6 +43,8 @@ #include "store_digest.h" #include "StoreClient.h" #include "tools.h" +// for tvSubDsec() which should be in SquidTime.h +#include "util.h" #if USE_AUTH #include "auth/UserRequest.h" #endif diff --git a/src/store.cc b/src/store.cc index e75bf67e10..d576194fe1 100644 --- a/src/store.cc +++ b/src/store.cc @@ -48,6 +48,11 @@ #include "DelayPools.h" #endif +/** StoreEntry uses explicit new/delete operators, which set pool chunk size to 2MB + * XXX: convert to MEMPROXY_CLASS() API + */ +#include "mem/Pool.h" + #include #include diff --git a/src/store_digest.cc b/src/store_digest.cc index 8a7e405b3d..9a79e1fe37 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -33,6 +33,7 @@ #include "SquidTime.h" #include "Store.h" #include "StoreSearch.h" +#include "util.h" #include diff --git a/src/store_dir.cc b/src/store_dir.cc index c79954102e..3a54bf0d00 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -24,6 +24,8 @@ #include "SwapDir.h" #include "tools.h" #include "Transients.h" +// for tvSubDsec() which should be in SquidTime.h +#include "util.h" #include #include diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index faae363591..0e636b1190 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -11,7 +11,6 @@ #include "squid.h" #include "HttpRequest.h" #include "md5.h" -#include "Mem.h" #include "store_key_md5.h" #include "URL.h" diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 4b5b634bbf..631e27a1f2 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -21,6 +21,8 @@ #include "store_rebuild.h" #include "StoreSearch.h" #include "SwapDir.h" +// for tvSubDsec() which should be in SquidTime.h +#include "util.h" #include diff --git a/src/tests/CapturingStoreEntry.h b/src/tests/CapturingStoreEntry.h index 6b5cb78362..e95a1c0fc8 100644 --- a/src/tests/CapturingStoreEntry.h +++ b/src/tests/CapturingStoreEntry.h @@ -9,7 +9,6 @@ #ifndef SQUID_TESTS_CAPTURINGSTORE_ENTRY_H #define SQUID_TESTS_CAPTURINGSTORE_ENTRY_H -#include "Mem.h" #include "Store.h" /* class that captures various call data for test analysis */ diff --git a/src/tests/Stub.list b/src/tests/Stub.list index 1d3d446d8f..6cc84f639a 100644 --- a/src/tests/Stub.list +++ b/src/tests/Stub.list @@ -50,7 +50,7 @@ STUB_SOURCE= tests/STUB.h \ tests/stub_libsslsquid.cc \ tests/stub_main_cc.cc \ tests/stub_MemBuf.cc \ - tests/stub_mem.cc \ + tests/stub_libmem.cc \ tests/stub_mem_node.cc \ tests/stub_MemObject.cc \ tests/stub_MemStore.cc \ diff --git a/src/tests/stub_libmem.cc b/src/tests/stub_libmem.cc new file mode 100644 index 0000000000..509dafdbdf --- /dev/null +++ b/src/tests/stub_libmem.cc @@ -0,0 +1,105 @@ +/* + * Copyright (C) 1996-2014 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#include "squid.h" + +#define STUB_API "mem/libmem.la" +#include "STUB.h" + +#include "mem/AllocatorProxy.h" +void *Mem::AllocatorProxy::alloc() {return xmalloc(64*1024);} +void Mem::AllocatorProxy::freeOne(void *address) {xfree(address);} +int Mem::AllocatorProxy::inUseCount() const {return 0;} +//static MemPoolMeter tmpMemPoolMeter; +//MemPoolMeter const &Mem::AllocatorProxy::getMeter() const STUB_RETVAL(tmpMemPoolMeter) +int Mem::AllocatorProxy::getStats(MemPoolStats * stats) STUB_RETVAL(0) + +#include "mem/forward.h" +void Mem::Init() STUB_NOP +void Mem::Report() STUB_NOP +void Mem::Stats(StoreEntry *) STUB_NOP +void CleanIdlePools(void *) STUB_NOP +void Report(std::ostream &) STUB_NOP +void PoolReport(const MemPoolStats *, const MemPoolMeter *, std::ostream &) STUB_NOP +//const size_t squidSystemPageSize = 4096; +void memClean(void) STUB +void memInitModule(void) STUB +void memCleanModule(void) STUB +void memConfigure(void) STUB + +void * memAllocate(mem_type type) +{ + // let's waste plenty of memory. This should cover any possible need + return xmalloc(64*1024); +} + +void *memAllocString(size_t net_size, size_t * gross_size) {return memAllocBuf(net_size, gross_size);} + +void * +memAllocBuf(size_t net_size, size_t * gross_size) +{ + *gross_size=net_size; + return xcalloc(1, net_size); +} + +/* net_size is the new size, *gross size is the old gross size, to be changed to + * the new gross size as a side-effect. + */ +void * +memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size) +{ + void *rv=xrealloc(oldbuf,net_size); +// if (net_size > *gross_size) +// memset(rv+net_size,0,net_size-*gross_size); + *gross_size=net_size; + return rv; +} + +void memFree(void *p, int) {xfree(p);} +void memFreeString(size_t, void *buf) {xfree(buf);} +void memFreeBuf(size_t, void *buf) {xfree(buf);} +static void cxx_xfree(void * ptr) {xfree(ptr);} +FREE *memFreeBufFunc(size_t) {return cxx_xfree;} +int memInUse(mem_type) STUB_RETVAL(0) +void memDataInit(mem_type, const char *, size_t, int, bool) STUB_NOP +void memCheckInit(void) STUB_NOP + +#include "mem/Pool.h" +MemPoolMeter::MemPoolMeter() STUB_NOP +void MemPoolMeter::flush() STUB +static MemPools tmpMemPools; +MemPools &MemPools::GetInstance() {return tmpMemPools;} +MemPools::MemPools() STUB_NOP +void MemPools::init() STUB_NOP +void MemPools::flushMeters() STUB +MemImplementingAllocator * MemPools::create(const char *label, size_t obj_size) STUB_RETVAL(NULL); +void MemPools::setIdleLimit(ssize_t new_idle_limit) STUB +ssize_t MemPools::idleLimit() const STUB_RETVAL(0) +void MemPools::clean(time_t maxage) STUB +void MemPools::setDefaultPoolChunking(bool const &) STUB + +//MemAllocator::MemAllocator(char const *aLabel); +char const *MemAllocator::objectType() const STUB_RETVAL(NULL) +int MemAllocator::inUseCount() STUB_RETVAL(0) +size_t MemAllocator::RoundedSize(size_t minSize) STUB_RETVAL(minSize) + +//MemImplementingAllocator::MemImplementingAllocator(char const *aLabel, size_t aSize) STUB_NOP +//MemImplementingAllocator::~MemImplementingAllocator(); +MemPoolMeter const &MemImplementingAllocator::getMeter() const STUB_RETSTATREF(MemPoolMeter) +MemPoolMeter &MemImplementingAllocator::getMeter() STUB_RETSTATREF(MemPoolMeter) +void MemImplementingAllocator::flushMetersFull() STUB +void MemImplementingAllocator::flushMeters() STUB +void *MemImplementingAllocator::alloc() STUB_RETVAL(NULL) +void MemImplementingAllocator::freeOne(void *) STUB + +MemPoolIterator * memPoolIterate(void) STUB_RETVAL(NULL) +MemImplementingAllocator * memPoolIterateNext(MemPoolIterator * iter) STUB_RETVAL(NULL) +void memPoolIterateDone(MemPoolIterator ** iter) STUB +int memPoolGetGlobalStats(MemPoolGlobalStats * stats) STUB_RETVAL(0) +int memPoolInUseCount(MemAllocator *) STUB_RETVAL(0) +int memPoolsTotalAllocated(void) STUB_RETVAL(0) diff --git a/src/tests/stub_mem.cc b/src/tests/stub_mem.cc deleted file mode 100644 index 47a520561e..0000000000 --- a/src/tests/stub_mem.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 1996-2014 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* - * stub file for mem.cc - */ - -#include "squid.h" - -#define STUB_API "stub_mem.cc" -#include "Mem.h" -#include "STUB.h" - -void -memFreeString(size_t size, void *buf) -{ - xfree(buf); -} - -void * -memAllocString(size_t net_size, size_t * gross_size) -{ - *gross_size=net_size; - return xmalloc(net_size); -} - -void -memFreeBuf(size_t size, void *buf) -{ - xfree(buf); -} - -void * -memAllocBuf(size_t net_size, size_t * gross_size) -{ - *gross_size=net_size; - return xcalloc(1, net_size); -} - -/* net_size is the new size, *gross size is the old gross size, to be changed to - * the new gross size as a side-effect. - */ -void * -memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size) -{ - void *rv=xrealloc(oldbuf,net_size); -// if (net_size > *gross_size) -// memset(rv+net_size,0,net_size-*gross_size); - *gross_size=net_size; - return rv; -} - -static void -cxx_xfree(void * ptr) -{ - xfree(ptr); -} - -FREE * -memFreeBufFunc(size_t size) -{ - return cxx_xfree; -} - -void * memAllocate(mem_type type) -{ - // let's waste plenty of memory. This should cover any possible need - return xmalloc(64*1024); -} -void memFree(void *p, int type) -{ - xfree(p); -} -void Mem::Init(void) STUB_NOP -void memDataInit(mem_type, const char *, size_t, int, bool) STUB_NOP -int memInUse(mem_type) STUB_RETVAL(0) -void memConfigure(void) STUB_NOP diff --git a/src/tests/testAuth.cc b/src/tests/testAuth.cc index 95391ba5da..c92e000356 100644 --- a/src/tests/testAuth.cc +++ b/src/tests/testAuth.cc @@ -15,7 +15,6 @@ #include "auth/Scheme.h" #include "auth/UserRequest.h" #include "ConfigParser.h" -#include "Mem.h" #include "testAuth.h" CPPUNIT_TEST_SUITE_REGISTRATION( testAuth ); diff --git a/src/tests/testCacheManager.cc b/src/tests/testCacheManager.cc index 1b38aeb2b9..7219a3e635 100644 --- a/src/tests/testCacheManager.cc +++ b/src/tests/testCacheManager.cc @@ -8,7 +8,6 @@ #include "squid.h" #include "CacheManager.h" -#include "Mem.h" #include "mgr/Action.h" #include "Store.h" #include "testCacheManager.h" diff --git a/src/tests/testConfigParser.cc b/src/tests/testConfigParser.cc index 9a02917d42..a98f9297f5 100644 --- a/src/tests/testConfigParser.cc +++ b/src/tests/testConfigParser.cc @@ -9,7 +9,6 @@ #include "squid.h" #include "ConfigParser.h" #include "event.h" -#include "Mem.h" #include "SquidString.h" #include "testConfigParser.h" diff --git a/src/tests/testDiskIO.cc b/src/tests/testDiskIO.cc index 6e92fb7bcd..a43d939f4b 100644 --- a/src/tests/testDiskIO.cc +++ b/src/tests/testDiskIO.cc @@ -10,7 +10,6 @@ #include "DiskIO/DiskIOModule.h" #include "HttpHeader.h" #include "HttpReply.h" -#include "Mem.h" #include "MemObject.h" #include "Store.h" #include "StoreFileSystem.h" diff --git a/src/tests/testEvent.cc b/src/tests/testEvent.cc index 61855885ec..702e55ba21 100644 --- a/src/tests/testEvent.cc +++ b/src/tests/testEvent.cc @@ -13,7 +13,6 @@ #include "base/AsyncCallQueue.h" #include "CapturingStoreEntry.h" #include "event.h" -#include "Mem.h" #include "stat.h" #include "testEvent.h" diff --git a/src/tests/testEventLoop.cc b/src/tests/testEventLoop.cc index 5aa5df5718..9d8586de54 100644 --- a/src/tests/testEventLoop.cc +++ b/src/tests/testEventLoop.cc @@ -12,7 +12,7 @@ #include "AsyncEngine.h" #include "EventLoop.h" -#include "Mem.h" +#include "mem/forward.h" #include "SquidTime.h" #include "stat.h" #include "testEventLoop.h" diff --git a/src/tests/testHttp1Parser.cc b/src/tests/testHttp1Parser.cc index a3f01eb860..506d5c2911 100644 --- a/src/tests/testHttp1Parser.cc +++ b/src/tests/testHttp1Parser.cc @@ -15,7 +15,6 @@ #include "http/one/RequestParser.h" #include "http/RequestMethod.h" -#include "Mem.h" #include "MemBuf.h" #include "SquidConfig.h" #include "testHttp1Parser.h" diff --git a/src/tests/testHttpReply.cc b/src/tests/testHttpReply.cc index fb0ee40474..12a564cea9 100644 --- a/src/tests/testHttpReply.cc +++ b/src/tests/testHttpReply.cc @@ -11,7 +11,6 @@ #include "HttpHeader.h" #include "HttpReply.h" -#include "Mem.h" #include "mime_header.h" #include "SquidConfig.h" #include "testHttpReply.h" diff --git a/src/tests/testHttpRequest.cc b/src/tests/testHttpRequest.cc index e9adf2850b..8120609d0c 100644 --- a/src/tests/testHttpRequest.cc +++ b/src/tests/testHttpRequest.cc @@ -12,7 +12,6 @@ #include "HttpHeader.h" #include "HttpRequest.h" -#include "Mem.h" #include "mime_header.h" #include "testHttpRequest.h" diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 4b94d2606f..52392f14dc 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -10,7 +10,6 @@ #include #include "http/RequestMethod.h" -#include "Mem.h" #include "SquidConfig.h" #include "testHttpRequestMethod.h" diff --git a/src/tests/testRock.cc b/src/tests/testRock.cc index 4f9c7a27c3..d66ee55206 100644 --- a/src/tests/testRock.cc +++ b/src/tests/testRock.cc @@ -13,7 +13,6 @@ #include "globals.h" #include "HttpHeader.h" #include "HttpReply.h" -#include "Mem.h" #include "MemObject.h" #include "RequestFlags.h" #include "SquidConfig.h" diff --git a/src/tests/testSBuf.cc b/src/tests/testSBuf.cc index 93d6dc2623..945f315823 100644 --- a/src/tests/testSBuf.cc +++ b/src/tests/testSBuf.cc @@ -8,7 +8,6 @@ #include "squid.h" #include "base/CharacterSet.h" -#include "Mem.h" #include "SBuf.h" #include "SBufFindTest.h" #include "SBufStream.h" diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index 68e0b0f6a9..74a66e633f 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -7,7 +7,6 @@ */ #include "squid.h" -#include "Mem.h" #include "MemObject.h" #include "SquidConfig.h" #include "SquidTime.h" diff --git a/src/tests/testStoreEntryStream.cc b/src/tests/testStoreEntryStream.cc index 760042f2fd..2be76f5d19 100644 --- a/src/tests/testStoreEntryStream.cc +++ b/src/tests/testStoreEntryStream.cc @@ -8,7 +8,6 @@ #include "squid.h" #include "CapturingStoreEntry.h" -#include "Mem.h" #include "Store.h" #include "StoreEntryStream.h" #include "testStore.h" diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index 7d0adb3a9d..09c08365ed 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -7,7 +7,6 @@ */ #include "squid.h" -#include "Mem.h" #include "MemObject.h" #include "SquidConfig.h" #include "SquidTime.h" diff --git a/src/tests/testString.cc b/src/tests/testString.cc index 19dea2029d..b0c31bca81 100644 --- a/src/tests/testString.cc +++ b/src/tests/testString.cc @@ -8,7 +8,6 @@ #include "squid.h" #include "event.h" -#include "Mem.h" #include "SquidString.h" #include "testString.h" diff --git a/src/tests/testURL.cc b/src/tests/testURL.cc index 3bf7b6ff52..a82a1ea055 100644 --- a/src/tests/testURL.cc +++ b/src/tests/testURL.cc @@ -10,7 +10,6 @@ #include -#include "Mem.h" #include "testURL.h" #include "URL.h" diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 6556934769..5ca295338c 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -12,7 +12,6 @@ #include "globals.h" #include "HttpHeader.h" #include "HttpReply.h" -#include "Mem.h" #include "MemObject.h" #include "RequestFlags.h" #include "SquidConfig.h" diff --git a/src/tests/testUriScheme.cc b/src/tests/testUriScheme.cc index 24b0784633..78a254845b 100644 --- a/src/tests/testUriScheme.cc +++ b/src/tests/testUriScheme.cc @@ -11,7 +11,6 @@ #include #include "anyp/UriScheme.h" -#include "Mem.h" #include "SquidString.h" #include "tests/testUriScheme.h" diff --git a/src/tests/test_http_range.cc b/src/tests/test_http_range.cc index 9d7647f5c7..3dc4105765 100644 --- a/src/tests/test_http_range.cc +++ b/src/tests/test_http_range.cc @@ -9,9 +9,9 @@ /* DEBUG: section 64 HTTP Range Header */ #include "squid.h" +#include "fatal.h" #include "HttpHeader.h" #include "HttpHeaderRange.h" -#include "Mem.h" /** \todo CLEANUP: This file should be called something_stub.cc */ diff --git a/src/wccp.cc b/src/wccp.cc index 1325f2ca06..8aefa8a562 100644 --- a/src/wccp.cc +++ b/src/wccp.cc @@ -15,6 +15,7 @@ #include "comm/Connection.h" #include "comm/Loops.h" #include "event.h" +#include "fatal.h" #include "SquidConfig.h" #define WCCP_PORT 2048 diff --git a/src/wordlist.h b/src/wordlist.h index 916fca52a6..302d2081c9 100644 --- a/src/wordlist.h +++ b/src/wordlist.h @@ -10,7 +10,6 @@ #define SQUID_WORDLIST_H #include "globals.h" -#include "MemPool.h" #include "profiler/Profiler.h" #include "SBufList.h" diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 8daaa1d7a1..8bb56e64f3 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -91,12 +91,16 @@ ESIExpressions_LDADD = $(top_builddir)/src/esi/Expression.o \ $(LDADD) mem_node_test_SOURCES = mem_node_test.cc $(DEBUG_SOURCE) -mem_node_test_LDADD = $(top_builddir)/src/mem_node.o $(LDADD) +mem_node_test_LDADD = \ + $(top_builddir)/src/mem_node.o \ + $(top_builddir)/src/mem/libmem.la \ + $(LDADD) mem_hdr_test_SOURCES = mem_hdr_test.cc $(DEBUG_SOURCE) mem_hdr_test_LDADD = \ $(top_builddir)/src/stmem.o \ $(top_builddir)/src/mem_node.o \ + $(top_builddir)/src/mem/libmem.la \ $(LDADD) MemPoolTest_SOURCES = MemPoolTest.cc $(DEBUG_SOURCE)