Hello,

> please note that field alignment applies as per the requirements your
> platform so there may be padding between smaller and larger fields. On x86
> this padding is seen between the op and swap_file_number fields.


I am on an x86 machine.

>
> Detailed layout on x86: offset(length)
>
> 0(1) char op;
> 1(3) char padding[3]
> 4(4) int swap_file_number;
> 8(4) time_t timestamp;
> 12(4) time_t lastref;
> 16(4) time_t expires;
> 20(4) time_t lastmod;
> 24(4) size_t swap_file_sz;
> 28(2) u_short refcount;
> 30(2) u_short flags;
> 32(16) unsigned char key[MD5_DIGEST_CHARS];
>


I still cant't read the swap.state records properly.

I now have in code:

$binary_layout = "A1 x3 i l l l l l s s A16";
$recordlen = length pack $binary_layout, "";

open SWAP_STATE, "<$swap_state";

if ( ! read SWAP_STATE, $record, $recordlen ) {
print "Failed to read initial record in $swap_state\n";
die;
}

($metaop,$metapad,$metafilenum,$metatimestamp,$met alastref,$metaexpires,$metalastmod,
$metafilesz,$metarefcount,$metaflags,$metakey) = unpack $binary_layout,
$record;

print DEBUG "binary_layout: $binary_layout\n";
print DEBUG "recordlen: $recordlen\n";
print DEBUG "metaop: $metaop\n";
print DEBUG "metafilenum: $metafilenum\n";
print DEBUG "metatimestamp: $metatimestamp\n";
print DEBUG "metalastref: $metalastref\n";
print DEBUG "metaexpires: $metaexpires\n";
print DEBUG "metalastmod: $metalastmod\n";

and for output I get I get:

binary_layout: A1 x3 i l l l l l s s A16
recordlen: 48
metaop:
metafilenum: 1076866014
metatimestamp: 1076866015
metalastref: -1
metaexpires: 1062471704
metalastmod: 5992

Obviously I have done something wrong, but I can't see it. Could
someone help please?

>
> Most if not all of this information is also logged in swap.log where you
> also have access to the URL etc, provided it's known by Squid at the
> time.


I would rather use the swap.state data since it has more information,
but I looked at using swap.log.

I didn't have the cache_swap_log option set in squid.conf, but I turned
it on and pointed to /usr/local/squid/var/logs/swap.log

I restarted (not reloaded) squid and swap.log.00 got created. When it
first got created, it had the same size as my swap.state file, but as
soon as I went to some sites not cached, the swap.log file updated, but
the swap.state file remained unchanged (both size and timestamp). Are
swap.log and swap.state mutually exclusive?

Now, I restarted squid again, and still the swap.state file remained
unchanged. So it appears that if I have swap.log enabled, swap.state is
not updated, right? If not, how/when is swap.state updated?


Also, what is the binary layout for the swap.log?



Thanks,

Murrah Boswell