diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-29 23:07:18 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-29 23:07:18 +0000 |
commit | e5f5b81d65a5ed9b34910a58707b870d677c6183 (patch) | |
tree | 6e87cfda96222560751e200ca5ef7dd8d7cd65f4 /src/caches/dcache_clean_expired.c | |
parent | 5b063a4db3e631d40c05b77ecc7554ebdf5fff92 (diff) | |
download | s6-dns-e5f5b81d65a5ed9b34910a58707b870d677c6183.tar.xz |
Refactor libdcache, expose dcache_clean_expired()
Diffstat (limited to 'src/caches/dcache_clean_expired.c')
-rw-r--r-- | src/caches/dcache_clean_expired.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/caches/dcache_clean_expired.c b/src/caches/dcache_clean_expired.c new file mode 100644 index 0000000..5308d8a --- /dev/null +++ b/src/caches/dcache_clean_expired.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +#include <stdint.h> + +#include <skalibs/tai.h> +#include <skalibs/avltree.h> + +#include <s6-dns/dcache.h> +#include "dcache-internal.h" + +void dcache_clean_expired (dcache_t *z, tain_t 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) ; + } +} |