]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1149: segfault on mgr:vm_objects
authorserassio <>
Mon, 27 Dec 2004 18:04:36 +0000 (18:04 +0000)
committerserassio <>
Mon, 27 Dec 2004 18:04:36 +0000 (18:04 +0000)
Forward port of 2.5 patch

src/MemObject.cc
src/MemObject.h
src/StoreClient.h
src/stat.cc
src/store_client.cc

index 626e66b4693e596a8487b31333ab97f013c2e6ec..116f7183d0ce318cb9db8f56510f724c4173694e 100644 (file)
@@ -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<store_client, void>
 
 struct StoreClientStats : public unary_function<store_client, void>
 {
-    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<StoreClientStats>(clients, statsVisitor);
 }
index 54acae461fefd59a19523633331ca754b0ef99d3..93306606029966c73b9485a96647fa1f76f90861 100644 (file)
@@ -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();
index 2d54c95d41006ace90a286e3a0c8c6ab19b6552a..6101fe13378d7929d98de4bafe72096a5d10737c 100644 (file)
@@ -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
index 603f3c9e8028e90941817abfb77ef6081f702628..9c14967dabd22ea63d4115fd444864760417e214 100644 (file)
@@ -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
index 1e1763b7451182dd28431b4b3c1fe3e64483f35a..de0c79a5f9817b2d3d58f4af8a0f994a1404661d 100644 (file)
@@ -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