Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 78800 invoked from network); 28 Sep 2010 17:06:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Sep 2010 17:06:46 -0000 Received: (qmail 41695 invoked by uid 500); 28 Sep 2010 17:06:46 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 41476 invoked by uid 500); 28 Sep 2010 17:06:45 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 41468 invoked by uid 99); 28 Sep 2010 17:06:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Sep 2010 17:06:45 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of minfrin@sharp.fm designates 72.32.122.20 as permitted sender) Received: from [72.32.122.20] (HELO chandler.sharp.fm) (72.32.122.20) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Sep 2010 17:06:35 +0000 Received: from chandler.sharp.fm (localhost [127.0.0.1]) by chandler.sharp.fm (Postfix) with ESMTP id C74DD2C8B4F for ; Tue, 28 Sep 2010 12:06:14 -0500 (CDT) Received: from [172.31.120.255] (unknown [212.58.232.179]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) (Authenticated sender: minfrin@sharp.fm) by chandler.sharp.fm (Postfix) with ESMTP id 47BB02C8B4D for ; Tue, 28 Sep 2010 12:06:14 -0500 (CDT) Message-Id: <54AD7A5F-33D8-4495-9A56-87A99D13DD66@sharp.fm> From: Graham Leggett To: dev@httpd.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: mod_disk_cache: intended change to file formats Date: Tue, 28 Sep 2010 19:06:12 +0200 X-Mailer: Apple Mail (2.936) X-Virus-Scanned: ClamAV using ClamSMTP X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I have two changes to the mod_disk_cache on-disk structure that I plan to make, and to avoid gratuitous format version bumping, I plan to make this format change in one go, and then apply each implementation separately. The changes are: - Fix the problem that updates to an entry by mod_disk_cache aren't atomic, without using locks. To fix this, the inode and device numbers for the body file are embedded in the header file, and when the header and body files are read in, the ident so saved in the header is checked against the real ident of the body (in a stat we're already doing anyway to get the body size). When the check fails, we know that our attempt to read in the header and open the body file have failed due to the race condition, and we should try open the files again. - Add flags to indicate whether the body is included, and whether we've attempted to cache a HEAD request. Sometimes, we are asked to cache responses that officially have no body (eg 204 No Content), or potentially HEAD requests that should have a body, but don't. In these cases, we end up saving a zero byte body file, which takes up one extra inode. The flag indicates that no body is included with this entry, and that mod_disk_cache shouldn't look for one. This is useful when attempts are made to cache service calls, where the result of the call is the result code, or when the result of the call arrives in headers only. The format change looks like this: Index: modules/cache/mod_disk_cache.h =================================================================== --- modules/cache/mod_disk_cache.h (revision 1002189) +++ modules/cache/mod_disk_cache.h (working copy) @@ -17,12 +17,14 @@ #ifndef MOD_DISK_CACHE_H #define MOD_DISK_CACHE_H +#include "apr_file_io.h" + /* * include for mod_disk_cache: Disk Based HTTP 1.1 Cache. */ -#define VARY_FORMAT_VERSION 3 -#define DISK_FORMAT_VERSION 4 +#define VARY_FORMAT_VERSION 5 +#define DISK_FORMAT_VERSION 6 #define CACHE_HEADER_SUFFIX ".header" #define CACHE_DATA_SUFFIX ".data" @@ -49,6 +51,12 @@ apr_time_t expire; apr_time_t request_time; apr_time_t response_time; + /* The ident of the body file, so we can test the body matches the header */ + apr_ino_t inode; + apr_dev_t device; + /* Does this cached request have a body? */ + int has_body; + int header_only; } disk_cache_info_t; typedef struct { Regards, Graham --