]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup of some MemAllocatorProxy abuse. This is a MemPool internal class,
authorhno <>
Sun, 3 Sep 2006 10:11:59 +0000 (10:11 +0000)
committerhno <>
Sun, 3 Sep 2006 10:11:59 +0000 (10:11 +0000)
only meant to be used via the CLASS macros.

14 files changed:
include/MemPool.h
lib/MemPool.cc
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.h
src/DiskIO/DiskThreads/aiops.cc
src/auth/digest/auth_digest.cc
src/auth/negotiate/auth_negotiate.cc
src/auth/ntlm/auth_ntlm.cc
src/fs/coss/StoreFScoss.cc
src/fs/coss/store_coss.h
src/fs/coss/store_dir_coss.cc
src/helper.h
src/repl/lru/store_repl_lru.cc
test-suite/MemPoolTest.cc

index 68cfb27be9cbe2989436054ea1d6fd7a57f4dd10..b1f6218d94eafcbf4d2a99e255a7d9367109921e 100644 (file)
@@ -109,6 +109,7 @@ public:
     virtual void free(void *) = 0;
     virtual char const *objectType() const;
     virtual size_t objectSize() const = 0;
+    int inUseCount();
 private:
     const char *label;
 };
index 85d51e2d281a5bea94f759fbc05b5d7b019daa62..5de67f74f5e84ea049adca5f97eb821e40503d98 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MemPool.cc,v 1.4 2006/09/03 04:09:35 hno Exp $
+ * $Id: MemPool.cc,v 1.5 2006/09/03 04:11:59 hno Exp $
  *
  * DEBUG: section 63    Low Level Memory Pool Management
  * AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins
@@ -453,6 +453,14 @@ MemAllocator::objectType() const
     return label;
 }
 
+int
+MemAllocator::inUseCount()
+{
+    MemPoolStats stats;
+    getStats(&stats);
+    return stats.items_inuse;
+}
+
 void
 MemImplementingAllocator::flushMeters()
 {
@@ -832,10 +840,7 @@ MemMalloc::clean(time_t maxage)
 int
 memPoolInUseCount(MemAllocator * pool)
 {
-    MemPoolStats stats;
-    assert(pool != NULL);
-    pool->getStats(&stats);
-    return stats.items_inuse;
+    return pool->inUseCount();
 }
 
 int
index 2fb68c856c7ffd7cf1239aa8696b6a8eabdb751a..6d7f42c997cdaacbde0ac325eca5db4fe88f3ec7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskThreadsIOStrategy.cc,v 1.7 2006/06/17 16:36:15 serassio Exp $
+ * $Id: DiskThreadsIOStrategy.cc,v 1.8 2006/09/03 04:12:00 hno Exp $
  *
  * DEBUG: section 79    Squid-side Disk I/O functions.
  * AUTHOR: Robert Collins
 #include "Store.h"
 #include "fde.h"
 
-//static MemAllocatorProxy *squidaio_ctrl_pool;
-
 void
 DiskThreadsIOStrategy::init(void)
 {
     if (initialised)
         return;
 
-    squidaio_ctrl_pool = new MemAllocatorProxy("aio_ctrl", sizeof(squidaio_ctrl_t));
+    squidaio_ctrl_pool = MemPools::GetInstance().create("aio_ctrl", sizeof(squidaio_ctrl_t));
 
     initialised = true;
 
index 56e8199fe626eb34b78327aa9a1e8863c6299830..1bea5092b8aa666a67301b42a8497bfcbef7d1c8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskThreadsIOStrategy.h,v 1.3 2006/05/29 00:15:03 robertc Exp $
+ * $Id: DiskThreadsIOStrategy.h,v 1.4 2006/09/03 04:12:00 hno Exp $
  *
  * DEBUG: section 79    Squid-side Disk I/O functions.
  * AUTHOR: Robert Collins
@@ -64,7 +64,7 @@ public:
     /* Todo: add access limitations */
     bool initialised;
     static DiskThreadsIOStrategy Instance;
-    MemAllocatorProxy *squidaio_ctrl_pool;
+    MemAllocator *squidaio_ctrl_pool;
 
 private:
     static void aioStats(StoreEntry * sentry);
index 72d52fc208a872563ea88b4473bd452721e08612..314ec65e6b5ce158d56c1f326a37fdcca6b8f27f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.10 2006/08/07 02:28:22 robertc Exp $
+ * $Id: aiops.cc,v 1.11 2006/09/03 04:12:01 hno Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -143,15 +143,15 @@ static int squidaio_initialised = 0;
 #define AIO_TINY_BUFS  AIO_LARGE_BUFS >> 3
 #define AIO_MICRO_BUFS 128
 
-static MemAllocatorProxy *squidaio_large_bufs = NULL;  /* 16K */
-static MemAllocatorProxy *squidaio_medium_bufs = NULL; /* 8K */
-static MemAllocatorProxy *squidaio_small_bufs = NULL;  /* 4K */
-static MemAllocatorProxy *squidaio_tiny_bufs = NULL;   /* 2K */
-static MemAllocatorProxy *squidaio_micro_bufs = NULL;  /* 128K */
+static MemAllocator *squidaio_large_bufs = NULL;       /* 16K */
+static MemAllocator *squidaio_medium_bufs = NULL;      /* 8K */
+static MemAllocator *squidaio_small_bufs = NULL;       /* 4K */
+static MemAllocator *squidaio_tiny_bufs = NULL;        /* 2K */
+static MemAllocator *squidaio_micro_bufs = NULL;       /* 128K */
 
 static int request_queue_len = 0;
-static MemAllocatorProxy *squidaio_request_pool = NULL;
-static MemAllocatorProxy *squidaio_thread_pool = NULL;
+static MemAllocator *squidaio_request_pool = NULL;
+static MemAllocator *squidaio_thread_pool = NULL;
 static squidaio_request_queue_t request_queue;
 
 static struct
@@ -181,33 +181,30 @@ static struct sched_param globsched;
 #endif
 static pthread_t main_thread;
 
-static MemAllocatorProxy *
+static MemAllocator *
 squidaio_get_pool(int size)
 {
-    MemAllocatorProxy *p;
-
     if (size <= AIO_LARGE_BUFS) {
         if (size <= AIO_MICRO_BUFS)
-            p = squidaio_micro_bufs;
+            return squidaio_micro_bufs;
         else if (size <= AIO_TINY_BUFS)
-            p = squidaio_tiny_bufs;
+            return squidaio_tiny_bufs;
         else if (size <= AIO_SMALL_BUFS)
-            p = squidaio_small_bufs;
+            return squidaio_small_bufs;
         else if (size <= AIO_MEDIUM_BUFS)
-            p = squidaio_medium_bufs;
+            return squidaio_medium_bufs;
         else
-            p = squidaio_large_bufs;
-    } else
-        p = NULL;
+            return squidaio_large_bufs;
+    }
 
-    return p;
+    return NULL;
 }
 
 void *
 squidaio_xmalloc(int size)
 {
     void *p;
-    MemAllocatorProxy *pool;
+    MemAllocator *pool;
 
     if ((pool = squidaio_get_pool(size)) != NULL) {
         p = pool->alloc();
@@ -232,7 +229,7 @@ squidaio_xstrdup(const char *str)
 void
 squidaio_xfree(void *p, int size)
 {
-    MemAllocatorProxy *pool;
+    MemAllocator *pool;
 
     if ((pool = squidaio_get_pool(size)) != NULL) {
         pool->free(p);
@@ -243,7 +240,7 @@ squidaio_xfree(void *p, int size)
 static void
 squidaio_xstrfree(char *str)
 {
-    MemAllocatorProxy *pool;
+    MemAllocator *pool;
     int len = strlen(str) + 1;
 
     if ((pool = squidaio_get_pool(len)) != NULL) {
@@ -326,7 +323,7 @@ squidaio_init(void)
     done_queue.blocked = 0;
 
     /* Create threads and get them to sit in their wait loop */
-    squidaio_thread_pool = new MemAllocatorProxy("aio_thread", sizeof(squidaio_thread_t));
+    squidaio_thread_pool = MemPools::GetInstance().create("aio_thread", sizeof(squidaio_thread_t));
 
     assert(NUMTHREADS);
 
@@ -346,17 +343,17 @@ squidaio_init(void)
     }
 
     /* Create request pool */
-    squidaio_request_pool = new MemAllocatorProxy("aio_request", sizeof(squidaio_request_t));
+    squidaio_request_pool = MemPools::GetInstance().create("aio_request", sizeof(squidaio_request_t));
 
-    squidaio_large_bufs = new MemAllocatorProxy("squidaio_large_bufs", AIO_LARGE_BUFS);
+    squidaio_large_bufs = MemPools::GetInstance().create("squidaio_large_bufs", AIO_LARGE_BUFS);
 
-    squidaio_medium_bufs = new MemAllocatorProxy("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
+    squidaio_medium_bufs = MemPools::GetInstance().create("squidaio_medium_bufs", AIO_MEDIUM_BUFS);
 
-    squidaio_small_bufs = new MemAllocatorProxy("squidaio_small_bufs", AIO_SMALL_BUFS);
+    squidaio_small_bufs = MemPools::GetInstance().create("squidaio_small_bufs", AIO_SMALL_BUFS);
 
-    squidaio_tiny_bufs = new MemAllocatorProxy("squidaio_tiny_bufs", AIO_TINY_BUFS);
+    squidaio_tiny_bufs = MemPools::GetInstance().create("squidaio_tiny_bufs", AIO_TINY_BUFS);
 
-    squidaio_micro_bufs = new MemAllocatorProxy("squidaio_micro_bufs", AIO_MICRO_BUFS);
+    squidaio_micro_bufs = MemPools::GetInstance().create("squidaio_micro_bufs", AIO_MICRO_BUFS);
 
     squidaio_initialised = 1;
 }
index e79a57e46a50e9572feafddfd27b02e99a6a87c8..47c1078475114660c9ae7c6590b95a3732bb50fc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_digest.cc,v 1.48 2006/08/07 02:28:24 robertc Exp $
+ * $Id: auth_digest.cc,v 1.49 2006/09/03 04:12:01 hno Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Robert Collins
@@ -63,7 +63,7 @@ static hash_table *digest_nonce_cache;
 static AuthDigestConfig digestConfig;
 
 static int authdigest_initialised = 0;
-static MemAllocatorProxy *digest_nonce_pool = NULL;
+static MemAllocator *digest_nonce_pool = NULL;
 
 CBDATA_TYPE(DigestAuthenticateStateData);
 
@@ -201,7 +201,7 @@ static void
 authenticateDigestNonceSetup(void)
 {
     if (!digest_nonce_pool)
-        digest_nonce_pool = new MemAllocatorProxy("Digest Scheme nonce's", sizeof(digest_nonce_h));
+        digest_nonce_pool = MemPools::GetInstance().create("Digest Scheme nonce's", sizeof(digest_nonce_h));
 
     if (!digest_nonce_cache) {
         digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
index 428306a9aed0f8ae655542c761c40bbe9b04d203..0ca74aebea1af57b3d1880d37209cca20088ec0d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_negotiate.cc,v 1.10 2006/07/07 19:10:30 serassio Exp $
+ * $Id: auth_negotiate.cc,v 1.11 2006/09/03 04:12:01 hno Exp $
  *
  * DEBUG: section 29    Negotiate Authenticator
  * AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
@@ -70,8 +70,6 @@ CBDATA_TYPE(authenticateStateData);
 
 static int authnegotiate_initialised = 0;
 
-//static MemAllocatorProxy *negotiate_user_hash_pool = NULL;
-
 static auth_negotiate_config negotiateConfig;
 
 static hash_table *proxy_auth_cache = NULL;
@@ -175,14 +173,6 @@ void
 AuthNegotiateConfig::init(AuthConfig * scheme)
 {
     if (authenticate) {
-#if PLACEHOLDER
-
-        if (!negotiate_user_hash_pool)
-
-            negotiate_user_hash_pool = new MemAllocatorProxy("Negotiate Header Hash Data", sizeof(struct ProxyAuthCachePointer));
-
-#endif
-
         authnegotiate_initialised = 1;
 
         if (negotiateauthenticators == NULL)
index 0436ecebb8f995d0ff286a65f152e398e4b51892..5ff7d549c13381d1d0d17ee18495e98dfc35e37d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_ntlm.cc,v 1.59 2006/07/07 19:10:30 serassio Exp $
+ * $Id: auth_ntlm.cc,v 1.60 2006/09/03 04:12:02 hno Exp $
  *
  * DEBUG: section 29    NTLM Authenticator
  * AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
@@ -70,8 +70,6 @@ CBDATA_TYPE(authenticateStateData);
 
 static int authntlm_initialised = 0;
 
-//static MemAllocatorProxy *ntlm_user_hash_pool = NULL;
-
 static auth_ntlm_config ntlmConfig;
 
 static hash_table *proxy_auth_cache = NULL;
@@ -175,13 +173,6 @@ void
 AuthNTLMConfig::init(AuthConfig * scheme)
 {
     if (authenticate) {
-#if PLACEHOLDER
-
-        if (!ntlm_user_hash_pool)
-
-            ntlm_user_hash_pool = new MemAllocatorProxy("NTLM Header Hash Data", sizeof(struct ProxyAuthCachePointer));
-
-#endif
 
         authntlm_initialised = 1;
 
index 832edda8e3af06a20838f395bf8e87c9c026f3cd..2a0ed9771f9cd9e8989937f85f7fcdb057053262 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StoreFScoss.cc,v 1.5 2006/05/29 00:15:09 robertc Exp $
+ * $Id: StoreFScoss.cc,v 1.6 2006/09/03 04:12:02 hno Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Robert Collins
@@ -79,7 +79,7 @@ StoreFScoss::setup()
 {
     assert(!initialised);
 
-    coss_index_pool = new MemAllocatorProxy("COSS index data", sizeof(CossIndexNode));
+    coss_index_pool = MemPools::GetInstance().create("COSS index data", sizeof(CossIndexNode));
     initialised = true;
 }
 
index 2b058f5c2de3265c0e6445d9df0c16565493b57a..a97ab8069a5f589d768156124bc424a3051c79ff 100644 (file)
@@ -98,8 +98,8 @@ typedef struct _cossindex CossIndexNode;
 
 /* Whether the coss system has been setup or not */
 extern int coss_initialised;
-extern MemAllocatorProxy *coss_membuf_pool;
-extern MemAllocatorProxy *coss_index_pool;
+extern MemAllocator *coss_membuf_pool;
+extern MemAllocator *coss_index_pool;
 
 #include "DiskIO/ReadRequest.h"
 
index 4445cecd8c216a0daadbca6d0821829f1f8399da..c4fdc6b7e40cf06641212341677db324a73f4ca1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.66 2006/08/19 12:31:21 robertc Exp $
+ * $Id: store_dir_coss.cc,v 1.67 2006/09/03 04:12:03 hno Exp $
  * vim: set et : 
  *
  * DEBUG: section 47    Store COSS Directory Routines
@@ -54,7 +54,7 @@
 
 int n_coss_dirs = 0;
 /* static int last_coss_pick_index = -1; */
-MemAllocatorProxy *coss_index_pool = NULL;
+MemAllocator *coss_index_pool = NULL;
 
 typedef struct _RebuildState RebuildState;
 
index a4f6abb2c7ac5e234d86ddf82edb0dfe0c67022f..327febd57259ad6e267b29c71104bf0537cd3626 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.h,v 1.5 2006/09/02 15:24:08 serassio Exp $
+ * $Id: helper.h,v 1.6 2006/09/03 04:11:59 hno Exp $
  *
  * DEBUG: section 84    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -90,7 +90,7 @@ struct _helper_stateful
     int n_running;
     int n_active;
     int ipc_type;
-    MemAllocatorProxy *datapool;
+    MemAllocator *datapool;
     HLPSAVAIL *IsAvailable;
     HLPSONEQ *OnEmptyQueue;
     time_t last_queue_warn;
index 61f1b1842129ad638e66f55bb577145fe25a1ea9..a93d188b4fcaab1012fbbf8ea930930db36b8d45 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.18 2006/08/21 00:50:47 robertc Exp $
+ * $Id: store_repl_lru.cc,v 1.19 2006/09/03 04:12:04 hno Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -97,7 +97,7 @@ struct _LruNode
     dlink_node node;
 };
 
-static MemPool *lru_node_pool = NULL;
+static MemImplementingAllocator *lru_node_pool = NULL;
 static int nr_lru_policies = 0;
 
 static void
@@ -334,7 +334,7 @@ createRemovalPolicy_lru(wordlist * args)
 
     if (!lru_node_pool) {
         /* Must be chunked */
-        lru_node_pool = new MemPool("LRU policy node", sizeof(LruNode));
+        lru_node_pool = MemPools::GetInstance().create("LRU policy node", sizeof(LruNode));
         lru_node_pool->setChunkSize(512 * 1024);
     }
 
index 8aa48ad51e5ea52b0d3e9ad8d96e362ffa7a6ca4..a41c178c77f30886d32ebdcb8f210265c7707a11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: MemPoolTest.cc,v 1.3 2004/08/30 05:12:33 robertc Exp $
+ * $Id: MemPoolTest.cc,v 1.4 2006/09/03 04:12:04 hno Exp $
  *
  * AUTHOR: Robert Collins
  *
@@ -54,13 +54,13 @@ private:
   };
   static MemPool *Pool;
 };
-MemPool *MemPoolTest::Pool = NULL;
+MemAllocator *MemPoolTest::Pool = NULL;
 
 void
 MemPoolTest::run()
 {
     assert (Pool == NULL);
-    Pool = new MemPool ("Test Pool", sizeof(SomethingToAlloc));
+    Pool = MemPools::GetInstance().create("Test Pool", sizeof(SomethingToAlloc));
     assert (Pool);
     SomethingToAlloc *something = static_cast<SomethingToAlloc *>(Pool->alloc());
     assert (something);