]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 8 Jul 2010 12:45:31 +0000 (00:45 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 8 Jul 2010 12:45:31 +0000 (00:45 +1200)
purge tool: making it work proper with current Squid versions

tools/purge/Makefile
tools/purge/purge.cc
tools/purge/squid-tlv.cc
tools/purge/squid-tlv.hh

index 946f394c5704edc98a4673cad4eacb8fac0705a8..a9cbf8ef18ac797ba68a7c02479d00905becb3a6 100644 (file)
@@ -108,10 +108,10 @@ ifeq (LINUX,${SYSTEM})
 LIBCVER = $(shell /bin/ls /lib/libc.so.? | \
        awk -F'.' '{ if (m<$$3) m=$$3;} END { print m} ')
 ifeq (6,${LIBCVER})
-SOCKLEN        = size_t
+SOCKLEN        = socklen_t
 endif
 CXXFLAGS += -DHAS_PSIGNAL -DLIBCVERSION=$(LIBCVER) -pipe # -Wall -pedantic
-OPT_NORM = -march=pentium -O2
+OPT_NORM = -O2
 # if your g++ balks (e.g. SuSE still uses 2.7.2.3)
 #CXXFLAGS += -DHAS_PSIGNAL -DLIBCVERSION=$(LIBCVER) -m486
 LD     = $(CC)
index 8d7162cecfc8f93502fcb38af7a0ef5f937ebdad..78a64cc5e87732bc4e7c837d39b8ab3a6d0d6dcc 100644 (file)
@@ -289,6 +289,13 @@ log_extended( const char* fn, int code, long size, const SquidMetaList* meta )
     sprintf( timeb, "%08x %08x %08x %08x %04x %5hu ",
             temp.timestamp, temp.lastref,
             temp.expires, temp.lastmod, temp.flags, temp.refcount );
+  } else if ( meta && (findings = meta->search( STORE_META_STD_LFS )) ) {
+    StoreMetaStdLFS temp;
+    // make data aligned, avoid SIGBUS on RISC machines (ARGH!)
+    memcpy( &temp, findings->data, sizeof(StoreMetaStd) );
+    sprintf( timeb, "%08x %08x %08x %08x %04x %5hu ",
+            temp.timestamp, temp.lastref,
+            temp.expires, temp.lastmod, temp.flags, temp.refcount );
   } else {
     sprintf( timeb, "%08x %08x %08x %08x %04x %5hu ", -1, -1, -1, -1, 0, 0 );
   }
@@ -417,7 +424,7 @@ match( const char* fn, const REList* list )
       // the URL as part of the list. First, gobble all meta data.
       unsigned int offset = addon;
       SquidMetaList meta;
-      while ( offset < datastart && *(offset+linebuffer) != STORE_META_END ) {
+      while ( offset + addon <= datastart ) {
        unsigned int size = 0;
        memcpy( &size, linebuffer+offset+sizeof(char), sizeof(unsigned int) );
        meta.append( SquidMetaType(*(linebuffer+offset)),
index 2ca4d6d42163c092ff601434cd145f0aa043ae6c..87df2668aba9935d727434f00c2858d1e4062265 100644 (file)
@@ -49,13 +49,8 @@ static const char* RCS_ID =
 SquidTLV::SquidTLV( SquidMetaType _type, size_t _size, void* _data )
   :next(0),size(_size)
 {
-  if ( size ) {
-    type = _type;
-    data = (char*) _data;
-  } else {
-    type = STORE_META_END;
-    data = 0;
-  }
+  type = _type;
+  data = (char*) _data;
 }
 
 SquidMetaList::SquidMetaList()
index 17edc4116e765463121267587ad1a7b215a0179d..2e4e80189ed04f5813e4debecfa038e041fdf5fc 100644 (file)
@@ -65,7 +65,9 @@ enum SquidMetaType {
   STORE_META_STD,              // standard metadata
   STORE_META_HITMETERING,      // reserved for hit metering
   STORE_META_VALID,
-  STORE_META_END
+  STORE_META_VARY_HEADERS,     // Stores Vary request headers
+  STORE_META_STD_LFS,          // standard metadata in lfs format
+  STORE_META_OBJSIZE,          // object size, if its known
 };
 
 // taken from Squid-2.x
@@ -79,6 +81,16 @@ struct StoreMetaStd {
   u_short flags;
 };
 
+struct StoreMetaStdLFS {
+  time_t  timestamp;
+  time_t  lastref;
+  time_t  expires;
+  time_t  lastmod;
+  uint64_t  swap_file_sz;
+  u_short refcount;
+  u_short flags;
+};
+
 struct SquidTLV {
   // create a shallow reference pointing into the "buffer" variable
   // do not copy --> saves times, saves memory.