[dovecot-cvs] dovecot/src/lib-index mail-index.c, 1.230.2.4, 1.230.2.5 mail-transaction-log.c, 1.111, 1.111.2.1

cras at dovecot.org cras at dovecot.org
Sat Jun 17 16:42:38 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv25846

Modified Files:
      Tag: branch_1_0
	mail-index.c mail-transaction-log.c 
Log Message:
Handle transaction log deletions silently. Handle whole index directory
deletions silently (the most common cases anyway).



Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.230.2.4
retrieving revision 1.230.2.5
diff -u -d -r1.230.2.4 -r1.230.2.5
--- mail-index.c	17 Jun 2006 12:40:28 -0000	1.230.2.4
+++ mail-index.c	17 Jun 2006 13:42:36 -0000	1.230.2.5
@@ -1702,8 +1702,8 @@
 		if (errno != ENOENT)
 			return -1;
 
-		/* lost it? recreate */
-		(void)mail_index_mark_corrupted(index);
+		/* lost it? recreate later */
+		mail_index_mark_corrupted(index);
 		return -1;
 	}
 

Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.111
retrieving revision 1.111.2.1
diff -u -d -r1.111 -r1.111.2.1
--- mail-transaction-log.c	25 Apr 2006 13:40:20 -0000	1.111
+++ mail-transaction-log.c	17 Jun 2006 13:42:36 -0000	1.111.2.1
@@ -561,11 +561,25 @@
 				 dev_t dev, ino_t ino, uoff_t file_size)
 {
 	struct dotlock *dotlock;
-        mode_t old_mask;
+	struct stat st;
+	mode_t old_mask;
 	int fd;
 
 	i_assert(!MAIL_INDEX_IS_IN_MEMORY(log->index));
 
+	if (stat(log->index->dir, &st) < 0) {
+		if (ENOTFOUND(errno)) {
+			/* the whole index directory was deleted, which means
+			   the mailbox was deleted by another process.
+			   fail silently. */
+			mail_index_mark_corrupted(log->index);
+			return -1;
+		}
+		mail_index_file_set_syscall_error(log->index, log->index->dir,
+						  "stat()");
+		return -1;
+	}
+
 	/* With dotlocking we might already have path.lock created, so this
 	   filename has to be different. */
 	old_mask = umask(log->index->mode ^ 0666);
@@ -921,15 +935,19 @@
 	path = t_strconcat(log->index->filepath,
 			   MAIL_TRANSACTION_LOG_SUFFIX, NULL);
 	if (nfs_safe_stat(path, &st) < 0) {
-		mail_index_file_set_syscall_error(log->index, path, "stat()");
-		return -1;
-	}
-
-	if (log->head != NULL &&
-	    log->head->st_ino == st.st_ino &&
-	    CMP_DEV_T(log->head->st_dev, st.st_dev)) {
-		/* same file */
-		return 0;
+		if (errno != ENOENT) {
+			mail_index_file_set_syscall_error(log->index, path,
+							  "stat()");
+			return -1;
+		}
+		/* log was deleted. just reopen/recreate it. */
+	} else {
+		if (log->head != NULL &&
+		    log->head->st_ino == st.st_ino &&
+		    CMP_DEV_T(log->head->st_dev, st.st_dev)) {
+			/* same file */
+			return 0;
+		}
 	}
 
 	file = create_if_needed ?



More information about the dovecot-cvs mailing list