Mercurial > hg > audiodb
changeset 563:c6036e0a511a
Work around the non-universality of fdatasync()
POSIX, which specifies fdatasync(), also apparently specifies that
POSIX_SYNCHRONIZED_IO is defined to a non-zero value if fdatasync() is
available -- or at least that's what the man page suggests on Linux.
This is probably good enough for us, anyway.
author | mas01cr |
---|---|
date | Thu, 18 Jun 2009 11:01:31 +0000 |
parents | dfeb5ef768da |
children | 048688d47697 |
files | audioDB-internals.h |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB-internals.h Fri Apr 17 16:52:15 2009 +0000 +++ b/audioDB-internals.h Thu Jun 18 11:01:31 2009 +0000 @@ -1,3 +1,6 @@ +#include <sys/types.h> +#include <unistd.h> + #include <set> #include <queue> #include <map> @@ -179,8 +182,11 @@ goto error; } - /* can be fsync() if fdatasync() is racily exciting and new */ +#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) fdatasync(adb->fd); +#else + fsync(adb->fd); +#endif if(lseek(adb->fd, pos, SEEK_SET) == (off_t) -1) { goto error; }