dovecot-2.1: Maildir++ quota: Close maildirsize file after writi...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jan 20 17:06:12 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/00a27339f541
changeset: 13962:00a27339f541
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jan 20 17:06:06 2012 +0200
description:
Maildir++ quota: Close maildirsize file after writing to it to force NFS to write it.
This should fix the "Stale NFS file handle" errors with maildirsize.

diffstat:

 src/plugins/quota/quota-maildir.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 8714ccb35848 -r 00a27339f541 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Fri Jan 20 16:54:17 2012 +0200
+++ b/src/plugins/quota/quota-maildir.c	Fri Jan 20 17:06:06 2012 +0200
@@ -706,6 +706,14 @@
 			i_error("write_full(%s) failed: %m",
 				root->maildirsize_path);
 		}
+	} else {
+		/* close the file to force a flush with NFS */
+		if (close(root->fd) < 0) {
+			ret = -1;
+			if (errno != ESTALE)
+				i_error("close(%s) failed: %m", root->maildirsize_path);
+		}
+		root->fd = -1;
 	}
 	return ret;
 }
@@ -870,8 +878,10 @@
 		root->fd = -1;
 		(void)maildirsize_recalculate(root);
 	} else if (maildirsize_update(root, ctx->count_used, ctx->bytes_used) < 0) {
-		(void)close(root->fd);
-		root->fd = -1;
+		if (root->fd != -1) {
+			(void)close(root->fd);
+			root->fd = -1;
+		}
 		maildirsize_rebuild_later(root);
 	}
 


More information about the dovecot-cvs mailing list