diff options
author | Matt Johnston <matt@ucc.asn.au> | 2016-11-19 00:31:21 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2016-11-19 00:31:21 +0800 |
commit | 597f12c44a000add479c6a0b416e8c0847b59b20 (patch) | |
tree | d6d1aa9862e2214767ab6c4ee7f5ac66c4290a3f /dbutil.c | |
parent | 9025cd9b72bf316f4d84b71b03af25675c834ff9 (diff) |
Use atomic key generation in all cases
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -681,4 +681,21 @@ time_t monotonic_now() { return time(NULL); } +void fsync_parent_dir(const char* fn) { +#ifdef HAVE_LIBGEN_H + char *fn_dir = m_strdup(fn); + char *dir = dirname(fn_dir); + int dirfd = open(dir, O_RDONLY); + + if (dirfd != -1) { + if (fsync(dirfd) != 0) { + TRACE(("fsync of directory %s failed: %s", dir, strerror(errno))) + } + m_close(dirfd); + } else { + TRACE(("error opening directory %s for fsync: %s", dir, strerror(errno))) + } + free(fn_dir); +#endif +} |