[SSSD] [PATCH] negcache: Soften condition for expired entries
Lukas Slebodnik
lslebodn at redhat.com
Wed May 20 11:35:59 UTC 2015
ehlo,
Type of timestamp for entries in negative cache is time_t
which is number of *seconds* that have elapsed since 1 January 1970.
The condition for ttl was to strict so entry could be valid
from "ttl-1" to ttl e.g.
* ttl is 1 second
* entry was stored to negative cache at 1432120871.999639
stored_timestamp = 1432120871
* entry was tested few miliseconds later 1432120872.001293
current_time = 1432120872
Entry was marked as expired becuase result of condition was false
stored_timestamp + ttl < current_time
1432120871 + 1 < 1432120872
This is a reason why ./test-negcache sometime fails.
It's quite easily reproducible on slow machine or when valgrind was used.
sh$ while libtool --mode=execute valgrind ./test-negcache ; do echo OK: done
It would be good to push patch to master and sssd-1-12.
So we can get gid of problematic failed tests in CI.
LS
-------------- next part --------------
>From dbca992b4f967af485a6d2180349c0795c05f220 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 20 May 2015 13:13:40 +0200
Subject: [PATCH] negcache: Soften condition for expired entries
Type of timestamp for entries in negative cache is time_t
which is number of *seconds* that have elapsed since 1 January 1970.
The condition for ttl was to strict so entry could be valid
from "ttl-1" to ttl e.g.
* ttl is 1 second
* entry was stored to negative cache at 1432120871.999639
stored_timestamp = 1432120871
* entry was tested few miliseconds later 1432120872.001293
current_time = 1432120872
Entry was marked as expired becuase result of condition was false
stored_timestamp + ttl < current_time
1432120871 + 1 < 1432120872
This is a reason why ./test-negcache sometime fails.
It's quite easily reproducible on slow machine or when valgrind was used.
sh$ while libtool --mode=execute valgrind ./test-negcache ; do echo OK: done
---
src/responder/common/negcache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c
index 2fa61af53dd2d42ae4df2a3db17edf4978ed78a1..cf70dc52fe122328810064ebd112aec501f892a4 100644
--- a/src/responder/common/negcache.c
+++ b/src/responder/common/negcache.c
@@ -116,7 +116,7 @@ static int sss_ncache_check_str(struct sss_nc_ctx *ctx, char *str, int ttl)
goto done;
}
- if (timestamp + ttl > time(NULL)) {
+ if (timestamp + ttl >= time(NULL)) {
/* still valid */
ret = EEXIST;
goto done;
--
2.4.1
More information about the sssd-devel
mailing list