httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaillet...@apache.org
Subject svn commit: r1700418 - in /httpd/httpd/trunk: docs/manual/mod/mod_socache_memcache.xml modules/cache/mod_socache_memcache.c
Date Tue, 01 Sep 2015 08:23:02 GMT
Author: jailletc36
Date: Tue Sep  1 08:23:01 2015
New Revision: 1700418

URL: http://svn.apache.org/r1700418
Log:
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.

Modified:
    httpd/httpd/trunk/docs/manual/mod/mod_socache_memcache.xml
    httpd/httpd/trunk/modules/cache/mod_socache_memcache.c

Modified: httpd/httpd/trunk/docs/manual/mod/mod_socache_memcache.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_socache_memcache.xml?rev=1700418&r1=1700417&r2=1700418&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_socache_memcache.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_socache_memcache.xml Tue Sep  1 08:23:01 2015
@@ -55,20 +55,38 @@
 <directivesynopsis>
 <name>MemcacheConnTTL</name>
 <description>Keepalive time for idle connections</description>
-<syntax>MemcacheConnTTL <em>seconds</em></syntax>
-<default>MemcacheConnTTL 15</default>
+<syntax>MemcacheConnTTL <em>num[units]</em></syntax>
+<default>MemcacheConnTTL 15s</default>
 <contextlist>
 <context>server config</context>
 <context>virtual host</context>
 </contextlist>
+<compatibility>Available in Apache 2.4.17 and later</compatibility>
 
 <usage>
 
-    <p>Set the time, in seconds, to keep idle connections with the memcache
-    server(s) alive (threaded platforms only).</p>
+    <p>Set the time to keep idle connections with the memcache server(s)
+    alive (threaded platforms only).</p>
     
-    <p>Valid values for <directive>MemcacheConnTTL</directive> are integers
-    from 1 to 1800. That is to say, up to half an hour.</p>
+    <p>Valid values for <directive>MemcacheConnTTL</directive> are times
+    up to one hour. 0 means no timeout.</p>
+
+    <note><p>This timeout defaults to units of seconds, but accepts
+    suffixes for milliseconds (ms), seconds (s), minutes (min), and hours (h).
+    </p></note>
+
+    <p>Before Apache 2.4.17, this timeout was hardcoded and its value was 600 usec.
+    So, the closest configuration to match the legacy behaviour is to set
+    <directive>MemcacheConnTTL</directive> to 1ms.</p>
+
+    <example>
+    <highlight language="config">
+# Set a timeout of 10 minutes
+MemcacheConnTTL 10min
+# Set a timeout of 60 seconds
+MemcacheConnTTL 60
+    </highlight>
+    </example>
 
 </usage>
 </directivesynopsis>

Modified: httpd/httpd/trunk/modules/cache/mod_socache_memcache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_memcache.c?rev=1700418&r1=1700417&r2=1700418&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_memcache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_memcache.c Tue Sep  1 08:23:01 2015
@@ -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_po
 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 }
 };
 



Mime
View raw message