forward-port CacheMaxExpire "hard" option

This commit is contained in:
Jan Kaluza 2013-04-18 08:22:20 +02:00
parent 08bb147aa8
commit 3f84aef712
2 changed files with 85 additions and 0 deletions

View File

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

View File

@ -59,6 +59,7 @@ Patch26: httpd-2.4.4-r1337344+.patch
Patch27: httpd-2.4.2-icons.patch Patch27: httpd-2.4.2-icons.patch
Patch28: httpd-2.4.4-r1332643+.patch Patch28: httpd-2.4.4-r1332643+.patch
Patch29: httpd-2.4.3-mod_systemd.patch Patch29: httpd-2.4.3-mod_systemd.patch
Patch30: httpd-2.4.4-cachehardmax.patch
# Bug fixes # Bug fixes
Patch50: httpd-2.4.2-r1374214+.patch Patch50: httpd-2.4.2-r1374214+.patch
Patch51: httpd-2.4.3-sslsninotreq.patch Patch51: httpd-2.4.3-sslsninotreq.patch
@ -181,6 +182,7 @@ interface for storing and accessing per-user session data.
%patch27 -p1 -b .icons %patch27 -p1 -b .icons
%patch28 -p1 -b .r1332643+ %patch28 -p1 -b .r1332643+
%patch29 -p1 -b .systemd %patch29 -p1 -b .systemd
%patch30 -p1 -b .cachehardmax
%patch50 -p1 -b .r1374214+ %patch50 -p1 -b .r1374214+
%patch51 -p1 -b .sninotreq %patch51 -p1 -b .sninotreq
@ -609,6 +611,7 @@ rm -rf $RPM_BUILD_ROOT
* Thu Apr 18 2013 Jan Kaluza <jkaluza@redhat.com> - 2.4.4-5 * Thu Apr 18 2013 Jan Kaluza <jkaluza@redhat.com> - 2.4.4-5
- execute systemctl reload as result of apachectl graceful - execute systemctl reload as result of apachectl graceful
- mod_ssl: ignore SNI hints unless required by config - mod_ssl: ignore SNI hints unless required by config
- mod_cache: forward-port CacheMaxExpire "hard" option
* Tue Apr 16 2013 Jan Kaluza <jkaluza@redhat.com> - 2.4.4-4 * Tue Apr 16 2013 Jan Kaluza <jkaluza@redhat.com> - 2.4.4-4
- fix service file to not send SIGTERM after ExecStop (#906321, #912288) - fix service file to not send SIGTERM after ExecStop (#906321, #912288)