---------------------
PatchSet 2207 
Date: 2001/05/04 14:41:55
Author: akroonmaa
Branch: chunked_mempools
Tag: (none) 
Log:
fix rest of code to comply with new memPool API

Members: 
	src/MemPoolStats.c:1.1.2.18->1.1.2.19 
	src/mem.c:1.9.8.6->1.9.8.7 
	src/protos.h:1.23.4.8->1.23.4.9 
	src/stat.c:1.9.8.5->1.9.8.6 
	src/auth/basic/auth_basic.c:1.11->1.11.4.1 
	src/auth/digest/auth_digest.c:1.5->1.5.8.1 
	src/auth/ntlm/auth_ntlm.c:1.9->1.9.6.1 
	src/fs/aufs/async_io.c:1.5->1.5.20.1 
	src/fs/aufs/store_dir_aufs.c:1.17->1.17.6.1 
	src/fs/coss/store_dir_coss.c:1.11->1.11.8.1 
	src/fs/diskd/store_dir_diskd.c:1.21.6.1->1.21.6.2 
	src/fs/ufs/store_dir_ufs.c:1.16->1.16.6.1 
	src/repl/lru/store_repl_lru.c:1.7.8.1->1.7.8.2 

Index: squid/src/MemPoolStats.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/Attic/MemPoolStats.c,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -u -r1.1.2.18 -r1.1.2.19
--- squid/src/MemPoolStats.c	3 May 2001 14:31:40 -0000	1.1.2.18
+++ squid/src/MemPoolStats.c	4 May 2001 14:41:55 -0000	1.1.2.19
@@ -125,10 +125,11 @@
 void
 memReport(StoreEntry * e)
 {
-    int i;
     static char buf[64];
     static MemPoolStats mp_stats;
-    static MemPoolStats mp_total;
+    static MemPoolGlobalStats mp_total;
+    MemPoolIterator *iter;
+    MemPool *pool;
 
     /* caption */
     storeAppendPrintf(e, "Current memory usage:\n");
@@ -155,24 +156,41 @@
     xm_time = current_dtime;
 
     /* Get stats for Totals report line */
-    memPoolGetStats(&mp_total, NULL, -1);
-    mp_total.obj_size = 1;
+    memPoolGetGlobalStats(&mp_total);
 
     /* main table */
-    i = 0;
-    while (memPoolGetStats(&mp_stats, NULL, i++)) {
+    iter = memPoolIterate();
+
+    while ((pool = memPoolIterateNext(iter))) {
+	memPoolGetStats(&mp_stats, pool);
 	if (!mp_stats.pool)	/* pool destroyed */
 	    continue;
 	if (mp_stats.pool->meter.inuse.hwater_level > 0)	/* this pool has been used */
-	    memPoolReport(&mp_stats, mp_total.meter, e);
+	    memPoolReport(&mp_stats, mp_total.TheMeter, e);
     }
-    memPoolReport(&mp_total, mp_total.meter, e);
+
+    mp_stats.pool = NULL;
+    mp_stats.label = "Total";
+    mp_stats.meter = mp_total.TheMeter;
+    mp_stats.obj_size = 1;
+    mp_stats.chunk_capacity = 0;
+    mp_stats.chunk_size = 0;
+    mp_stats.chunks_alloc = mp_total.tot_chunks_alloc;
+    mp_stats.chunks_inuse = mp_total.tot_chunks_inuse;
+    mp_stats.chunks_partial = mp_total.tot_chunks_partial;
+    mp_stats.chunks_free = mp_total.tot_chunks_free;
+    mp_stats.items_alloc = mp_total.tot_items_alloc;
+    mp_stats.items_inuse = mp_total.tot_items_inuse;
+    mp_stats.items_idle = mp_total.tot_items_idle;
+    mp_stats.overhead = mp_total.tot_overhead;
+
+    memPoolReport(&mp_stats, mp_total.TheMeter, e);
 
     /* Cumulative */
-    storeAppendPrintf(e, "Cumulative allocated volume: %s\n", double_to_str(buf, 64, mp_total.meter->gb_saved.bytes));
+    storeAppendPrintf(e, "Cumulative allocated volume: %s\n", double_to_str(buf, 64, mp_total.TheMeter->gb_saved.bytes));
     /* overhead */
     storeAppendPrintf(e, "Current overhead: %d bytes (%.3f%%)\n",
-	mp_total.overhead, xpercent(mp_total.overhead, mp_total.meter->inuse.level));
+	mp_total.tot_overhead, xpercent(mp_total.tot_overhead, mp_total.TheMeter->inuse.level));
     /* limits */
     storeAppendPrintf(e, "Idle pool limit: %.2f MB\n", toMB(mp_total.mem_idle_limit));
 }
Index: squid/src/mem.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/mem.c,v
retrieving revision 1.9.8.6
retrieving revision 1.9.8.7
diff -u -r1.9.8.6 -r1.9.8.7
--- squid/src/mem.c	3 May 2001 14:31:40 -0000	1.9.8.6
+++ squid/src/mem.c	4 May 2001 14:41:55 -0000	1.9.8.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem.c,v 1.9.8.6 2001/05/03 14:31:40 akroonmaa Exp $
+ * $Id: mem.c,v 1.9.8.7 2001/05/04 14:41:55 akroonmaa Exp $
  *
  * DEBUG: section 13    High Level Memory Pool Management
  * AUTHOR: Harvest Derived
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "memMeter.h"
 
 /* module globals */
 
@@ -113,16 +114,16 @@
 {
     MemPoolStats stats;
     assert(pool);
-    memPoolGetStats(&stats, pool, -1);
+    memPoolGetStats(&stats, pool);
     return stats.items_inuse;
 }
 
 int
 memPoolsTotalAllocated(void)
 {
-    MemPoolStats stats;
-    memPoolGetStats(&stats, NULL, -1);
-    return stats.meter->alloc.level;
+    MemPoolGlobalStats stats;
+    memPoolGetGlobalStats(&stats);
+    return stats.TheMeter->alloc.level;
 }
 
 /*
@@ -196,7 +197,7 @@
 void
 memPoolCleanIdlePools(void *unused)
 {
-    memPoolClean(NULL, clean_interval, -1);
+    memPoolClean(clean_interval);
     eventAdd("memPoolCleanIdlePools", memPoolCleanIdlePools, NULL, clean_interval, 1);
 }
 
@@ -216,7 +217,7 @@
 
     if (mem_idle_limit > new_pool_limit)
 	debug(63, 1) ("Shrinking idle mem pools to %.2f MB\n", toMB(new_pool_limit));
-    memPoolClean(NULL, 0, new_pool_limit);
+    memPoolSetIdleLimit(new_pool_limit);
     mem_idle_limit = new_pool_limit;
 }
 
@@ -224,7 +225,7 @@
 memInit(void)
 {
     int i;
-    memPoolInit();
+
     debug(63, 1) ("Memory pools are '%s'; limit: %.2f MB\n",
 	(Config.onoff.mem_pools ? "on" : "off"), toMB(mem_idle_limit));
 
@@ -283,13 +284,13 @@
 	Squid_MaxFD >> 3);
     memDataInit(MEM_STMEM_BUF, "Store Mem Buffer", SM_PAGE_SIZE,
 	Config.memMaxSize / SM_PAGE_SIZE);
-    memPoolTune(MemPools[MEM_STMEM_BUF], 512 * 1024, 0);
+    memPoolSetChunkSize(MemPools[MEM_STMEM_BUF], 512 * 1024);
     memDataInit(MEM_STOREENTRY, "StoreEntry", sizeof(StoreEntry), 0);
-    memPoolTune(MemPools[MEM_STOREENTRY], 2048 * 1024, 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);
-    memPoolTune(MemPools[MEM_MD5_DIGEST], 512 * 1024, 0);
+    memPoolSetChunkSize(MemPools[MEM_MD5_DIGEST], 512 * 1024);
     memDataInit(MEM_HELPER_REQUEST, "helper_request",
 	sizeof(helper_request), 0);
     memDataInit(MEM_HELPER_STATEFUL_REQUEST, "helper_stateful_request",
@@ -328,11 +329,13 @@
 void
 memClean(void)
 {
-    MemPoolStats stats;
-    memPoolClean(NULL, 0, 0);
-    memPoolGetStats(&stats, NULL, -1);
-    if (stats.items_inuse)
-	debug(63, 2) ("memCleanModule: %d items in %d chunks are left dirty\n", stats.items_inuse, stats.chunks_inuse);
+    MemPoolGlobalStats stats;
+    memPoolSetIdleLimit(0);
+    memPoolClean(0);
+    memPoolGetGlobalStats(&stats);
+    if (stats.tot_items_inuse)
+	debug(63, 2) ("memCleanModule: %d items in %d chunks and %d pools are left dirty\n", stats.tot_items_inuse,
+	    stats.tot_chunks_inuse, stats.tot_pools_inuse);
 }
 
 int
Index: squid/src/protos.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/protos.h,v
retrieving revision 1.23.4.8
retrieving revision 1.23.4.9
diff -u -r1.23.4.8 -r1.23.4.9
--- squid/src/protos.h	3 May 2001 14:31:40 -0000	1.23.4.8
+++ squid/src/protos.h	4 May 2001 14:41:55 -0000	1.23.4.9
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.23.4.8 2001/05/03 14:31:40 akroonmaa Exp $
+ * $Id: protos.h,v 1.23.4.9 2001/05/04 14:41:55 akroonmaa Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -834,16 +834,23 @@
 
 /* MemPool */
 extern MemPool *memPoolCreate(const char *label, size_t obj_size);
-extern void memPoolTune(MemPool * pool, size_t chunksize, int unused);
 extern void *memPoolAlloc(MemPool * pool);
 extern void memPoolFree(MemPool * pool, void *obj);
-extern void memPoolDestroy(MemPool * pool);
-extern int memPoolGetStats(MemPoolStats * stats, MemPool * pool, int index);
-extern void memPoolInit(void);
-extern void memPoolClean(MemPool * pool, time_t maxage, int new_idle_limit);
+extern void memPoolDestroy(MemPool ** pool);
+extern MemPoolIterator * memPoolGetFirst(void);
+extern MemPool * memPoolGetNext(MemPoolIterator ** iter);
+extern void memPoolSetChunkSize(MemPool * pool, size_t chunksize);
+extern void memPoolSetIdleLimit(size_t new_idle_limit);
+extern int memPoolGetStats(MemPoolStats * stats, MemPool * pool);
+extern int memPoolGetGlobalStats(MemPoolGlobalStats * stats);
+extern void memPoolClean(time_t maxage);
 
 /* Mem */
 extern void memReport(StoreEntry * e);
+extern void memConfigure(void);
+extern void memPoolCleanIdlePools(void *unused);
+extern int memPoolInUseCount(MemPool * pool);
+extern int memPoolsTotalAllocated(void);
 
 extern int stmemFreeDataUpto(mem_hdr *, int);
 extern void stmemAppend(mem_hdr *, const char *, int);
Index: squid/src/stat.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/stat.c,v
retrieving revision 1.9.8.5
retrieving revision 1.9.8.6
diff -u -r1.9.8.5 -r1.9.8.6
--- squid/src/stat.c	3 May 2001 14:31:40 -0000	1.9.8.5
+++ squid/src/stat.c	4 May 2001 14:41:56 -0000	1.9.8.6
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.c,v 1.9.8.5 2001/05/03 14:31:40 akroonmaa Exp $
+ * $Id: stat.c,v 1.9.8.6 2001/05/04 14:41:56 akroonmaa Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -602,16 +602,16 @@
 	statMemoryAccounted() >> 10);
 #endif
     {
-	MemPoolStats mp_stats;
-	memPoolGetStats(&mp_stats, NULL, -1);
+	MemPoolGlobalStats mp_stats;
+	memPoolGetGlobalStats(&mp_stats);
 	storeAppendPrintf(sentry, "\tmemPool accounted:     %6d KB %3d%%\n",
-	    mp_stats.meter->alloc.level >> 10, percent(mp_stats.meter->alloc.level, t));
+	    mp_stats.TheMeter->alloc.level >> 10, percent(mp_stats.TheMeter->alloc.level, t));
 	storeAppendPrintf(sentry, "\tmemPool unaccounted:   %6d KB %3d%%\n",
-	    (t - mp_stats.meter->alloc.level) >> 10, percent((t - mp_stats.meter->alloc.level), t));
+	    (t - mp_stats.TheMeter->alloc.level) >> 10, percent((t - mp_stats.TheMeter->alloc.level), t));
 	storeAppendPrintf(sentry, "\tmemPoolAlloc calls: %9.0f\n",
-	    mp_stats.meter->gb_saved.count);
+	    mp_stats.TheMeter->gb_saved.count);
 	storeAppendPrintf(sentry, "\tmemPoolFree calls:  %9.0f\n",
-	    mp_stats.meter->gb_freed.count);
+	    mp_stats.TheMeter->gb_freed.count);
     }
     storeAppendPrintf(sentry, "File descriptor usage for %s:\n", appname);
     storeAppendPrintf(sentry, "\tMaximum number of file descriptors:   %4d\n",
Index: squid/src/auth/basic/auth_basic.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/auth/basic/auth_basic.c,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -u -r1.11 -r1.11.4.1
--- squid/src/auth/basic/auth_basic.c	21 Mar 2001 23:43:33 -0000	1.11
+++ squid/src/auth/basic/auth_basic.c	4 May 2001 14:41:56 -0000	1.11.4.1
@@ -120,7 +120,7 @@
 	helperFree(basicauthenticators);
     basicauthenticators = NULL;
     if (basic_data_pool) {
-	memPoolDestroy(basic_data_pool);
+	memPoolDestroy(&basic_data_pool);
 	basic_data_pool = NULL;
     }
     debug(29, 2) ("authBasicDone: Basic authentication Shutdown.\n");
Index: squid/src/auth/digest/auth_digest.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/auth/digest/auth_digest.c,v
retrieving revision 1.5
retrieving revision 1.5.8.1
diff -u -r1.5 -r1.5.8.1
--- squid/src/auth/digest/auth_digest.c	3 Mar 2001 10:44:33 -0000	1.5
+++ squid/src/auth/digest/auth_digest.c	4 May 2001 14:41:56 -0000	1.5.8.1
@@ -229,8 +229,7 @@
     }
     if (digest_nonce_pool) {
 	assert(memPoolInUseCount(digest_nonce_pool) == 0);
-	memPoolDestroy(digest_nonce_pool);
-	digest_nonce_pool = NULL;
+	memPoolDestroy(&digest_nonce_pool);
     }
     debug(29, 2) ("authenticateDigestNonceShutdown: Nonce cache shutdown\n");
 }
@@ -462,8 +461,7 @@
     }
     if (digest_user_pool) {
 	assert(memPoolInUseCount(digest_user_pool) == 0);
-	memPoolDestroy(digest_user_pool);
-	digest_user_pool = NULL;
+	memPoolDestroy(&digest_user_pool);
     }
 }
 
@@ -526,8 +524,7 @@
     /* No requests should be in progress when we get here */
     if (digest_request_pool) {
 	assert(memPoolInUseCount(digest_request_pool) == 0);
-	memPoolDestroy(digest_request_pool);
-	digest_request_pool = NULL;
+	memPoolDestroy(&digest_request_pool);
     }
 }
 
Index: squid/src/auth/ntlm/auth_ntlm.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/auth_ntlm.c,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -u -r1.9 -r1.9.6.1
--- squid/src/auth/ntlm/auth_ntlm.c	10 Mar 2001 00:58:00 -0000	1.9
+++ squid/src/auth/ntlm/auth_ntlm.c	4 May 2001 14:41:56 -0000	1.9.6.1
@@ -106,18 +106,15 @@
     ntlmauthenticators = NULL;
     if (ntlm_helper_state_pool) {
 	assert(memPoolInUseCount(ntlm_helper_state_pool) == 0);
-	memPoolDestroy(ntlm_helper_state_pool);
-	ntlm_helper_state_pool = NULL;
+	memPoolDestroy(&ntlm_helper_state_pool);
     }
     if (ntlm_request_pool) {
 	assert(memPoolInUseCount(ntlm_request_pool) == 0);
-	memPoolDestroy(ntlm_request_pool);
-	ntlm_request_pool = NULL;
+	memPoolDestroy(&ntlm_request_pool);
     }
     if (ntlm_user_pool) {
 	assert(memPoolInUseCount(ntlm_user_pool) == 0);
-	memPoolDestroy(ntlm_user_pool);
-	ntlm_user_pool = NULL;
+	memPoolDestroy(&ntlm_user_pool);
     }
     debug(29, 2) ("authNTLMDone: NTLM authentication Shutdown.\n");
 }
Index: squid/src/fs/aufs/async_io.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/async_io.c,v
retrieving revision 1.5
retrieving revision 1.5.20.1
diff -u -r1.5 -r1.5.20.1
--- squid/src/fs/aufs/async_io.c	12 Jan 2001 08:20:34 -0000	1.5
+++ squid/src/fs/aufs/async_io.c	4 May 2001 14:41:56 -0000	1.5.20.1
@@ -102,7 +102,7 @@
 void
 aioDone(void)
 {
-    memPoolDestroy(aio_ctrl_pool);
+    memPoolDestroy(&aio_ctrl_pool);
     initialised = 0;
 }
 
Index: squid/src/fs/aufs/store_dir_aufs.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_dir_aufs.c,v
retrieving revision 1.17
retrieving revision 1.17.6.1
diff -u -r1.17 -r1.17.6.1
--- squid/src/fs/aufs/store_dir_aufs.c	17 Mar 2001 13:42:03 -0000	1.17
+++ squid/src/fs/aufs/store_dir_aufs.c	4 May 2001 14:41:56 -0000	1.17.6.1
@@ -1693,9 +1693,9 @@
 storeAufsDirDone(void)
 {
     aioDone();
-    memPoolDestroy(aio_state_pool);
-    memPoolDestroy(aio_qread_pool);
-    memPoolDestroy(aio_qwrite_pool);
+    memPoolDestroy(&aio_state_pool);
+    memPoolDestroy(&aio_qread_pool);
+    memPoolDestroy(&aio_qwrite_pool);
     asyncufs_initialised = 0;
 }
 
Index: squid/src/fs/coss/store_dir_coss.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/coss/store_dir_coss.c,v
retrieving revision 1.11
retrieving revision 1.11.8.1
diff -u -r1.11 -r1.11.8.1
--- squid/src/fs/coss/store_dir_coss.c	3 Mar 2001 10:44:33 -0000	1.11
+++ squid/src/fs/coss/store_dir_coss.c	4 May 2001 14:41:56 -0000	1.11.8.1
@@ -849,7 +849,8 @@
 static void
 storeCossDirDone(void)
 {
-    memPoolDestroy(coss_state_pool);
+    memPoolDestroy(&coss_state_pool);
+/*  memPoolDestroy(&coss_index_pool);  XXX Should be here? */
     coss_initialised = 0;
 }
 
Index: squid/src/fs/diskd/store_dir_diskd.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/diskd/store_dir_diskd.c,v
retrieving revision 1.21.6.1
retrieving revision 1.21.6.2
diff -u -r1.21.6.1 -r1.21.6.2
--- squid/src/fs/diskd/store_dir_diskd.c	5 Apr 2001 07:35:48 -0000	1.21.6.1
+++ squid/src/fs/diskd/store_dir_diskd.c	4 May 2001 14:41:56 -0000	1.21.6.2
@@ -1924,7 +1924,7 @@
 static void
 storeDiskdDirDone(void)
 {
-    memPoolDestroy(diskd_state_pool);
+    memPoolDestroy(&diskd_state_pool);
     diskd_initialised = 0;
 }
 
Index: squid/src/fs/ufs/store_dir_ufs.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/ufs/store_dir_ufs.c,v
retrieving revision 1.16
retrieving revision 1.16.6.1
diff -u -r1.16 -r1.16.6.1
--- squid/src/fs/ufs/store_dir_ufs.c	16 Mar 2001 17:22:14 -0000	1.16
+++ squid/src/fs/ufs/store_dir_ufs.c	4 May 2001 14:41:57 -0000	1.16.6.1
@@ -1674,7 +1674,7 @@
 static void
 storeUfsDirDone(void)
 {
-    memPoolDestroy(ufs_state_pool);
+    memPoolDestroy(&ufs_state_pool);
     ufs_initialised = 0;
 }
 
Index: squid/src/repl/lru/store_repl_lru.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/repl/lru/store_repl_lru.c,v
retrieving revision 1.7.8.1
retrieving revision 1.7.8.2
diff -u -r1.7.8.1 -r1.7.8.2
--- squid/src/repl/lru/store_repl_lru.c	9 Apr 2001 11:38:22 -0000	1.7.8.1
+++ squid/src/repl/lru/store_repl_lru.c	4 May 2001 14:41:57 -0000	1.7.8.2
@@ -266,7 +266,7 @@
     /* Initialize */
     if (!lru_node_pool) {
 	lru_node_pool = memPoolCreate("LRU policy node", sizeof(LruNode));
-	memPoolTune(lru_node_pool, 512 * 1024, 0);
+	memPoolSetChunkSize(lru_node_pool, 512 * 1024);
     }
     /* Allocate the needed structures */
     lru_data = xcalloc(1, sizeof(*lru_data));
