mempool conversion for commit

From: Adrian Chadd <adrian@dont-contact.us>
Date: Mon, 16 Oct 2000 05:38:46 +0800

This is the first set of mempool additions thanks to Andres, with a touch
of tidyups in the aufs code. I'd like to commit this over the next couple
days so we can all continue on our merry ways .. I'm running this code
against a 100req/sec polygraph load here and over the past 12 hours it
hasn't barfed, and memory usage hasn't gone wacky.

Can someone just double-check the sanity here before I commit ?

Thanks!

Adrian

----- Forwarded message from Adrian Chadd <adrian@nympho.cacheboy.net> -----

Date: Sun, 15 Oct 2000 23:33:12 +0200 (CEST)
From: Adrian Chadd <adrian@nympho.cacheboy.net>
To: adrian@creative.net.au

? config.log
? config.cache
? config.status
? makefile
? auth_modules/Makefile
? auth_modules/LDAP/Makefile
? auth_modules/MSNT/Makefile
? auth_modules/NCSA/Makefile
? auth_modules/PAM/Makefile
? auth_modules/SMB/Makefile
? auth_modules/getpwnam/Makefile
? contrib/Makefile
? errors/Makefile
? icons/Makefile
? include/config.h
? include/autoconf.h
? lib/Makefile
? scripts/Makefile
? scripts/RunCache
? scripts/RunAccel
? src/cf.data
? src/Makefile
? src/cf_gen_defines.h
? src/cf_gen
? src/cf_parser.c
? src/squid.conf
? src/globals.c
? src/repl_modules.c
? src/store_modules.c
? src/string_arrays.c
? src/squid
? src/client
? src/unlinkd
? src/cachemgr.cgi
? src/fs/Makefile
? src/fs/aufs/foo
? src/fs/aufs/Makefile
? src/fs/coss/Makefile
? src/fs/diskd/Makefile
? src/fs/diskd/diskd
? src/fs/ufs/Makefile
? src/repl/Makefile
? src/repl/stamp
? src/repl/lru/Makefile
Index: include/util.h
===================================================================
RCS file: /server/cvs-server/squid/squid/include/util.h,v
retrieving revision 1.54
diff -u -r1.54 util.h
--- include/util.h 1999/10/04 05:04:49 1.54
+++ include/util.h 2000/10/15 21:31:00
@@ -85,7 +85,7 @@
 extern void rfc1738_unescape(char *);
 
 #if XMALLOC_STATISTICS
-extern void malloc_statistics(void (*)(int, int, void *), void *);
+extern void malloc_statistics(void (*)(int, int, int, void *), void *);
 #endif
 
 #if XMALLOC_TRACE
Index: lib/Array.c
===================================================================
RCS file: /server/cvs-server/squid/squid/lib/Array.c,v
retrieving revision 1.5
diff -u -r1.5 Array.c
--- lib/Array.c 2000/03/27 21:56:21 1.5
+++ lib/Array.c 2000/10/15 21:31:01
@@ -50,6 +50,10 @@
 #include "util.h"
 #include "Array.h"
 
+#include "../src/enums.h"
+extern void *memAllocate(mem_type);
+extern void memFree(void *p, int type);
+
 static void arrayGrow(Array * a, int min_capacity);
 
 Array *
Index: lib/util.c
===================================================================
RCS file: /server/cvs-server/squid/squid/lib/util.c,v
retrieving revision 1.71
diff -u -r1.71 util.c
--- lib/util.c 2000/08/19 06:10:00 1.71
+++ lib/util.c 2000/10/15 21:31:01
@@ -106,19 +106,34 @@
 
 #if XMALLOC_STATISTICS
 #define DBG_MAXSIZE (1024*1024)
+#define DBG_SPLIT (256) /* mallocs below this value are tracked with DBG_GRAIN_SM precision instead of DBG_GRAIN */
 #define DBG_GRAIN (16)
-#define DBG_MAXINDEX (DBG_MAXSIZE/DBG_GRAIN)
-#define DBG_INDEX(sz) (sz<DBG_MAXSIZE?(sz+DBG_GRAIN-1)/DBG_GRAIN:DBG_MAXINDEX)
+#define DBG_GRAIN_SM (4)
+#define DBG_OFFSET (DBG_SPLIT/DBG_GRAIN_SM - DBG_SPLIT/DBG_GRAIN )
+#define DBG_MAXINDEX (DBG_MAXSIZE/DBG_GRAIN + DBG_OFFSET)
+// #define DBG_INDEX(sz) (sz<DBG_MAXSIZE?(sz+DBG_GRAIN-1)/DBG_GRAIN:DBG_MAXINDEX)
 static int malloc_sizes[DBG_MAXINDEX + 1];
+static int malloc_histo[DBG_MAXINDEX + 1];
 static int dbg_stat_init = 0;
 
+static int
+DBG_INDEX(int sz)
+{
+ if (sz >= DBG_MAXSIZE)
+ return DBG_MAXINDEX;
+
+ if (sz <= DBG_SPLIT)
+ return (sz+DBG_GRAIN_SM-1)/DBG_GRAIN_SM;
+
+ return (sz+DBG_GRAIN-1)/DBG_GRAIN + DBG_OFFSET;
+}
 
 static void
 stat_init(void)
 {
     int i;
     for (i = 0; i <= DBG_MAXINDEX; i++)
- malloc_sizes[i] = 0;
+ malloc_sizes[i] = malloc_histo[i] = 0;
     dbg_stat_init = 1;
 }
 
@@ -131,11 +146,15 @@
 }
 
 void
-malloc_statistics(void (*func) (int, int, void *), void *data)
+malloc_statistics(void (*func) (int, int, int, void *), void *data)
 {
     int i;
- for (i = 0; i <= DBG_MAXSIZE; i += DBG_GRAIN)
- func(i, malloc_sizes[DBG_INDEX(i)], data);
+ for (i = 0; i <= DBG_SPLIT; i += DBG_GRAIN_SM)
+ func(i, malloc_sizes[DBG_INDEX(i)], malloc_histo[DBG_INDEX(i)], data);
+ i -= DBG_GRAIN_SM;
+ for (i = i; i <= DBG_MAXSIZE; i += DBG_GRAIN)
+ func(i, malloc_sizes[DBG_INDEX(i)], malloc_histo[DBG_INDEX(i)], data);
+ xmemcpy(&malloc_histo, &malloc_sizes, sizeof(malloc_sizes));
 }
 #endif /* XMALLOC_STATISTICS */
 
Index: src/MemBuf.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/MemBuf.c,v
retrieving revision 1.25
diff -u -r1.25 MemBuf.c
--- src/MemBuf.c 2000/06/06 19:34:30 1.25
+++ src/MemBuf.c 2000/10/15 21:31:02
@@ -317,6 +317,14 @@
         mb->buf = memAllocate(MEM_8K_BUF);
         mb->freefunc = &memFree8K;
         break;
+ case 16384:
+ mb->buf = memAllocate(MEM_16K_BUF);
+ mb->freefunc = &memFree16K;
+ break;
+ case 32768:
+ mb->buf = memAllocate(MEM_32K_BUF);
+ mb->freefunc = &memFree32K;
+ break;
     default:
         /* recycle if old buffer was not "pool"ed */
         if (old_mb.freefunc == &xfree) {
Index: src/MemPool.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/MemPool.c,v
retrieving revision 1.24
diff -u -r1.24 MemPool.c
--- src/MemPool.c 2000/10/09 01:48:30 1.24
+++ src/MemPool.c 2000/10/15 21:31:03
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MemPool.c,v 1.24 2000/10/09 01:48:30 adrian Exp $
+ * $Id: MemPool.c,v 1.23 2000/10/05 23:01:40 wessels Exp $
  *
  * DEBUG: section 63 Low Level Memory Pool Management
  * AUTHOR: Alex Rousskov
@@ -63,7 +63,6 @@
 static void memPoolShrink(MemPool * pool, ssize_t new_limit);
 
 
-
 static double
 toMB(size_t size)
 {
@@ -163,7 +162,7 @@
     int alloc_count, int inuse_count, int idle_count, StoreEntry * e)
 {
     assert(pm);
- storeAppendPrintf(e, "%d\t %d\t %d\t %.2f\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\n",
+ storeAppendPrintf(e, "%d\t %d\t %d\t %.2f\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %.2f\t %.2f\t %.2f\t %d\n",
     /* alloc */
         alloc_count,
         toKB(obj_size * pm->alloc.level),
@@ -181,9 +180,10 @@
         toKB(obj_size * pm->idle.hwater_level),
     /* (int)rint(xpercent(pm->idle.level, pm->alloc.level)), */
     /* saved */
- xpercentInt(pm->saved.count, mem_traffic_volume.count),
- xpercentInt(obj_size * gb_to_double(&pm->saved), gb_to_double(&mem_traffic_volume)),
- xpercentInt(pm->saved.count, pm->total.count),
+ pm->saved.count,
+ xpercent(pm->saved.count, mem_traffic_volume.count),
+ xpercent(obj_size * gb_to_double(&pm->saved), gb_to_double(&mem_traffic_volume)),
+ xpercent(pm->saved.count, pm->total.count),
         pm->total.count);
 }
 
@@ -346,13 +346,14 @@
     storeAppendPrintf(e, "Current memory usage:\n");
     /* heading */
     storeAppendPrintf(e, "Pool\t Obj Size\t"
- "Allocated\t\t\t\t\t In Use\t\t\t\t Idle\t\t\t Allocations Saved\t\t Hit Rate\tTotal\n"
+ "Allocated\t\t\t\t\t In Use\t\t\t\t Idle\t\t\t Allocations Saved\t\t\t Hit Rate\t\n"
         " \t (bytes)\t"
         "(#)\t (KB)\t high (KB)\t high (hrs)\t impact (%%total)\t"
         "(#)\t (KB)\t high (KB)\t portion (%%alloc)\t"
         "(#)\t (KB)\t high (KB)\t"
- "(%%number)\t (%%volume)\t"
- "(%%number)\t (number)\t"
+ "(number)\t (%%num)\t (%%vol)\t"
+ "(%%num)\t"
+ "(number)"
         "\n");
     /* main table */
     for (i = 0; i < Pools.count; i++) {
Index: src/cbdata.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/cbdata.c,v
retrieving revision 1.29
diff -u -r1.29 cbdata.c
--- src/cbdata.c 2000/03/06 16:23:29 1.29
+++ src/cbdata.c 2000/10/15 21:31:03
@@ -87,6 +87,7 @@
 static HASHHASH cbdata_hash;
 static void cbdataReallyFree(cbdata * c);
 static OBJH cbdataDump;
+static MemPool *cbdata_pool = NULL;
 
 static int
 cbdata_cmp(const void *p1, const void *p2)
@@ -105,6 +106,9 @@
 cbdataInit(void)
 {
     debug(45, 3) ("cbdataInit\n");
+ if (cbdata_pool == NULL) {
+ cbdata_pool = memPoolCreate("cbdata", sizeof(cbdata));
+ }
     htable = hash_create(cbdata_cmp, 1 << 8, cbdata_hash);
     cachemgrRegister("cbdata",
         "Callback Data Registry Contents",
@@ -123,7 +127,7 @@
     debug(45, 3) ("cbdataAdd: %p\n", p);
     assert(htable != NULL);
     assert(hash_lookup(htable, p) == NULL);
- c = xcalloc(1, sizeof(cbdata));
+ c = memPoolAlloc(cbdata_pool);
     c->key = p;
     c->valid = 1;
     c->unlock_func = unlock_func;
@@ -144,7 +148,7 @@
     int id = c->id;
     hash_remove_link(htable, (hash_link *) c);
     cbdataCount--;
- xfree(c);
+ memPoolFree(cbdata_pool,c);
     debug(45, 3) ("cbdataReallyFree: Freeing %p\n", p);
     if (unlock_func)
         unlock_func(p, id);
Index: src/client_side.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/client_side.c,v
retrieving revision 1.505
diff -u -r1.505 client_side.c
--- src/client_side.c 2000/10/04 17:09:24 1.505
+++ src/client_side.c 2000/10/15 21:31:09
@@ -70,7 +70,6 @@
 
 static const char *const crlf = "\r\n";
 
-#define REQUEST_BUF_SIZE 4096
 #define FAILURE_MODE_TIME 300
 
 /* Local functions */
@@ -799,7 +798,10 @@
         assert(connState->chr != connState->chr->next);
         httpRequestFree(http);
     }
- safe_free(connState->in.buf);
+ if (connState->in.size == CLIENT_REQ_BUF_SZ)
+ memFree(connState->in.buf, MEM_CLIENT_REQ_BUF);
+ else
+ safe_free(connState->in.buf);
     /* XXX account connState->in.buf */
     pconnHistCount(0, connState->nrequests);
     cbdataFree(connState);
@@ -2184,8 +2186,8 @@
 static clientHttpRequest *
 parseHttpRequestAbort(ConnStateData * conn, const char *uri)
 {
- clientHttpRequest *http = xcalloc(1, sizeof(clientHttpRequest));
- cbdataAdd(http, cbdataXfree, 0);
+ clientHttpRequest *http = memAllocate(MEM_CLIENTHTTPREQUEST);
+ cbdataAdd(http, memFree, MEM_CLIENTHTTPREQUEST);
     http->conn = conn;
     http->start = current_time;
     http->req_sz = conn->in.offset;
@@ -2318,8 +2320,8 @@
     assert(prefix_sz <= conn->in.offset);
 
     /* Ok, all headers are received */
- http = xcalloc(1, sizeof(clientHttpRequest));
- cbdataAdd(http, cbdataXfree, 0);
+ http = memAllocate(MEM_CLIENTHTTPREQUEST);
+ cbdataAdd(http, memFree, MEM_CLIENTHTTPREQUEST);
     http->http_ver = http_ver;
     http->conn = conn;
     http->start = current_time;
@@ -2462,6 +2464,7 @@
     int k;
     request_t *request = NULL;
     int size;
+ void *p;
     method_t method;
     clientHttpRequest *http = NULL;
     clientHttpRequest **H = NULL;
@@ -2695,8 +2698,14 @@
                     return;
                 }
                 /* Grow the request memory area to accomodate for a large request */
- conn->in.size += REQUEST_BUF_SIZE;
- conn->in.buf = xrealloc(conn->in.buf, conn->in.size);
+ conn->in.size += CLIENT_REQ_BUF_SZ;
+ if (conn->in.size == 2 * CLIENT_REQ_BUF_SZ) {
+ p = conn->in.buf; /* get rid of fixed size Pooled buffer */
+ conn->in.buf = xcalloc(2, CLIENT_REQ_BUF_SZ);
+ xmemcpy(conn->in.buf, p, CLIENT_REQ_BUF_SZ);
+ memFree(p, MEM_CLIENT_REQ_BUF);
+ } else
+ conn->in.buf = xrealloc(conn->in.buf, conn->in.size);
                 /* XXX account conn->in.buf */
                 debug(33, 3) ("Handling a large request, offset=%d inbufsize=%d\n",
                     (int) conn->in.offset, conn->in.size);
@@ -2800,14 +2809,14 @@
         }
         debug(33, 4) ("httpAccept: FD %d: accepted\n", fd);
         connState = memAllocate(MEM_CONNSTATEDATA);
+ cbdataAdd(connState, memFree, MEM_CONNSTATEDATA);
         connState->peer = peer;
         connState->log_addr = peer.sin_addr;
         connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
         connState->me = me;
         connState->fd = fd;
- connState->in.size = REQUEST_BUF_SIZE;
- connState->in.buf = xcalloc(connState->in.size, 1);
- cbdataAdd(connState, memFree, MEM_CONNSTATEDATA);
+ connState->in.size = CLIENT_REQ_BUF_SZ;
+ connState->in.buf = memAllocate(MEM_CLIENT_REQ_BUF);
         /* XXX account connState->in.buf */
         comm_add_close_handler(fd, connStateFree, connState);
         if (Config.onoff.log_fqdn)
Index: src/comm.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/comm.c,v
retrieving revision 1.309
diff -u -r1.309 comm.c
--- src/comm.c 2000/10/10 02:22:25 1.309
+++ src/comm.c 2000/10/15 21:31:11
@@ -73,6 +73,7 @@
 
 static MemPool *comm_write_pool = NULL;
 static MemPool *conn_state_pool = NULL;
+static MemPool *conn_close_pool = NULL;
 
 static void
 CommWriteStateCallbackAndFree(int fd, int code)
@@ -533,7 +534,7 @@
         if (cbdataValid(ch->data))
             ch->handler(fd, ch->data);
         cbdataUnlock(ch->data);
- safe_free(ch);
+ memPoolFree(conn_close_pool, ch); // AAA
     }
 }
 
@@ -653,7 +654,7 @@
 void
 comm_add_close_handler(int fd, PF * handler, void *data)
 {
- close_handler *new = xmalloc(sizeof(*new));
+ close_handler *new = memPoolAlloc(conn_close_pool); // AAA
     close_handler *c;
     debug(5, 5) ("comm_add_close_handler: FD %d, handler=%p, data=%p\n",
         fd, handler, data);
@@ -684,7 +685,7 @@
     else
         fd_table[fd].close_handler = p->next;
     cbdataUnlock(p->data);
- safe_free(p);
+ memPoolFree(conn_close_pool,p); // AAA
 }
 
 static void
@@ -785,6 +786,7 @@
     RESERVED_FD = XMIN(100, Squid_MaxFD / 4);
     comm_write_pool = memPoolCreate("CommWriteStateData", sizeof(CommWriteStateData));
     conn_state_pool = memPoolCreate("ConnectStateData", sizeof(ConnectStateData));
+ conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler));
 }
 
 /* Write to FD. */
Index: src/defines.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/defines.h,v
retrieving revision 1.82
diff -u -r1.82 defines.h
--- src/defines.h 2000/07/18 06:16:41 1.82
+++ src/defines.h 2000/10/15 21:31:12
@@ -172,6 +172,7 @@
 
 #define AUTH_MSG_SZ 4096
 #define HTTP_REPLY_BUF_SZ 4096
+#define CLIENT_REQ_BUF_SZ 4096
 
 #if !defined(ERROR_BUF_SZ) && defined(MAX_URL)
 #define ERROR_BUF_SZ (MAX_URL << 2)
Index: src/disk.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/disk.c,v
retrieving revision 1.150
diff -u -r1.150 disk.c
--- src/disk.c 2000/06/27 22:06:00 1.150
+++ src/disk.c 2000/10/15 21:31:12
@@ -146,7 +146,7 @@
         len = 0;
         for (q = fdd->write_q; q != NULL; q = q->next)
             len += q->len - q->buf_offset;
- wq = xcalloc(1, sizeof(dwrite_q));
+ wq = memAllocate(MEM_DWRITE_Q);
         wq->buf = xmalloc(len);
         wq->len = 0;
         wq->buf_offset = 0;
@@ -160,7 +160,7 @@
             fdd->write_q = q->next;
             if (q->free_func)
                 (q->free_func) (q->buf);
- safe_free(q);
+ if (q) { memFree(q, MEM_DWRITE_Q); q = NULL; }
         } while (fdd->write_q != NULL);
         fdd->write_q_tail = wq;
         fdd->write_q = wq;
@@ -224,7 +224,7 @@
                 fdd->write_q = q->next;
                 if (q->free_func)
                     (q->free_func) (q->buf);
- safe_free(q);
+ if (q) { memFree(q, MEM_DWRITE_Q); q = NULL; }
             } while ((q = fdd->write_q));
         }
         len = 0;
@@ -241,7 +241,7 @@
             fdd->write_q = q->next;
             if (q->free_func)
                 (q->free_func) (q->buf);
- safe_free(q);
+ if (q) { memFree(q, MEM_DWRITE_Q); q = NULL; }
         }
     }
     if (fdd->write_q == NULL) {
@@ -295,7 +295,7 @@
     assert(fd >= 0);
     assert(F->flags.open);
     /* if we got here. Caller is eligible to write. */
- wq = xcalloc(1, sizeof(dwrite_q));
+ wq = memAllocate(MEM_DWRITE_Q);
     wq->file_offset = file_offset;
     wq->buf = ptr_to_buf;
     wq->len = len;
Index: src/enums.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/enums.h,v
retrieving revision 1.173
diff -u -r1.173 enums.h
--- src/enums.h 2000/10/04 00:24:17 1.173
+++ src/enums.h 2000/10/15 21:31:13
@@ -506,6 +506,9 @@
     MEM_2K_BUF,
     MEM_4K_BUF,
     MEM_8K_BUF,
+ MEM_16K_BUF,
+ MEM_32K_BUF,
+ MEM_64K_BUF,
     MEM_ACCESSLOGENTRY,
     MEM_ACL,
     MEM_ACLCHECK_T,
@@ -529,6 +532,7 @@
 #if USE_CACHE_DIGESTS
     MEM_DIGEST_FETCH_STATE,
 #endif
+ MEM_LINK_LIST,
     MEM_DLINK_LIST,
     MEM_DLINK_NODE,
     MEM_DNSSERVER_T,
@@ -598,6 +602,11 @@
     MEM_IDNS_QUERY,
 #endif
     MEM_EVENT,
+ MEM_TLV,
+ MEM_SWAP_LOG_DATA,
+ MEM_GEN_CBDATA,
+ MEM_PUMP_STATE_DATA,
+ MEM_CLIENT_REQ_BUF,
     MEM_MAX
 } mem_type;
 
Index: src/fqdncache.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fqdncache.c,v
retrieving revision 1.140
diff -u -r1.140 fqdncache.c
--- src/fqdncache.c 2000/10/04 19:34:13 1.140
+++ src/fqdncache.c 2000/10/15 21:31:15
@@ -367,9 +367,9 @@
     f->handlerData = handlerData;
     cbdataLock(handlerData);
     f->request_time = current_time;
- c = xcalloc(1, sizeof(*c));
+ c = memAllocate(MEM_GEN_CBDATA);
     c->data = f;
- cbdataAdd(c, cbdataXfree, 0);
+ cbdataAdd(c, memFree, MEM_GEN_CBDATA);
 #if USE_DNSSERVERS
     dnsSubmit(f->name, fqdncacheHandleReply, c);
 #else
Index: src/ipcache.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/ipcache.c,v
retrieving revision 1.225
diff -u -r1.225 ipcache.c
--- src/ipcache.c 2000/10/07 16:10:13 1.225
+++ src/ipcache.c 2000/10/15 21:31:17
@@ -413,9 +413,9 @@
     i->handlerData = handlerData;
     cbdataLock(handlerData);
     i->request_time = current_time;
- c = xcalloc(1, sizeof(*c));
+ c = memAllocate(MEM_GEN_CBDATA);
     c->data = i;
- cbdataAdd(c, cbdataXfree, 0);
+ cbdataAdd(c, memFree, MEM_GEN_CBDATA);
 #if USE_DNSSERVERS
     dnsSubmit(i->name, ipcacheHandleReply, c);
 #else
Index: src/main.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/main.c,v
retrieving revision 1.317
diff -u -r1.317 main.c
--- src/main.c 2000/07/16 01:11:49 1.317
+++ src/main.c 2000/10/15 21:31:18
@@ -621,11 +621,11 @@
         if (!ConfigFile)
             ConfigFile = xstrdup(DefaultConfigFile);
         assert(!configured_once);
+ memInit(); /* memInit is required for config parsing */
         cbdataInit();
 #if USE_LEAKFINDER
         leakInit();
 #endif
- memInit(); /* memInit is required for config parsing */
         eventInit(); /* eventInit() is required for config parsing */
         storeFsInit(); /* required for config parsing */
         parse_err = parseConfigFile(ConfigFile);
Index: src/mem.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/mem.c,v
retrieving revision 1.48
diff -u -r1.48 mem.c
--- src/mem.c 2000/10/04 00:24:17 1.48
+++ src/mem.c 2000/10/15 21:31:19
@@ -189,6 +189,9 @@
     memDataInit(MEM_2K_BUF, "2K Buffer", 2048, 10);
     memDataInit(MEM_4K_BUF, "4K Buffer", 4096, 10);
     memDataInit(MEM_8K_BUF, "8K Buffer", 8192, 10);
+ memDataInit(MEM_16K_BUF, "16K Buffer", 16384, 10);
+ memDataInit(MEM_32K_BUF, "32K Buffer", 32768, 10);
+ memDataInit(MEM_64K_BUF, "64K Buffer", 65536, 10);
     memDataInit(MEM_CLIENT_SOCK_BUF, "Client Socket Buffer", CLIENT_SOCK_SZ, 0);
     memDataInit(MEM_ACCESSLOGENTRY, "AccessLogEntry",
         sizeof(AccessLogEntry), 10);
@@ -217,6 +220,7 @@
 #if USE_CACHE_DIGESTS
     memDataInit(MEM_DIGEST_FETCH_STATE, "DigestFetchState", sizeof(DigestFetchState), 0);
 #endif
+ memDataInit(MEM_LINK_LIST, "link_list", sizeof(link_list), 10);
     memDataInit(MEM_DLINK_LIST, "dlink_list", sizeof(dlink_list), 10);
     memDataInit(MEM_DLINK_NODE, "dlink_node", sizeof(dlink_node), 10);
     memDataInit(MEM_DNSSERVER_T, "dnsserver_t", sizeof(dnsserver_t), 0);
@@ -285,6 +289,12 @@
     memDataInit(MEM_HELPER_SERVER, "helper_server",
         sizeof(helper_server), 0);
     memDataInit(MEM_STORE_IO, "storeIOState", sizeof(storeIOState), 0);
+ memDataInit(MEM_TLV, "storeSwapTLV", sizeof(tlv), 0);
+ memDataInit(MEM_GEN_CBDATA, "generic_cbdata", sizeof(generic_cbdata), 0);
+ memDataInit(MEM_PUMP_STATE_DATA, "PumpStateData", sizeof(PumpStateData), 0);
+ memDataInit(MEM_CLIENT_REQ_BUF, "clientRequestBuffer", CLIENT_REQ_BUF_SZ, 0);
+ memDataInit(MEM_SWAP_LOG_DATA, "storeSwapLogData", sizeof(storeSwapLogData), 0);
+
     /* init string pools */
     for (i = 0; i < mem_str_pool_count; i++) {
         StrPools[i].pool = memPoolCreate(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size);
@@ -342,4 +352,22 @@
 memFree8K(void *p)
 {
     memFree(p, MEM_8K_BUF);
+}
+
+void
+memFree16K(void *p)
+{
+ memFree(p, MEM_16K_BUF);
+}
+
+void
+memFree32K(void *p)
+{
+ memFree(p, MEM_32K_BUF);
+}
+
+void
+memFree64K(void *p)
+{
+ memFree(p, MEM_64K_BUF);
 }
Index: src/pconn.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/pconn.c,v
retrieving revision 1.27
diff -u -r1.27 pconn.c
--- src/pconn.c 2000/06/27 22:06:03 1.27
+++ src/pconn.c 2000/10/15 21:31:20
@@ -43,6 +43,7 @@
     int nfds;
 };
 
+#define PCONN_FDS_SZ 8 /* pconn set size, increase for better memcache hit rate */
 #define PCONN_HIST_SZ (1<<16)
 int client_pconn_hist[PCONN_HIST_SZ];
 int server_pconn_hist[PCONN_HIST_SZ];
@@ -55,6 +56,8 @@
 static void pconnDelete(struct _pconn *p);
 static void pconnRemoveFD(struct _pconn *p, int fd);
 static OBJH pconnHistDump;
+static MemPool *pconn_data_pool = NULL;
+static MemPool *pconn_fds_pool = NULL;
 
 static const char *
 pconnKey(const char *host, u_short port)
@@ -67,10 +70,10 @@
 static struct _pconn *
 pconnNew(const char *key)
 {
- struct _pconn *p = xcalloc(1, sizeof(struct _pconn));
+ struct _pconn *p = memPoolAlloc(pconn_data_pool);
     p->key = xstrdup(key);
- p->nfds_alloc = 2;
- p->fds = xcalloc(p->nfds_alloc, sizeof(int));
+ p->nfds_alloc = PCONN_FDS_SZ;
+ p->fds = memPoolAlloc(pconn_fds_pool);
     debug(48, 3) ("pconnNew: adding %s\n", p->key);
     hash_join(table, (hash_link *) p);
     return p;
@@ -81,9 +84,12 @@
 {
     debug(48, 3) ("pconnDelete: deleting %s\n", p->key);
     hash_remove_link(table, (hash_link *) p);
- xfree(p->fds);
+ if (p->nfds_alloc == PCONN_FDS_SZ)
+ memPoolFree(pconn_fds_pool,p->fds);
+ else
+ xfree(p->fds);
     xfree(p->key);
- xfree(p);
+ memPoolFree(pconn_data_pool, p);
 }
 
 static void
@@ -168,6 +174,9 @@
         client_pconn_hist[i] = 0;
         server_pconn_hist[i] = 0;
     }
+ pconn_data_pool = memPoolCreate("pconn_data", sizeof(struct _pconn));
+ pconn_fds_pool = memPoolCreate("pconn_fds", PCONN_FDS_SZ * sizeof(int));
+
     cachemgrRegister("pconn",
         "Persistent Connection Utilization Histograms",
         pconnHistDump, 0, 1);
@@ -200,7 +209,10 @@
         old = p->fds;
         p->fds = xmalloc(p->nfds_alloc * sizeof(int));
         xmemcpy(p->fds, old, p->nfds * sizeof(int));
- xfree(old);
+ if (p->nfds == PCONN_FDS_SZ)
+ memPoolFree(pconn_fds_pool,old);
+ else
+ xfree(old);
     }
     p->fds[p->nfds++] = fd;
     commSetSelect(fd, COMM_SELECT_READ, pconnRead, p, 0);
Index: src/peer_select.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/peer_select.c,v
retrieving revision 1.108
diff -u -r1.108 peer_select.c
--- src/peer_select.c 2000/05/02 18:37:59 1.108
+++ src/peer_select.c 2000/10/15 21:31:20
@@ -134,12 +134,12 @@
     PSC * callback,
     void *callback_data)
 {
- ps_state *psstate = xcalloc(1, sizeof(ps_state));
+ ps_state *psstate = memAllocate(MEM_PS_STATE);
     if (entry)
         debug(44, 3) ("peerSelect: %s\n", storeUrl(entry));
     else
         debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]);
- cbdataAdd(psstate, cbdataXfree, 0);
+ cbdataAdd(psstate, memFree, MEM_PS_STATE);
     psstate->request = requestLink(request);
     psstate->entry = entry;
     psstate->callback = callback;
Index: src/protos.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/protos.h,v
retrieving revision 1.382
diff -u -r1.382 protos.h
--- src/protos.h 2000/10/10 18:15:30 1.382
+++ src/protos.h 2000/10/15 21:31:23
@@ -767,6 +767,9 @@
 extern void memFree2K(void *);
 extern void memFree4K(void *);
 extern void memFree8K(void *);
+extern void memFree16K(void *);
+extern void memFree32K(void *);
+extern void memFree64K(void *);
 extern int memInUse(mem_type);
 extern size_t memTotalAllocated(void);
 extern void memDataInit(mem_type, const char *, size_t, int);
Index: src/pump.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/pump.c,v
retrieving revision 1.84
diff -u -r1.84 pump.c
--- src/pump.c 2000/06/27 22:06:03 1.84
+++ src/pump.c 2000/10/15 21:31:24
@@ -37,28 +37,8 @@
 
 #define PUMP_MAXBUFFER 2*SQUID_UDP_SO_SNDBUF
 
-struct _PumpStateData {
- FwdState *fwd;
- request_t *req;
- store_client *sc; /* The store client we're using */
- int c_fd; /* client fd */
- int s_fd; /* server end */
- int rcvd; /* bytes received from client */
- int sent; /* bytes sent to server */
- StoreEntry *request_entry; /* the request entry */
- StoreEntry *reply_entry; /* the reply entry */
- CWCB *callback; /* what to do when we finish sending */
- void *cbdata; /* callback data passed to callback func */
- struct {
- int closing:1;
- } flags;
- struct _PumpStateData *next;
-};
-
 #define PUMP_FLAG_CLOSING 0x01
 
-typedef struct _PumpStateData PumpStateData;
-
 static PumpStateData *pump_head = NULL;
 
 static PF pumpReadFromClient;
@@ -74,8 +54,8 @@
 pumpInit(int fd, request_t * r, char *uri)
 {
     request_flags flags;
+ PumpStateData *p = memAllocate(MEM_PUMP_STATE_DATA);
     LOCAL_ARRAY(char, new_key, MAX_URL + 8);
- PumpStateData *p = xcalloc(1, sizeof(PumpStateData));
     debug(61, 3) ("pumpInit: FD %d, uri=%s\n", fd, uri);
     /*
      * create a StoreEntry which will buffer the data
@@ -90,7 +70,7 @@
     flags = null_request_flags;
     flags.nocache = 1;
     snprintf(new_key, MAX_URL + 5, "%s|Pump", uri);
- cbdataAdd(p, cbdataXfree, 0);
+ cbdataAdd(p, memFree, MEM_PUMP_STATE_DATA);
     p->request_entry = storeCreateEntry(new_key, new_key, flags, r->method);
     p->sc = storeClientListAdd(p->request_entry, p);
     EBIT_SET(p->request_entry->flags, ENTRY_DONT_LOG);
Index: src/stat.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/stat.c,v
retrieving revision 1.338
diff -u -r1.338 stat.c
--- src/stat.c 2000/10/06 00:58:39 1.338
+++ src/stat.c 2000/10/15 21:31:28
@@ -79,7 +79,9 @@
 static OBJH statClientRequests;
 
 #ifdef XMALLOC_STATISTICS
-static void info_get_mallstat(int, int, void *);
+static void info_get_mallstat(int, int, int, void *);
+static double xm_time;
+static double xm_deltat;
 #endif
 
 StatCounters CountHist[N_COUNT_HIST];
@@ -388,11 +390,11 @@
 
 #ifdef XMALLOC_STATISTICS
 static void
-info_get_mallstat(int size, int number, void *data)
+info_get_mallstat(int size, int number, int oldnum, void *data)
 {
     StoreEntry *sentry = data;
     if (number > 0)
- storeAppendPrintf(sentry, "\t%d = %d\n", size, number);
+ storeAppendPrintf(sentry, "%d\t %d\t %d\t %.1f\n", size, number, number - oldnum , xdiv((number - oldnum),xm_deltat));
 }
 #endif
 
@@ -622,7 +624,10 @@
         n_disk_objects);
 
 #if XMALLOC_STATISTICS
- storeAppendPrintf(sentry, "Memory allocation statistics\n");
+ xm_deltat = current_dtime - xm_time;
+ xm_time = current_dtime;
+ storeAppendPrintf(sentry, "\nMemory allocation statistics\n");
+ storeAppendPrintf(sentry, "Allocation Size\t Alloc Count\t Alloc Delta\t Allocs/sec \n");
     malloc_statistics(info_get_mallstat, sentry);
 #endif
 }
Index: src/stmem.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/stmem.c,v
retrieving revision 1.65
diff -u -r1.65 stmem.c
--- src/stmem.c 2000/03/06 16:23:34 1.65
+++ src/stmem.c 2000/10/15 21:31:28
@@ -43,7 +43,7 @@
         mem->head = p->next;
         memFree(p->data, MEM_STMEM_BUF);
         store_mem_size -= SM_PAGE_SIZE;
- safe_free(p);
+ if (p) { memFree(p, MEM_MEM_NODE); p = NULL; }
     }
     mem->head = mem->tail = NULL;
     mem->origin_offset = 0;
@@ -67,7 +67,7 @@
             current_offset += lastp->len;
             memFree(lastp->data, MEM_STMEM_BUF);
             store_mem_size -= SM_PAGE_SIZE;
- safe_free(lastp);
+ if (lastp) { memFree(lastp, MEM_MEM_NODE); lastp = NULL; }
         }
     }
     mem->head = p;
@@ -102,7 +102,7 @@
     }
     while (len > 0) {
         len_to_copy = XMIN(len, SM_PAGE_SIZE);
- p = xcalloc(1, sizeof(mem_node));
+ p = memAllocate(MEM_MEM_NODE);
         p->next = NULL;
         p->len = len_to_copy;
         p->data = memAllocate(MEM_STMEM_BUF);
Index: src/store_swapmeta.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/store_swapmeta.c,v
retrieving revision 1.11
diff -u -r1.11 store_swapmeta.c
--- src/store_swapmeta.c 2000/07/18 06:16:42 1.11
+++ src/store_swapmeta.c 2000/10/15 21:31:28
@@ -38,7 +38,7 @@
 static tlv **
 storeSwapTLVAdd(int type, const void *ptr, size_t len, tlv ** tail)
 {
- tlv *t = xcalloc(1, sizeof(tlv));
+ tlv *t = memAllocate(MEM_TLV);
     t->type = (char) type;
     t->length = (int) len;
     t->value = xmalloc(len);
@@ -54,7 +54,7 @@
     while ((t = n) != NULL) {
         n = t->next;
         xfree(t->value);
- xfree(t);
+ memFree(t, MEM_TLV);
     }
 }
 
Index: src/store_swapout.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/store_swapout.c,v
retrieving revision 1.75
diff -u -r1.75 store_swapout.c
--- src/store_swapout.c 2000/08/15 07:14:04 1.75
+++ src/store_swapout.c 2000/10/15 21:31:29
@@ -61,9 +61,9 @@
     storeSwapTLVFree(tlv_list);
     mem->swap_hdr_sz = (size_t) swap_hdr_sz;
     /* Create the swap file */
- c = xcalloc(1, sizeof(*c));
+ c = memAllocate(MEM_GEN_CBDATA);
     c->data = e;
- cbdataAdd(c, cbdataXfree, 0);
+ cbdataAdd(c, memFree, MEM_GEN_CBDATA);
     mem->swapout.sio = storeCreate(e, storeSwapOutFileNotify, storeSwapOutFileClosed, c);
     if (NULL == mem->swapout.sio) {
         e->swap_status = SWAPOUT_NONE;
Index: src/structs.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/structs.h,v
retrieving revision 1.355
diff -u -r1.355 structs.h
--- src/structs.h 2000/10/10 18:15:30 1.355
+++ src/structs.h 2000/10/15 21:31:35
@@ -1845,6 +1845,24 @@
     int zero_object_sz;
 };
 
+struct _PumpStateData {
+ FwdState *fwd;
+ request_t *req;
+ store_client *sc; /* The store client we're using */
+ int c_fd; /* client fd */
+ int s_fd; /* server end */
+ int rcvd; /* bytes received from client */
+ int sent; /* bytes sent to server */
+ StoreEntry *request_entry; /* the request entry */
+ StoreEntry *reply_entry; /* the reply entry */
+ CWCB *callback; /* what to do when we finish sending */
+ void *cbdata; /* callback data passed to callback func */
+ struct {
+ int closing:1;
+ } flags;
+ struct _PumpStateData *next;
+};
+
 /*
  * This defines an fs type
  */
Index: src/tools.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/tools.c,v
retrieving revision 1.196
diff -u -r1.196 tools.c
--- src/tools.c 2000/10/10 02:10:43 1.196
+++ src/tools.c 2000/10/15 21:31:35
@@ -858,7 +858,7 @@
 void
 linklistPush(link_list ** L, void *p)
 {
- link_list *l = xmalloc(sizeof(*l));
+ link_list *l = memAllocate(MEM_LINK_LIST);
     l->next = NULL;
     l->ptr = p;
     while (*L)
@@ -876,7 +876,7 @@
     l = *L;
     p = l->ptr;
     *L = (*L)->next;
- xfree(l);
+ memFree(l, MEM_LINK_LIST);
     return p;
 }
 
Index: src/typedefs.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/typedefs.h,v
retrieving revision 1.109
diff -u -r1.109 typedefs.h
--- src/typedefs.h 2000/10/04 00:24:18 1.109
+++ src/typedefs.h 2000/10/15 21:31:36
@@ -163,7 +163,10 @@
 typedef struct _helper_request helper_request;
 typedef struct _generic_cbdata generic_cbdata;
 typedef struct _storeIOState storeIOState;
+typedef struct _queued_read queued_read;
+typedef struct _queued_write queued_write;
 typedef struct _link_list link_list;
+typedef struct _PumpStateData PumpStateData;
 typedef struct _storefs_entry storefs_entry_t;
 typedef struct _storerepl_entry storerepl_entry_t;
 typedef struct _diskd_queue diskd_queue;
Index: src/fs/aufs/aiops.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/aufs/aiops.c,v
retrieving revision 1.2
diff -u -r1.2 aiops.c
--- src/fs/aufs/aiops.c 2000/06/27 08:33:53 1.2
+++ src/fs/aufs/aiops.c 2000/10/15 21:31:37
@@ -140,6 +140,16 @@
 static aio_thread_t *threads;
 static int aio_initialised = 0;
 
+#define AIO_LARGE_BUFS 16384
+#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
+#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
+#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
+
+static MemPool *aio_large_bufs = NULL; // 16K
+static MemPool *aio_medium_bufs = NULL; // 8K
+static MemPool *aio_small_bufs = NULL; // 4K
+static MemPool *aio_tiny_bufs = NULL; // 2K
+
 static int request_queue_len = 0;
 static MemPool *aio_request_pool = NULL;
 static aio_request_t *request_queue_head = NULL;
@@ -153,7 +163,50 @@
 static struct sched_param globsched;
 static pthread_t main_thread;
 
+static MemPool *
+aio_get_pool(int size)
+{
+ MemPool *p;
+ if (size <= AIO_LARGE_BUFS) {
+ if (size <= AIO_TINY_BUFS)
+ p = aio_tiny_bufs;
+ else if (size <= AIO_SMALL_BUFS)
+ p = aio_small_bufs;
+ else if (size <= AIO_MEDIUM_BUFS)
+ p = aio_medium_bufs;
+ else
+ p = aio_large_bufs;
+ } else
+ p = NULL;
+ return p;
+}
+
+static void *
+aio_xmalloc(int size)
+{
+ void *p;
+ MemPool *pool;
+
+ if ( (pool = aio_get_pool(size)) != NULL) {
+ p = memPoolAlloc(pool);
+ } else
+ p = xmalloc(size);
+
+ return p;
+}
+
 static void
+aio_xfree(void *p, int size)
+{
+ MemPool *pool;
+
+ if ( (pool = aio_get_pool(size)) != NULL) {
+ memPoolFree(pool, p);
+ } else
+ xfree(p);
+}
+
+static void
 aio_init(void)
 {
     int i;
@@ -206,6 +259,10 @@
 
     /* Create request pool */
     aio_request_pool = memPoolCreate("aio_request", sizeof(aio_request_t));
+ aio_large_bufs = memPoolCreate("aio_large_bufs", AIO_LARGE_BUFS);
+ aio_medium_bufs = memPoolCreate("aio_medium_bufs", AIO_MEDIUM_BUFS);
+ aio_small_bufs = memPoolCreate("aio_small_bufs", AIO_SMALL_BUFS);
+ aio_tiny_bufs = memPoolCreate("aio_tiny_bufs", AIO_TINY_BUFS);
 
     aio_initialised = 1;
 }
@@ -463,7 +520,7 @@
     case _AIO_OP_STAT:
         if (!cancelled && requestp->ret == 0)
             xmemcpy(requestp->statp, requestp->tmpstatp, sizeof(struct stat));
- xfree(requestp->tmpstatp);
+ aio_xfree(requestp->tmpstatp, sizeof(struct stat));
     case _AIO_OP_OPEN:
         if (cancelled && requestp->ret >= 0)
             /* The open() was cancelled but completed */
@@ -484,7 +541,7 @@
         if (!cancelled && requestp->ret > 0)
             xmemcpy(requestp->bufferp, requestp->tmpbufp, requestp->ret);
     case _AIO_OP_WRITE:
- xfree(requestp->tmpbufp);
+ aio_xfree(requestp->tmpbufp, requestp->buflen);
         break;
     default:
         break;
@@ -576,11 +633,7 @@
     }
     requestp->fd = fd;
     requestp->bufferp = bufp;
- if ((requestp->tmpbufp = (char *) xmalloc(bufs)) == NULL) {
- memPoolFree(aio_request_pool, requestp);
- errno = ENOMEM;
- return -1;
- }
+ requestp->tmpbufp = (char *) aio_xmalloc(bufs);
     requestp->buflen = bufs;
     requestp->offset = offset;
     requestp->whence = whence;
@@ -614,11 +667,7 @@
         return -1;
     }
     requestp->fd = fd;
- if ((requestp->tmpbufp = (char *) xmalloc(bufs)) == NULL) {
- memPoolFree(aio_request_pool, requestp);
- errno = ENOMEM;
- return -1;
- }
+ requestp->tmpbufp = (char *) aio_xmalloc(bufs);
     xmemcpy(requestp->tmpbufp, bufp, bufs);
     requestp->buflen = bufs;
     requestp->offset = offset;
@@ -682,19 +731,10 @@
         return -1;
     }
     len = strlen(path) + 1;
- if ((requestp->path = (char *) xmalloc(len)) == NULL) {
- memPoolFree(aio_request_pool, requestp);
- errno = ENOMEM;
- return -1;
- }
+ requestp->path = (char *) xmalloc(len);
     strncpy(requestp->path, path, len);
     requestp->statp = sb;
- if ((requestp->tmpstatp = (struct stat *) xmalloc(sizeof(struct stat))) == NULL) {
- xfree(requestp->path);
- memPoolFree(aio_request_pool, requestp);
- errno = ENOMEM;
- return -1;
- }
+ requestp->tmpstatp = (struct stat *) aio_xmalloc(sizeof(struct stat));
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_STAT;
     requestp->cancelled = 0;
@@ -725,11 +765,7 @@
         return -1;
     }
     len = strlen(path) + 1;
- if ((requestp->path = (char *) xmalloc(len)) == NULL) {
- memPoolFree(aio_request_pool, requestp);
- errno = ENOMEM;
- return -1;
- }
+ requestp->path = (char *) xmalloc(len);
     strncpy(requestp->path, path, len);
     requestp->resultp = resultp;
     requestp->request_type = _AIO_OP_UNLINK;
Index: src/fs/aufs/store_asyncufs.h
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/aufs/store_asyncufs.h,v
retrieving revision 1.4
diff -u -r1.4 store_asyncufs.h
--- src/fs/aufs/store_asyncufs.h 2000/06/27 08:33:53 1.4
+++ src/fs/aufs/store_asyncufs.h 2000/10/15 21:31:37
@@ -74,11 +74,28 @@
     link_list *pending_reads;
 };
 
+struct _queued_write {
+ char *buf;
+ size_t size;
+ off_t offset;
+ FREE *free_func;
+};
+
+struct _queued_read {
+ char *buf;
+ size_t size;
+ off_t offset;
+ STRCB *callback;
+ void *callback_data;
+};
+
 typedef struct _aioinfo_t aioinfo_t;
 typedef struct _aiostate_t aiostate_t;
 
-/* The aio_state memory pool */
+/* The aio_state memory pools */
 extern MemPool *aio_state_pool;
+extern MemPool *aio_qread_pool;
+extern MemPool *aio_qwrite_pool;
 
 extern void storeAufsDirMapBitReset(SwapDir *, sfileno);
 extern int storeAufsDirMapBitAllocate(SwapDir *);
Index: src/fs/aufs/store_dir_aufs.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/aufs/store_dir_aufs.c,v
retrieving revision 1.9
diff -u -r1.9 store_dir_aufs.c
--- src/fs/aufs/store_dir_aufs.c 2000/10/13 06:35:54 1.9
+++ src/fs/aufs/store_dir_aufs.c 2000/10/15 21:31:41
@@ -72,6 +72,8 @@
 static int n_asyncufs_dirs = 0;
 static int *asyncufs_dir_index = NULL;
 MemPool *aio_state_pool = NULL;
+MemPool *aio_qread_pool = NULL;
+MemPool *aio_qwrite_pool = NULL;
 static int asyncufs_initialised = 0;
 
 static char *storeAufsDirSwapSubDir(SwapDir *, int subdirn);
@@ -1076,10 +1078,16 @@
 }
 
 static void
+storeSwapLogDataFree(void *s)
+{
+ memFree(s, MEM_SWAP_LOG_DATA);
+}
+
+static void
 storeAufsDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op)
 {
     aioinfo_t *aioinfo = (aioinfo_t *) sd->fsdata;
- storeSwapLogData *s = xcalloc(1, sizeof(storeSwapLogData));
+ storeSwapLogData *s = memAllocate(MEM_SWAP_LOG_DATA);
     s->op = (char) op;
     s->swap_filen = e->swap_filen;
     s->timestamp = e->timestamp;
@@ -1096,7 +1104,7 @@
         sizeof(storeSwapLogData),
         NULL,
         NULL,
- xfree);
+ (FREE *) storeSwapLogDataFree);
 }
 
 static void
@@ -1689,6 +1697,8 @@
 {
     aioDone();
     memPoolDestroy(aio_state_pool);
+ memPoolDestroy(aio_qread_pool);
+ memPoolDestroy(aio_qwrite_pool);
     asyncufs_initialised = 0;
 }
 
@@ -1700,6 +1710,11 @@
     storefs->reconfigurefunc = storeAufsDirReconfigure;
     storefs->donefunc = storeAufsDirDone;
     aio_state_pool = memPoolCreate("AUFS IO State data", sizeof(aiostate_t));
+ aio_qread_pool = memPoolCreate("AUFS Queued read data",
+ sizeof(queued_read));
+ aio_qwrite_pool = memPoolCreate("AUFS Queued write data",
+ sizeof(queued_write));
+
     asyncufs_initialised = 1;
     aioInit();
 }
Index: src/fs/aufs/store_io_aufs.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/aufs/store_io_aufs.c,v
retrieving revision 1.3
diff -u -r1.3 store_io_aufs.c
--- src/fs/aufs/store_io_aufs.c 2000/06/08 18:05:37 1.3
+++ src/fs/aufs/store_io_aufs.c 2000/10/15 21:31:41
@@ -14,21 +14,6 @@
 static int storeAufsKickWriteQueue(storeIOState * sio);
 static void storeAufsIOFreeEntry(void *, int);
 
-struct _queued_write {
- char *buf;
- size_t size;
- off_t offset;
- FREE *free_func;
-};
-
-struct _queued_read {
- char *buf;
- size_t size;
- off_t offset;
- STRCB *callback;
- void *callback_data;
-};
-
 /* === PUBLIC =========================================================== */
 
 /* open for reading */
@@ -137,7 +122,7 @@
         debug(78, 3) ("storeAufsRead: queueing read because FD < 0\n");
         assert(aiostate->flags.opening);
         assert(aiostate->pending_reads == NULL);
- q = xcalloc(1, sizeof(*q));
+ q = memPoolAlloc(aio_qread_pool);
         q->buf = buf;
         q->size = size;
         q->offset = offset;
@@ -169,7 +154,7 @@
         /* disk file not opened yet */
         struct _queued_write *q;
         assert(aiostate->flags.opening);
- q = xcalloc(1, sizeof(*q));
+ q = memPoolAlloc(aio_qwrite_pool);
         q->buf = buf;
         q->size = size;
         q->offset = offset;
@@ -180,7 +165,7 @@
     if (aiostate->flags.writing) {
         struct _queued_write *q;
         debug(78, 3) ("storeAufsWrite: queuing write\n");
- q = xcalloc(1, sizeof(*q));
+ q = memPoolAlloc(aio_qwrite_pool);
         q->buf = buf;
         q->size = size;
         q->offset = offset;
@@ -220,7 +205,7 @@
     debug(78, 3) ("storeAufsKickWriteQueue: writing queued chunk of %d bytes\n",
         q->size);
     storeAufsWrite(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->free_func);
- xfree(q);
+ memPoolFree(aio_qwrite_pool, q);
     return 1;
 }
 
@@ -234,7 +219,7 @@
     debug(78, 3) ("storeAufsKickReadQueue: reading queued request of %d bytes\n",
         q->size);
     storeAufsRead(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->callback, q->callback_data);
- xfree(q);
+ memPoolFree(aio_qread_pool, q);
     return 1;
 }
 
Index: src/fs/coss/store_dir_coss.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/coss/store_dir_coss.c,v
retrieving revision 1.3
diff -u -r1.3 store_dir_coss.c
--- src/fs/coss/store_dir_coss.c 2000/06/08 18:05:38 1.3
+++ src/fs/coss/store_dir_coss.c 2000/10/15 21:31:44
@@ -606,10 +606,16 @@
 }
 
 static void
+storeSwapLogDataFree(void *s)
+{
+ memFree(s, MEM_SWAP_LOG_DATA);
+}
+
+static void
 storeCossDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op)
 {
     CossInfo *cs = (CossInfo *) sd->fsdata;
- storeSwapLogData *s = xcalloc(1, sizeof(storeSwapLogData));
+ storeSwapLogData *s = memAllocate(MEM_SWAP_LOG_DATA);
     s->op = (char) op;
     s->swap_filen = e->swap_filen;
     s->timestamp = e->timestamp;
@@ -626,7 +632,7 @@
         sizeof(storeSwapLogData),
         NULL,
         NULL,
- xfree);
+ (FREE *) storeSwapLogDataFree);
 }
 
 static void
Index: src/fs/diskd/store_dir_diskd.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/diskd/store_dir_diskd.c,v
retrieving revision 1.20
diff -u -r1.20 store_dir_diskd.c
--- src/fs/diskd/store_dir_diskd.c 2000/10/13 06:35:57 1.20
+++ src/fs/diskd/store_dir_diskd.c 2000/10/15 21:31:47
@@ -1269,10 +1269,16 @@
 }
 
 static void
+storeSwapLogDataFree(void *s)
+{
+ memFree(s, MEM_SWAP_LOG_DATA);
+}
+
+static void
 storeDiskdDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op)
 {
     diskdinfo_t *diskdinfo = sd->fsdata;
- storeSwapLogData *s = xcalloc(1, sizeof(storeSwapLogData));
+ storeSwapLogData *s = memAllocate(MEM_SWAP_LOG_DATA);
     s->op = (char) op;
     s->swap_filen = e->swap_filen;
     s->timestamp = e->timestamp;
@@ -1289,7 +1295,7 @@
         sizeof(storeSwapLogData),
         NULL,
         NULL,
- xfree);
+ (FREE *) storeSwapLogDataFree);
 }
 
 static void
Index: src/fs/ufs/store_dir_ufs.c
===================================================================
RCS file: /server/cvs-server/squid/squid/src/fs/ufs/store_dir_ufs.c,v
retrieving revision 1.9
diff -u -r1.9 store_dir_ufs.c
--- src/fs/ufs/store_dir_ufs.c 2000/10/13 06:35:57 1.9
+++ src/fs/ufs/store_dir_ufs.c 2000/10/15 21:31:51
@@ -959,7 +959,7 @@
     unlink(state->cln);
     state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
     if (state->fd < 0)
- return -1;
+ return -1; /* state not free'd - possible leak */
     debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n",
         state->new, state->fd);
 #if HAVE_FCHMOD
@@ -1076,10 +1076,16 @@
 }
 
 static void
+storeSwapLogDataFree(void *s)
+{
+ memFree(s, MEM_SWAP_LOG_DATA);
+}
+
+static void
 storeUfsDirSwapLog(const SwapDir * sd, const StoreEntry * e, int op)
 {
     ufsinfo_t *ufsinfo = (ufsinfo_t *) sd->fsdata;
- storeSwapLogData *s = xcalloc(1, sizeof(storeSwapLogData));
+ storeSwapLogData *s = memAllocate(MEM_SWAP_LOG_DATA);
     s->op = (char) op;
     s->swap_filen = e->swap_filen;
     s->timestamp = e->timestamp;
@@ -1096,7 +1102,7 @@
         sizeof(storeSwapLogData),
         NULL,
         NULL,
- xfree);
+ (FREE *) storeSwapLogDataFree);
 }
 
 static void

----- End forwarded message -----

-- 
Adrian Chadd			"It was then that I knew that I wouldn't
<adrian@creative.net.au>	    die, as a doctor wouldn't fart in front
				      of a dying boy." -- Angela's Ashes
Received on Sun Oct 15 2000 - 15:38:55 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:43 MST