dovecot-1.2: fdatasync_path(): Ignore EBADF errors, it probably ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 20 15:24:24 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/164bdad216b8
changeset: 8012:164bdad216b8
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 20 15:24:05 2008 +0300
description:
fdatasync_path(): Ignore EBADF errors, it probably means directory fsyncing
isn't allowed (e.g. NetBSD).

diffstat:

1 file changed, 8 insertions(+), 2 deletions(-)
src/lib/fdatasync-path.c |   10 ++++++++--

diffs (20 lines):

diff -r 2d902d1f8bea -r 164bdad216b8 src/lib/fdatasync-path.c
--- a/src/lib/fdatasync-path.c	Sat Jul 19 14:43:24 2008 +0300
+++ b/src/lib/fdatasync-path.c	Sun Jul 20 15:24:05 2008 +0300
@@ -15,8 +15,14 @@ int fdatasync_path(const char *path)
 	fd = open(path, O_RDONLY);
 	if (fd == -1)
 		return -1;
-	if (fdatasync(fd) < 0)
-		ret = -1;
+	if (fdatasync(fd) < 0) {
+		if (errno == EBADF) {
+			/* At least NetBSD doesn't allow fsyncing directories.
+			   Silently ignore the problem. */
+		} else {
+			ret = -1;
+		}
+	}
 	(void)close(fd);
 	return ret;
 }


More information about the dovecot-cvs mailing list