From: serassio <> Date: Mon, 27 Dec 2004 18:04:36 +0000 (+0000) Subject: Bug #1149: segfault on mgr:vm_objects X-Git-Tag: SQUID_3_0_PRE4~937 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcc351807bcecc7e20a032afdc38cdc14b8d81ee;p=thirdparty%2Fsquid.git Bug #1149: segfault on mgr:vm_objects Forward port of 2.5 patch --- diff --git a/src/MemObject.cc b/src/MemObject.cc index 626e66b469..116f7183d0 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.13 2004/08/30 05:12:31 robertc Exp $ + * $Id: MemObject.cc,v 1.14 2004/12/27 11:04:36 serassio Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -201,32 +201,32 @@ struct LowestMemReader : public unary_function struct StoreClientStats : public unary_function { - StoreClientStats(StoreEntry *anEntry):where(anEntry),index(0){} + StoreClientStats(MemBuf *anEntry):where(anEntry),index(0){} void operator()(store_client const &x) { x.dumpStats(where, index++); } - StoreEntry *where; + MemBuf *where; size_t index; }; void -MemObject::stat (StoreEntry *s) const +MemObject::stat (MemBuf * mb) const { - storeAppendPrintf(s, "\t%s %s\n", - RequestMethodStr[method], log_url); - storeAppendPrintf(s, "\tinmem_lo: %d\n", (int) inmem_lo); - storeAppendPrintf(s, "\tinmem_hi: %d\n", (int) data_hdr.endOffset()); - storeAppendPrintf(s, "\tswapout: %d bytes queued\n", - (int) swapout.queue_offset); + memBufPrintf(mb, "\t%s %s\n", + RequestMethodStr[method], log_url); + memBufPrintf(mb, "\tinmem_lo: %d\n", (int) inmem_lo); + memBufPrintf(mb, "\tinmem_hi: %d\n", (int) data_hdr.endOffset()); + memBufPrintf(mb, "\tswapout: %d bytes queued\n", + (int) swapout.queue_offset); if (swapout.sio.getRaw()) - storeAppendPrintf(s, "\tswapout: %d bytes written\n", - (int) swapout.sio->offset()); + memBufPrintf(mb, "\tswapout: %d bytes written\n", + (int) swapout.sio->offset()); - StoreClientStats statsVisitor(s); + StoreClientStats statsVisitor(mb); for_each(clients, statsVisitor); } diff --git a/src/MemObject.h b/src/MemObject.h index 54acae461f..9330660602 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -1,6 +1,6 @@ /* - * $Id: MemObject.h,v 1.9 2004/08/30 05:12:31 robertc Exp $ + * $Id: MemObject.h,v 1.10 2004/12/27 11:04:36 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -59,7 +59,7 @@ public: void write(StoreIOBuffer, STMCB *, void *); void unlinkRequest(); HttpReply const *getReply() const; - void stat (StoreEntry *s) const; + void stat (MemBuf * mb) const; off_t endOffset () const; size_t size() const; void reset(); diff --git a/src/StoreClient.h b/src/StoreClient.h index 2d54c95d41..6101fe1337 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.12 2004/08/30 05:12:31 robertc Exp $ + * $Id: StoreClient.h,v 1.13 2004/12/27 11:04:36 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -70,7 +70,7 @@ public: void doCopy (StoreEntry *e); void readHeader(const char *buf, ssize_t len); void copy(StoreEntry *, StoreIOBuffer, STCB *, void *); - void dumpStats(StoreEntry * output, int clientNumber) const; + void dumpStats(MemBuf * output, int clientNumber) const; off_t cmp_offset; #if STORE_CLIENT_LIST_DEBUG diff --git a/src/stat.cc b/src/stat.cc index 603f3c9e80..9c14967dab 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.386 2004/12/20 19:26:11 robertc Exp $ + * $Id: stat.cc,v 1.387 2004/12/27 11:04:36 serassio Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -76,7 +76,7 @@ static void statCountersInitSpecial(StatCounters *); static void statCountersClean(StatCounters *); static void statCountersCopy(StatCounters * dest, const StatCounters * orig); static double statMedianSvc(int, int); -static void statStoreEntry(StoreEntry * s, StoreEntry * e); +static void statStoreEntry(MemBuf * mb, StoreEntry * e); static double statCPUUsage(int minutes); static OBJH stat_io_get; static OBJH stat_objects_get; @@ -309,24 +309,24 @@ describeTimestamps(const StoreEntry * entry) } static void -statStoreEntry(StoreEntry * s, StoreEntry * e) +statStoreEntry(MemBuf * mb, StoreEntry * e) { MemObject *mem = e->mem_obj; - storeAppendPrintf(s, "KEY %s\n", e->getMD5Text()); - storeAppendPrintf(s, "\t%s\n", describeStatuses(e)); - storeAppendPrintf(s, "\t%s\n", storeEntryFlags(e)); - storeAppendPrintf(s, "\t%s\n", describeTimestamps(e)); - storeAppendPrintf(s, "\t%d locks, %d clients, %d refs\n", - (int) e->lock_count, - storePendingNClients(e), - (int) e->refcount); - storeAppendPrintf(s, "\tSwap Dir %d, File %#08X\n", - e->swap_dirn, e->swap_filen); + memBufPrintf(mb, "KEY %s\n", e->getMD5Text()); + memBufPrintf(mb, "\t%s\n", describeStatuses(e)); + memBufPrintf(mb, "\t%s\n", storeEntryFlags(e)); + memBufPrintf(mb, "\t%s\n", describeTimestamps(e)); + memBufPrintf(mb, "\t%d locks, %d clients, %d refs\n", + (int) e->lock_count, + storePendingNClients(e), + (int) e->refcount); + memBufPrintf(mb, "\tSwap Dir %d, File %#08X\n", + e->swap_dirn, e->swap_filen); if (mem != NULL) - mem->stat (s); + mem->stat (mb); - storeAppendPrintf(s, "\n"); + memBufPrintf(mb, "\n"); } /* process objects list */ @@ -352,23 +352,29 @@ statObjects(void *data) return; } - storeBuffer(state->sentry); debug(49, 3) ("statObjects: Bucket #%d\n", state->bucket); link_next = hash_get_bucket(store_table, state->bucket); - while (NULL != (link_ptr = link_next)) { - link_next = link_ptr->next; - e = (StoreEntry *) link_ptr; + if (link_next) { + MemBuf mb; + memBufDefInit(&mb); - if (state->filter && 0 == state->filter(e)) - continue; + while (NULL != (link_ptr = link_next)) { + link_next = link_ptr->next; + e = (StoreEntry *) link_ptr; - statStoreEntry(state->sentry, e); + if (state->filter && 0 == state->filter(e)) + continue; + + statStoreEntry(&mb, e); + } + + storeAppend(state->sentry, mb.buf, mb.size); + memBufClean(&mb); } state->bucket++; eventAdd("statObjects", statObjects, state, 0.0, 1); - storeBufferFlush(state->sentry); } static void diff --git a/src/store_client.cc b/src/store_client.cc index 1e1763b745..de0c79a5f9 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.138 2004/12/20 16:30:36 robertc Exp $ + * $Id: store_client.cc,v 1.139 2004/12/27 11:04:37 serassio Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -819,31 +819,31 @@ CheckQuickAbort(StoreEntry * entry) } void -store_client::dumpStats(StoreEntry * output, int clientNumber) const +store_client::dumpStats(MemBuf * output, int clientNumber) const { if (_callback.pending()) return; - storeAppendPrintf(output, "\tClient #%d, %p\n", clientNumber, _callback.callback_data); + memBufPrintf(output, "\tClient #%d, %p\n", clientNumber, _callback.callback_data); - storeAppendPrintf(output, "\t\tcopy_offset: %lu\n", - (unsigned long) copyInto.offset); + memBufPrintf(output, "\t\tcopy_offset: %lu\n", + (unsigned long) copyInto.offset); - storeAppendPrintf(output, "\t\tcopy_size: %d\n", - (int) copyInto.length); + memBufPrintf(output, "\t\tcopy_size: %d\n", + (int) copyInto.length); - storeAppendPrintf(output, "\t\tflags:"); + memBufPrintf(output, "\t\tflags:"); if (flags.disk_io_pending) - storeAppendPrintf(output, " disk_io_pending"); + memBufPrintf(output, " disk_io_pending"); if (flags.store_copying) - storeAppendPrintf(output, " store_copying"); + memBufPrintf(output, " store_copying"); if (flags.copy_event_pending) - storeAppendPrintf(output, " copy_event_pending"); + memBufPrintf(output, " copy_event_pending"); - storeAppendPrintf(output, "\n"); + memBufPrintf(output, "\n"); } bool