From b4832aa9ee32dd27b75eff3f9aba5d861ad57ccc Mon Sep 17 00:00:00 2001 From: rousskov <> Date: Wed, 4 Mar 1998 05:17:50 +0000 Subject: [PATCH] - Fixed memory alignment problem in Mem.c by removing MemChunks. We do not pre-allocate memory any more. - Removed/replaced tmp_debug() mesages. --- src/HttpHeader.cc | 9 +++------ src/HttpReply.cc | 6 +++--- src/HttpStatusLine.cc | 6 +++--- src/Packer.cc | 3 +-- src/fqdncache.cc | 4 ++-- src/ipcache.cc | 4 ++-- src/mem.cc | 20 ++++---------------- src/protos.h | 7 ++++--- src/store.cc | 3 +-- 9 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index a8c49ff8bc..72fa5c1b12 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,5 +1,5 @@ /* - * $Id: HttpHeader.cc,v 1.11 1998/03/03 00:30:59 rousskov Exp $ + * $Id: HttpHeader.cc,v 1.12 1998/03/03 22:17:50 rousskov Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -69,7 +69,7 @@ typedef enum { ftPChar, ftDate_1123, ftPSCC, - ftPExtField, + ftPExtField } field_type; /* @@ -561,7 +561,7 @@ httpHeaderGetEntry(const HttpHeader * hdr, HttpHeaderPos * pos) { assert(hdr && pos); assert(*pos >= HttpHeaderInitPos && *pos < hdr->capacity); - tmp_debug(here) ("searching next e in hdr %p from %d\n", hdr, *pos); + debug(55,8) ("searching next e in hdr %p from %d\n", hdr, *pos); for ((*pos)++; *pos < hdr->ucount; (*pos)++) { HttpHeaderEntry *e = hdr->entries + *pos; if (httpHeaderEntryIsValid(e)) { @@ -1439,8 +1439,6 @@ httpHeaderExtFieldParseCreate(const char *field_start, const char *field_end) if (!name_end || name_end <= field_start || name_end > field_end) return NULL; - tmp_debug(here) ("got field len: %d\n", field_end - field_start); - value_start = name_end + 1; /* skip ':' */ /* skip white space */ while (value_start < field_end && isspace(*value_start)) @@ -1589,7 +1587,6 @@ dupShortBuf(const char *str, size_t len) { char *buf; assert(str); - assert(len >= 0); buf = allocShortBuf(len + 1); assert(buf); if (len) diff --git a/src/HttpReply.cc b/src/HttpReply.cc index d31125e518..b1ee9c232f 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.7 1998/03/03 00:30:59 rousskov Exp $ + * $Id: HttpReply.cc,v 1.8 1998/03/03 22:17:50 rousskov Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -49,7 +49,7 @@ HttpReply * httpReplyCreate() { HttpReply *rep = memAllocate(MEM_HTTPREPLY); - tmp_debug(here) ("creating rep: %p\n", rep); + debug(58,7) ("creating rep: %p\n", rep); httpReplyInit(rep); return rep; } @@ -78,7 +78,7 @@ void httpReplyDestroy(HttpReply * rep) { assert(rep); - tmp_debug(here) ("destroying rep: %p\n", rep); + debug(58,7) ("destroying rep: %p\n", rep); httpReplyClean(rep); httpReplyDoDestroy(rep); } diff --git a/src/HttpStatusLine.cc b/src/HttpStatusLine.cc index fdebd9e6fc..a290230363 100644 --- a/src/HttpStatusLine.cc +++ b/src/HttpStatusLine.cc @@ -1,5 +1,5 @@ /* - * $Id: HttpStatusLine.cc,v 1.5 1998/02/26 18:00:32 wessels Exp $ + * $Id: HttpStatusLine.cc,v 1.6 1998/03/03 22:17:51 rousskov Exp $ * * DEBUG: section 57 HTTP Status-line * AUTHOR: Alex Rousskov @@ -67,8 +67,8 @@ void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p) { assert(sline && p); - tmp_debug(here) ("packing sline %p using %p:\n", sline, p); - tmp_debug(here) (HttpStatusLineFormat, sline->version, sline->status, + debug(57,9) ("packing sline %p using %p:\n", sline, p); + debug(57,9) (HttpStatusLineFormat, sline->version, sline->status, sline->reason ? sline->reason : httpStatusString(sline->status)); packerPrintf(p, HttpStatusLineFormat, sline->version, sline->status, diff --git a/src/Packer.cc b/src/Packer.cc index 61f500bf12..1215129fbc 100644 --- a/src/Packer.cc +++ b/src/Packer.cc @@ -1,6 +1,6 @@ /* - * $Id: Packer.cc,v 1.5 1998/02/26 18:00:34 wessels Exp $ + * $Id: Packer.cc,v 1.6 1998/03/03 22:17:52 rousskov Exp $ * * DEBUG: section 60 Packer: A uniform interface to store-like modules * AUTHOR: Alex Rousskov @@ -158,7 +158,6 @@ packerPrintf(va_alist) #endif assert(p); assert(p->real_handler && p->vprintf); - tmp_debug(here) ("printf: fmt: '%s'\n", fmt); p->vprintf(p->real_handler, fmt, args); va_end(args); } diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 9b015efc58..c739b68e5f 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.88 1998/02/26 22:16:28 kostas Exp $ + * $Id: fqdncache.cc,v 1.89 1998/03/03 22:17:52 rousskov Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -943,7 +943,7 @@ snmp_fqdncacheFn(variable_list * Var, long *ErrP) case NET_FQDN_NAME: Answer->type = SMI_STRING; Answer->val_len = strlen(fq->names[0]); - Answer->val.string = xstrdup((char *) fq->names[0]); + Answer->val.string = (u_char *)xstrdup(fq->names[0]); break; case NET_FQDN_IP: Answer->type = SMI_IPADDRESS; diff --git a/src/ipcache.cc b/src/ipcache.cc index d1ba8ebb14..fb75632dbd 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.163 1998/02/26 22:16:28 kostas Exp $ + * $Id: ipcache.cc,v 1.164 1998/03/03 22:17:53 rousskov Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -1099,7 +1099,7 @@ snmp_ipcacheFn(variable_list * Var, long *ErrP) xfree(Answer->val.integer); Answer->type = SMI_STRING; Answer->val_len = strlen(IPc->name); - Answer->val.string = xstrdup(IPc->name); + Answer->val.string = (u_char *)xstrdup(IPc->name); break; case NET_IPC_IP: Answer->type = SMI_IPADDRESS; diff --git a/src/mem.cc b/src/mem.cc index a121aa785c..d13d394e26 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -1,6 +1,6 @@ /* - * $Id: mem.cc,v 1.8 1998/03/03 00:31:09 rousskov Exp $ + * $Id: mem.cc,v 1.9 1998/03/03 22:17:54 rousskov Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -46,21 +46,9 @@ memDataInit(mem_type type, const char *name, size_t size, int max_pages_notused) static void memStats(StoreEntry * sentry) { - mem_type t; storeBuffer(sentry); - storeAppendPrintf(sentry, "%-20s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\n", - "Pool", "Obj Size", - "Capacity (#)", "Capacity (KB)", "Used (KB)", "HWater (KB)", - "Util (%)", "Grow Count", - "Malloc (#)", "Malloc (KB)", "MHWater (KB)"); - for (t = MEM_NONE + 1; t < MEM_MAX; t++) { - const MemPool *pool = MemPools[t]; - if (!memPoolWasNeverUsed(pool)) - memPoolReport(pool, sentry); - } - storeAppendPrintf(sentry, "\n"); + memReport(sentry); /* memStringStats(sentry); */ - memReportTotals(sentry); storeBufferFlush(sentry); } @@ -197,7 +185,7 @@ memClean() int dirty_count = 0; for (t = MEM_NONE + 1; t < MEM_MAX; t++) { MemPool *pool = MemPools[t]; - if (memPoolIsUsedNow(pool)) { + if (memPoolInUseCount(pool)) { memPoolDescribe(pool); dirty_count++; } @@ -212,7 +200,7 @@ memClean() int memInUse(mem_type type) { - return memPoolUsedCount(MemPools[type]); + return memPoolInUseCount(MemPools[type]); } /* ick */ diff --git a/src/protos.h b/src/protos.h index 9ae9fb99b0..2132e8e0e1 100644 --- a/src/protos.h +++ b/src/protos.h @@ -529,12 +529,13 @@ extern MemPool *memPoolCreate(const char *label, size_t obj_size); extern void memPoolDestroy(MemPool *pool); extern void *memPoolAlloc(MemPool *pool); extern void memPoolFree(MemPool *pool, void *obj); -extern int memPoolWasNeverUsed(const MemPool *pool); -extern int memPoolIsUsedNow(const MemPool *pool); +extern int memPoolWasUsed(const MemPool *pool); +extern int memPoolInUseCount(const MemPool *pool); +extern size_t memPoolInUseSize(const MemPool *pool); extern int memPoolUsedCount(const MemPool *pool); extern void memPoolDescribe(const MemPool *pool); extern void memPoolReport(const MemPool *pool, StoreEntry *e); -extern void memReportTotals(StoreEntry *e); +extern void memReport(StoreEntry *e); extern int stmemFreeDataUpto(mem_hdr *, int); extern void stmemAppend(mem_hdr *, const char *, int); diff --git a/src/store.cc b/src/store.cc index d33a0efe9e..eb79a4e949 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.388 1998/03/03 00:31:14 rousskov Exp $ + * $Id: store.cc,v 1.389 1998/03/03 22:17:56 rousskov Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -456,7 +456,6 @@ storeAppend(StoreEntry * e, const char *buf, int len) debug(20, 5) ("storeAppend: appending %d bytes for '%s'\n", len, storeKeyText(e->key)); - tmp_debug(here) ("bytes: '%.20s'\n", buf); /* @?@ @?@ */ storeGetMemSpace(len); stmemAppend(mem->data, buf, len); mem->inmem_hi += len; -- 2.47.3