aboutsummaryrefslogtreecommitdiffstats
path: root/src/libdcache/dcache_clean_expired.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2024-07-16 01:51:04 +0000
committerLaurent Bercot <ska@appnovation.com>2024-07-16 01:51:04 +0000
commitd1c4602f80e395d1d6ab0453b8f0a6cc10aefadf (patch)
tree9e1410955b66e99d2284b0baa207d32264669716 /src/libdcache/dcache_clean_expired.c
parent8b435b76d68dd8f11808f0cff4d8998d2be48f4c (diff)
downloadshibari-d1c4602f80e395d1d6ab0453b8f0a6cc10aefadf.tar.gz
Refactor dcache, add prep for shibari-cache
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libdcache/dcache_clean_expired.c')
-rw-r--r--src/libdcache/dcache_clean_expired.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libdcache/dcache_clean_expired.c b/src/libdcache/dcache_clean_expired.c
new file mode 100644
index 0000000..0e23443
--- /dev/null
+++ b/src/libdcache/dcache_clean_expired.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/tai.h>
+#include <skalibs/avltree.h>
+
+#include <shibari/dcache.h>
+#include "dcache-internal.h"
+
+void dcache_clean_expired (dcache_t *z, tain const *stamp)
+{
+ for (;;)
+ {
+ uint32_t i ;
+ if (!avltree_min(&z->by_expire, &i)) break ;
+ if (tain_less(stamp, &DNODE(z, i)->expire)) break ;
+ dcache_delete(z, i) ;
+ }
+}