From 750aa727b00a75e54f766a3d348e400666a4b69d Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Mon, 5 Jan 2015 10:06:29 +0000 Subject: [PATCH] * modules/cache/mod_socache_memcache.c (socache_mc_store): Pass through expiration time. Submitted by: Faidon Liambotis , jorton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1649491 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/cache/mod_socache_memcache.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b3c9af7518..52ac22360a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_socache_memcache: Pass expiration time through to memcached. + [Faidon Liambotis , Joe Orton] + *) split-logfile: Fix perl error: 'Can't use string ("example.org:80") as a symbol ref while "strict refs"'. PR 56329. [Holger Mauermann ] diff --git a/modules/cache/mod_socache_memcache.c b/modules/cache/mod_socache_memcache.c index 8cabd8a50b..b05b6ed36f 100644 --- a/modules/cache/mod_socache_memcache.c +++ b/modules/cache/mod_socache_memcache.c @@ -205,8 +205,14 @@ static apr_status_t socache_mc_store(ap_socache_instance_t *ctx, server_rec *s, return APR_EINVAL; } - /* In APR-util - unclear what 'timeout' is, as it was not implemented */ - rv = apr_memcache_set(ctx->mc, buf, (char*)ucaData, nData, 0, 0); + /* memcache needs time in seconds till expiry; fail if this is not + * positive *before* casting to unsigned (apr_uint32_t). */ + expiry -= apr_time_now(); + if (apr_time_sec(expiry) <= 0) { + return APR_EINVAL; + } + rv = apr_memcache_set(ctx->mc, buf, (char*)ucaData, nData, + apr_time_sec(expiry), 0); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(00790) -- 2.50.1