On Mon, 2010-01-25 at 12:57 -0500, David Halik wrote:
> Jan 25 11:39:24 gehenna21 dovecot: IMAP(user): 
> fdatasync(/rci/nqu/rci/u8/user/dovecot/.INBOX/dovecot-uidlist) failed: 
> Stale NFS file handle

Well, two possibilities:

a) The attached patch fixes this

b) Dotlocking isn't working for you..

diff -r 0ff07b4ad306 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Jan 25 20:24:54 2010 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Jan 25 20:30:25 2010 +0200
@@ -904,11 +904,10 @@
 	}
 }
 
-int maildir_uidlist_refresh(struct maildir_uidlist *uidlist)
+static int maildir_uidlist_open_latest(struct maildir_uidlist *uidlist)
 {
-        unsigned int i;
-        bool retry, recreated;
-        int ret;
+	bool recreated;
+	int ret;
 
 	if (uidlist->fd != -1) {
 		ret = maildir_uidlist_has_changed(uidlist, &recreated);
@@ -918,10 +917,29 @@
 			return ret < 0 ? -1 : 1;
 		}
 
-		if (recreated)
-			maildir_uidlist_close(uidlist);
+		if (!recreated)
+			return 0;
+		maildir_uidlist_close(uidlist);
 	}
 
+	uidlist->fd = nfs_safe_open(uidlist->path, O_RDWR);
+	if (uidlist->fd == -1 && errno != ENOENT) {
+		mail_storage_set_critical(uidlist->ibox->box.storage,
+			"open(%s) failed: %m", uidlist->path);
+		return -1;
+	}
+	return 0;
+}
+
+int maildir_uidlist_refresh(struct maildir_uidlist *uidlist)
+{
+        unsigned int i;
+        bool retry;
+        int ret;
+
+	if (maildir_uidlist_open_latest(uidlist) < 0)
+		return -1;
+
         for (i = 0; ; i++) {
 		ret = maildir_uidlist_update_read(uidlist, &retry,
 						i < UIDLIST_ESTALE_RETRY_COUNT);
@@ -1512,18 +1530,12 @@
 	if (maildir_uidlist_want_recreate(ctx))
 		return maildir_uidlist_recreate(uidlist);
 
-	if (uidlist->fd == -1) {
-		/* NOREFRESH flag used. we're just appending some messages. */
+	if (!uidlist->locked_refresh) {
+		/* make sure we have the latest file (e.g. NOREFRESH used) */
 		i_assert(uidlist->initial_hdr_read);
-
-		uidlist->fd = nfs_safe_open(uidlist->path, O_RDWR);
-		if (uidlist->fd == -1) {
-			mail_storage_set_critical(storage,
-				"open(%s) failed: %m", uidlist->path);
+		if (maildir_uidlist_open_latest(uidlist) < 0)
 			return -1;
-		}
 	}
-
 	i_assert(ctx->first_unwritten_pos != (unsigned int)-1);
 
 	if (lseek(uidlist->fd, 0, SEEK_END) < 0) {

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to