Blame SOURCES/httpd-2.4.4-cachehardmax.patch

af9b8b
diff --git a/modules/cache/cache_util.h b/modules/cache/cache_util.h
af9b8b
index eec38f3..1a2d5ee 100644
af9b8b
--- a/modules/cache/cache_util.h
af9b8b
+++ b/modules/cache/cache_util.h
af9b8b
@@ -194,6 +194,9 @@ typedef struct {
af9b8b
     unsigned int store_nostore_set:1;
af9b8b
     unsigned int enable_set:1;
af9b8b
     unsigned int disable_set:1;
af9b8b
+    /* treat maxex as hard limit */
af9b8b
+    unsigned int hardmaxex:1;
af9b8b
+    unsigned int hardmaxex_set:1;
af9b8b
 } cache_dir_conf;
af9b8b
 
af9b8b
 /* A linked-list of authn providers. */
af9b8b
diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c
af9b8b
index 4f2d3e0..30c88f4 100644
af9b8b
--- a/modules/cache/mod_cache.c
af9b8b
+++ b/modules/cache/mod_cache.c
af9b8b
@@ -1299,6 +1299,11 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
af9b8b
             exp = date + dconf->defex;
af9b8b
         }
af9b8b
     }
af9b8b
+    /* else, forcibly cap the expiry date if required */
af9b8b
+    else if (dconf->hardmaxex && (date + dconf->maxex) < exp) {
af9b8b
+        exp = date + dconf->maxex;
af9b8b
+    }        
af9b8b
+
af9b8b
     info->expire = exp;
af9b8b
 
af9b8b
     /* We found a stale entry which wasn't really stale. */
af9b8b
@@ -1717,7 +1722,9 @@ static void *create_dir_config(apr_pool_t *p, char *dummy)
af9b8b
 
af9b8b
     /* array of providers for this URL space */
af9b8b
     dconf->cacheenable = apr_array_make(p, 10, sizeof(struct cache_enable));
af9b8b
-
af9b8b
+    /* flag; treat maxex as hard limit */
af9b8b
+    dconf->hardmaxex = 0;
af9b8b
+    dconf->hardmaxex_set = 0;
af9b8b
     return dconf;
af9b8b
 }
af9b8b
 
af9b8b
@@ -1767,7 +1774,10 @@ static void *merge_dir_config(apr_pool_t *p, void *basev, void *addv) {
af9b8b
     new->enable_set = add->enable_set || base->enable_set;
af9b8b
     new->disable = (add->disable_set == 0) ? base->disable : add->disable;
af9b8b
     new->disable_set = add->disable_set || base->disable_set;
af9b8b
-
af9b8b
+    new->hardmaxex = 
af9b8b
+        (add->hardmaxex_set == 0)
af9b8b
+        ? base->hardmaxex
af9b8b
+        : add->hardmaxex;
af9b8b
     return new;
af9b8b
 }
af9b8b
 
af9b8b
@@ -2096,12 +2106,18 @@ static const char *add_cache_disable(cmd_parms *parms, void *dummy,
af9b8b
 }
af9b8b
 
af9b8b
 static const char *set_cache_maxex(cmd_parms *parms, void *dummy,
af9b8b
-                                   const char *arg)
af9b8b
+                                   const char *arg, const char *hard)
af9b8b
 {
af9b8b
     cache_dir_conf *dconf = (cache_dir_conf *)dummy;
af9b8b
 
af9b8b
     dconf->maxex = (apr_time_t) (atol(arg) * MSEC_ONE_SEC);
af9b8b
     dconf->maxex_set = 1;
af9b8b
+    
af9b8b
+    if (hard && strcasecmp(hard, "hard") == 0) {
af9b8b
+        dconf->hardmaxex = 1;
af9b8b
+        dconf->hardmaxex_set = 1;
af9b8b
+    }
af9b8b
+
af9b8b
     return NULL;
af9b8b
 }
af9b8b
 
af9b8b
@@ -2309,7 +2325,7 @@ static const command_rec cache_cmds[] =
af9b8b
                    "caching is enabled"),
af9b8b
     AP_INIT_TAKE1("CacheDisable", add_cache_disable, NULL, RSRC_CONF|ACCESS_CONF,
af9b8b
                   "A partial URL prefix below which caching is disabled"),
af9b8b
-    AP_INIT_TAKE1("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF|ACCESS_CONF,
af9b8b
+    AP_INIT_TAKE12("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF|ACCESS_CONF,
af9b8b
                   "The maximum time in seconds to cache a document"),
af9b8b
     AP_INIT_TAKE1("CacheMinExpire", set_cache_minex, NULL, RSRC_CONF|ACCESS_CONF,
af9b8b
                   "The minimum time in seconds to cache a document"),