dovecot-2.2: maildir++ quota: If reading maildirsize fails with ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 20:57:39 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/cad676b57cc8
changeset: 14656:cad676b57cc8
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 15 15:12:33 2012 +0300
description:
maildir++ quota: If reading maildirsize fails with ESTALE, retry it.

diffstat:

 src/plugins/quota/quota-maildir.c |  23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diffs (57 lines):

diff -r c58a27eecdd4 -r cad676b57cc8 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Wed Jun 13 16:29:37 2012 +0300
+++ b/src/plugins/quota/quota-maildir.c	Fri Jun 15 15:12:33 2012 +0300
@@ -546,12 +546,15 @@
 		!CMP_DEV_T(st1.st_dev, st2.st_dev);
 }
 
-static int maildirsize_read(struct maildir_quota_root *root)
+static int maildirsize_read(struct maildir_quota_root *root, bool *retry)
 {
 	char buf[5120+1];
 	unsigned int i, size;
+	bool retry_estale = *retry;
 	int ret;
 
+	*retry = FALSE;
+
 	if (!maildirsize_has_changed(root))
 		return 1;
 
@@ -562,8 +565,10 @@
 	size = 0;
 	while ((ret = read(root->fd, buf + size, sizeof(buf)-1 - size)) != 0) {
 		if (ret < 0) {
-			if (errno == ESTALE)
+			if (errno == ESTALE && retry_estale) {
+				*retry = TRUE;
 				break;
+			}
 			i_error("read(%s) failed: %m", root->maildirsize_path);
 			break;
 		}
@@ -644,14 +649,20 @@
 
 static int maildirquota_read_limits(struct maildir_quota_root *root)
 {
-	int ret;
+	bool retry = TRUE;
+	int ret, n = 0;
 
 	if (!maildirquota_limits_init(root))
 		return 1;
 
-	T_BEGIN {
-		ret = maildirsize_read(root);
-	} T_END;
+	do {
+		if (n == NFS_ESTALE_RETRY_COUNT)
+			retry = FALSE;
+		T_BEGIN {
+			ret = maildirsize_read(root, &retry);
+		} T_END;
+		n++;
+	} while (ret == -1 && retry);
 	return ret;
 }
 


More information about the dovecot-cvs mailing list