Commit 3f6143a4 authored by Graham Leggett's avatar Graham Leggett
Browse files

mod_disk_cache: Do away with the write-to-file-then-move-in-place

mentality.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@462571 13f79535-47bb-0310-9956-ffa450edef68
parent 2b601ab6
Loading
Loading
Loading
Loading
+3 −0
Changes for CHANGES: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@
Changes with Apache 2.3.0
  [Remove entries to the current 2.0 and 2.2 section below, when backported]
  *) mod_disk_cache: Do away with the write-to-file-then-move-in-place
     mentality. [Niklas Edmundsson <nikke acc.umu.se>]
  *) mod_rewrite: support rewritemap by SQL query [Nick Kew]
  *) Fix issue which could cause piped loggers to be orphaned and never
+657 −245

File changed.

Preview size limit exceeded, changes collapsed.

+24 −4
Changes for modules/cache/mod_disk_cache.h: 24 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@
 */

#define VARY_FORMAT_VERSION 3
#define DISK_FORMAT_VERSION 4
#define DISK_FORMAT_VERSION_OLD 4
#define DISK_FORMAT_VERSION 5

#define CACHE_HEADER_SUFFIX ".header"
#define CACHE_DATA_SUFFIX   ".data"
@@ -30,6 +31,10 @@

#define CACHE_BUF_SIZE 65536

/* How long to sleep before retrying while looping */
#define CACHE_LOOP_SLEEP 200000


#define AP_TEMPFILE_PREFIX "/"
#define AP_TEMPFILE_BASE   "aptmp"
#define AP_TEMPFILE_SUFFIX "XXXXXX"
@@ -37,9 +42,10 @@
#define AP_TEMPFILE_NAMELEN strlen(AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX)
#define AP_TEMPFILE AP_TEMPFILE_PREFIX AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX

typedef struct {
/* Indicates the format of the header struct stored on-disk. */
    apr_uint32_t format;
typedef apr_uint32_t disk_cache_format_t;

typedef struct {
    /* The HTTP status code returned for this response.  */
    int status;
    /* The size of the entity name that follows. */
@@ -51,6 +57,9 @@ typedef struct {
    apr_time_t expire;
    apr_time_t request_time;
    apr_time_t response_time;
    /* The body size forced to 64bit to not break when people go from non-LFS
     * to LFS builds */
    apr_int64_t file_size;
} disk_cache_info_t;

/*
@@ -66,12 +75,16 @@ typedef struct disk_cache_object {
    const char *hdrsfile;    /* name of file where the hdrs will go */
    const char *hashfile;    /* Computed hash key for this URI */
    const char *name;   /* Requested URI without vary bits - suitable for mortals. */
    const char *key;    /* On-disk prefix; URI with Vary bits (if present) */
    apr_file_t *fd;          /* data file */
    apr_file_t *hfd;         /* headers file */
    apr_file_t *tfd;         /* temporary file for data */
    apr_off_t file_size;     /*  File size of the cached data file  */
    apr_off_t initial_size;  /*  Initial file size reported by caller */
    disk_cache_info_t disk_info; /* Header information. */

    apr_interval_time_t updtimeout; /* Cache update timeout */

    int skipstore;           /* Set if we should skip storing stuff */
} disk_cache_object_t;


@@ -84,6 +97,7 @@ typedef struct disk_cache_object {
#define DEFAULT_DIRLENGTH 2
#define DEFAULT_MIN_FILE_SIZE 1
#define DEFAULT_MAX_FILE_SIZE 1000000
#define DEFAULT_UPDATE_TIMEOUT apr_time_from_sec(10)

typedef struct {
    const char* cache_root;
@@ -92,6 +106,12 @@ typedef struct {
    int dirlength;               /* Length of subdirectory names */
    apr_off_t minfs;             /* minimum file size for cached files */
    apr_off_t maxfs;             /* maximum file size for cached files */
    apr_interval_time_t updtimeout;   /* Cache update timeout */
} disk_cache_conf;

#define CACHE_ENODATA (APR_OS_START_USERERR+1)
#define CACHE_EDECLINED (APR_OS_START_USERERR+2)
#define CACHE_EEXIST (APR_OS_START_USERERR+3)


#endif /*MOD_DISK_CACHE_H*/