From 1360696c2d6ed7083a71979c8382c9d34df12cf0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 30 Jul 2024 14:36:22 +0000 Subject: More stuff Signed-off-by: Laurent Bercot --- src/libdcache/dcache_search.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/libdcache/dcache_search.c') diff --git a/src/libdcache/dcache_search.c b/src/libdcache/dcache_search.c index 0239b88..3d79dd6 100644 --- a/src/libdcache/dcache_search.c +++ b/src/libdcache/dcache_search.c @@ -7,9 +7,18 @@ #include #include "dcache-internal.h" -dcache_node_t *dcache_search (dcache_t *z, char const *key, uint16_t keylen) +dcache_node_t *dcache_search (dcache_t *z, char const *key, uint16_t keylen, tain const *stamp) { uint32_t i ; dcache_key_t k = { .s = (char *)key, .len = keylen } ; - return avltree_search(&z->by_key, &k, &i) ? DNODE(z, i) : 0 ; + if (avltree_search(&z->by_key, &k, &i)) + { + if (tain_less(&DNODE(z, i)->expire, stamp)) + { + dcache_clean_expired(z, stamp) ; + if (!avltree_search(&z->by_key, &k, &i)) return 0 ; + } + return DNODE(z, i) ; + } + else return 0 ; } -- cgit v1.2.3