From: Amos Jeffries Date: Thu, 8 Jul 2010 12:45:31 +0000 (+1200) Subject: Author: Henrik Nordstrom X-Git-Tag: SQUID_3_2_0_1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a63b44c2f9b832570af164d0e515ee526e315059;p=thirdparty%2Fsquid.git Author: Henrik Nordstrom purge tool: making it work proper with current Squid versions --- diff --git a/tools/purge/Makefile b/tools/purge/Makefile index 946f394c57..a9cbf8ef18 100644 --- a/tools/purge/Makefile +++ b/tools/purge/Makefile @@ -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) diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc index 8d7162cecf..78a64cc5e8 100644 --- a/tools/purge/purge.cc +++ b/tools/purge/purge.cc @@ -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)), diff --git a/tools/purge/squid-tlv.cc b/tools/purge/squid-tlv.cc index 2ca4d6d421..87df2668ab 100644 --- a/tools/purge/squid-tlv.cc +++ b/tools/purge/squid-tlv.cc @@ -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() diff --git a/tools/purge/squid-tlv.hh b/tools/purge/squid-tlv.hh index 17edc4116e..2e4e80189e 100644 --- a/tools/purge/squid-tlv.hh +++ b/tools/purge/squid-tlv.hh @@ -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.