summaryrefslogtreecommitdiff
path: root/source3/lib/gencache.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/gencache.c')
-rw-r--r--source3/lib/gencache.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index b773f83c58..1b4342a62b 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -166,15 +166,16 @@ bool gencache_del(const char *keystr)
*
* @param keystr string that represents a key of this entry
* @param valstr buffer that is allocated and filled with the entry value
- * buffer's disposing must be done outside
- * @param timeout pointer to a time_t that is filled with entry's
- * timeout
+ * buffer's disposing must be done outside
+ * @param timeout If == NULL, the caller is not interested in timed out
+ * entries. If != NULL, return the timeout timestamp, the
+ * caller must figure out itself if this entry is timed out.
*
* @retval true when entry is successfuly fetched
* @retval False for failure
**/
-bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
+bool gencache_get(const char *keystr, char **valstr, time_t *ptimeout)
{
TDB_DATA databuf;
time_t t;
@@ -207,9 +208,13 @@ 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)) {
+ if ((t <= time(NULL)) && (ptimeout == NULL)) {
+
+ /*
+ * The entry is expired, and the caller isn't interested in
+ * timed out ones. Delete it.
+ */
- /* We're expired, delete the entry */
tdb_delete_bystring(cache, keystr);
SAFE_FREE(databuf.dptr);
@@ -224,15 +229,15 @@ bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
return False;
}
}
-
+
SAFE_FREE(databuf.dptr);
- if (timeout) {
- *timeout = t;
+ if (ptimeout) {
+ *ptimeout = t;
}
return True;
-}
+}
/**
* Get existing entry from the cache file.