diff options
author | Christophe Jaillet <jailletc36@apache.org> | 2015-09-01 10:23:01 +0200 |
---|---|---|
committer | Christophe Jaillet <jailletc36@apache.org> | 2015-09-01 10:23:01 +0200 |
commit | 6930a7b64dc633c7b6d8417f5529a5a07fd6aafd (patch) | |
tree | 3ee50b073023a76149b962b57cfac5715f9c2c76 /modules/cache | |
parent | Silence a sparse warning about inconsistent indenting + some minor style issues (diff) | |
download | apache2-6930a7b64dc633c7b6d8417f5529a5a07fd6aafd.tar.xz apache2-6930a7b64dc633c7b6d8417f5529a5a07fd6aafd.zip |
Allow 0 as a valid value (never close idle connections)
Increased maximum allowed value to 3600 s (1 hour)
Use 'ap_timeout_parameter_parse' to allow more flexible configuration (i.e. h, min, s, ms suffixes)
Use 'apr_time_from_sec' when applicable.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1700418 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/cache')
-rw-r--r-- | modules/cache/mod_socache_memcache.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/cache/mod_socache_memcache.c b/modules/cache/mod_socache_memcache.c index 795e23b579..86577a9f7b 100644 --- a/modules/cache/mod_socache_memcache.c +++ b/modules/cache/mod_socache_memcache.c @@ -51,13 +51,13 @@ #endif #ifndef MC_DEFAULT_SERVER_TTL -#define MC_DEFAULT_SERVER_TTL (15*1000*1000) /* 15 seconds */ +#define MC_DEFAULT_SERVER_TTL apr_time_from_sec(15) #endif module AP_MODULE_DECLARE_DATA socache_memcache_module; typedef struct { - unsigned int ttl; + apr_uint32_t ttl; } socache_mc_svr_cfg; struct ap_socache_instance_t { @@ -331,19 +331,22 @@ static void *create_server_config(apr_pool_t *p, server_rec *s) static const char *socache_mc_set_ttl(cmd_parms *cmd, void *dummy, const char *arg) { + apr_interval_time_t ttl; socache_mc_svr_cfg *sconf = ap_get_module_config(cmd->server->module_config, &socache_memcache_module); - int i; - i = atoi(arg); + if (ap_timeout_parameter_parse(arg, &ttl, "s") != APR_SUCCESS) { + return apr_pstrcat(cmd->pool, cmd->cmd->name, + " has wrong format", NULL); + } - if ((i < 1) || (i > 1800)) { + if ((ttl < apr_time_from_sec(0)) || (ttl > apr_time_from_sec(3600))) { return apr_pstrcat(cmd->pool, cmd->cmd->name, - " must be a number between 1 and 1800.", NULL); + " can only be 0 or up to one hour.", NULL); } /* apr_memcache_server_create needs a ttl in usec. */ - sconf->ttl = i * 1000 * 1000; + sconf->ttl = ttl; return NULL; } @@ -359,7 +362,7 @@ static void register_hooks(apr_pool_t *p) static const command_rec socache_memcache_cmds[] = { AP_INIT_TAKE1("MemcacheConnTTL", socache_mc_set_ttl, NULL, RSRC_CONF, - "TTL used for the connection with the memcache server(s), in seconds"), + "TTL used for the connection with the memcache server(s)"), { NULL } }; |