mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
mod_session: Introduce SessionExpiryUpdateInterval which allows to
configure the session/cookie expiry's update interval. PR 57300. Submitted by: Paul Spangler <paul.spangler ni.com> Reviewed/Committed by: ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1709121 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -177,6 +177,7 @@ static apr_status_t ap_session_save(request_rec * r, session_rec * z)
|
||||
{
|
||||
if (z) {
|
||||
apr_time_t now = apr_time_now();
|
||||
apr_time_t initialExpiry = z->expiry;
|
||||
int rv = 0;
|
||||
|
||||
session_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
|
||||
@@ -207,6 +208,17 @@ static apr_status_t ap_session_save(request_rec * r, session_rec * z)
|
||||
z->expiry = now + z->maxage * APR_USEC_PER_SEC;
|
||||
}
|
||||
|
||||
/* don't save if the only change is the expiry by a small amount */
|
||||
if (!z->dirty && dconf->expiry_update_time
|
||||
&& (z->expiry - initialExpiry < dconf->expiry_update_time)) {
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
/* also don't save sessions that didn't change at all */
|
||||
if (!z->dirty && !z->maxage) {
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
/* encode the session */
|
||||
rv = ap_run_session_encode(r, z);
|
||||
if (OK != rv) {
|
||||
@@ -551,6 +563,10 @@ static void *merge_session_dir_config(apr_pool_t * p, void *basev, void *addv)
|
||||
new->env_set = add->env_set || base->env_set;
|
||||
new->includes = apr_array_append(p, base->includes, add->includes);
|
||||
new->excludes = apr_array_append(p, base->excludes, add->excludes);
|
||||
new->expiry_update_time = (add->expiry_update_set == 0)
|
||||
? base->expiry_update_time
|
||||
: add->expiry_update_time;
|
||||
new->expiry_update_set = add->expiry_update_set || base->expiry_update_set;
|
||||
|
||||
return new;
|
||||
}
|
||||
@@ -620,6 +636,21 @@ static const char *add_session_exclude(cmd_parms * cmd, void *dconf, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
set_session_expiry_update(cmd_parms * parms, void *dconf, const char *arg)
|
||||
{
|
||||
session_dir_conf *conf = dconf;
|
||||
|
||||
conf->expiry_update_time = atoi(arg);
|
||||
if (conf->expiry_update_time < 0) {
|
||||
return "SessionExpiryUpdateInterval must be positive or nul";
|
||||
}
|
||||
conf->expiry_update_time = apr_time_from_sec(conf->expiry_update_time);
|
||||
conf->expiry_update_set = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static const command_rec session_cmds[] =
|
||||
{
|
||||
@@ -635,6 +666,9 @@ static const command_rec session_cmds[] =
|
||||
"URL prefixes to include in the session. Defaults to all URLs"),
|
||||
AP_INIT_TAKE1("SessionExclude", add_session_exclude, NULL, RSRC_CONF|OR_AUTHCFG,
|
||||
"URL prefixes to exclude from the session. Defaults to no URLs"),
|
||||
AP_INIT_TAKE1("SessionExpiryUpdateInterval", set_session_expiry_update, NULL, RSRC_CONF|OR_AUTHCFG,
|
||||
"time interval for which a session's expiry time may change "
|
||||
"without having to be rewritten. Zero to disable"),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user