Blame SOURCES/httpd-2.4.35-cachehardmax.patch

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