diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-09-09 21:40:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:51:19 -0500 |
commit | 554e68887bc84510690226c9b07a872e7a282abe (patch) | |
tree | e88d6106321e69e9a3cff8dd6e1f8be9d15bc2f9 /source/lib/gencache.c | |
parent | f6497adac674f9e5089a2e54ead07596e568a936 (diff) | |
download | samba-554e68887bc84510690226c9b07a872e7a282abe.tar.gz samba-554e68887bc84510690226c9b07a872e7a282abe.tar.xz samba-554e68887bc84510690226c9b07a872e7a282abe.zip |
r18312: Change gencache_get slightly: Delete expired keys, and only strdup the value
if a valid entry was found. The newer calls got the latter one wrong, change
the older calls.
Volker
Diffstat (limited to 'source/lib/gencache.c')
-rw-r--r-- | source/lib/gencache.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/lib/gencache.c b/source/lib/gencache.c index 871d1d1d802..dc5f32d66ea 100644 --- a/source/lib/gencache.c +++ b/source/lib/gencache.c @@ -212,6 +212,15 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout) "timeout = %s", t > time(NULL) ? "valid" : "expired", keystr, endptr+1, ctime(&t))); + if (t <= time(NULL)) { + + /* We're expired, delete the entry */ + tdb_delete(cache, keybuf); + + SAFE_FREE(databuf.dptr); + return False; + } + if (valstr) { *valstr = SMB_STRDUP(endptr+1); if (*valstr == NULL) { @@ -227,7 +236,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout) *timeout = t; } - return t > time(NULL); + return True; } |