summaryrefslogtreecommitdiff
path: root/src/caches/dcache_save.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-12-29 23:07:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-12-29 23:07:18 +0000
commite5f5b81d65a5ed9b34910a58707b870d677c6183 (patch)
tree6e87cfda96222560751e200ca5ef7dd8d7cd65f4 /src/caches/dcache_save.c
parent5b063a4db3e631d40c05b77ecc7554ebdf5fff92 (diff)
downloads6-dns-e5f5b81d65a5ed9b34910a58707b870d677c6183.tar.xz
Refactor libdcache, expose dcache_clean_expired()
Diffstat (limited to 'src/caches/dcache_save.c')
-rw-r--r--src/caches/dcache_save.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/caches/dcache_save.c b/src/caches/dcache_save.c
index 1ef35f0..04d1dac 100644
--- a/src/caches/dcache_save.c
+++ b/src/caches/dcache_save.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <stdint.h>
+#include <unistd.h>
#include <stdio.h>
#include <skalibs/posixplz.h>
@@ -57,7 +58,7 @@ int dcache_save (dcache_t const *z, char const *file)
fd = open_excl(sa.s) ;
if (fd == -1) goto err0 ;
buffer_init(&b, &buffer_write, fd, buf, N) ;
- if (!dcache_save_to_buffer(z, &b)) goto err2 ;
+ if (!dcache_save_to_buffer(z, &b) || fsync(fd) < 0) goto err2 ;
fd_close(fd) ;
if (rename(sa.s, file) == -1) goto err1 ;
stralloc_free(&sa) ;