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

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


details:   http://hg.dovecot.org/dovecot-1.1/rev/a8331972aee5
changeset: 7759:a8331972aee5
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 ffbe9f9e0376 -r a8331972aee5 src/lib/fdatasync-path.c
--- a/src/lib/fdatasync-path.c	Fri Jul 18 17:55:02 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