[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.16, 1.17 mail-index.c, 1.126, 1.127 mail-transaction-log.c, 1.30, 1.31

cras at procontrol.fi cras at procontrol.fi
Fri May 28 04:04:04 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv26024/lib-index

Modified Files:
	mail-index-private.h mail-index.c mail-transaction-log.c 
Log Message:
Don't complain about transaction log indexid changes when rebuilding index.



Index: mail-index-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- a/mail-index-private.h	25 May 2004 23:13:57 -0000	1.16
+++ b/mail-index-private.h	28 May 2004 01:04:01 -0000	1.17
@@ -73,7 +73,6 @@
 	unsigned int fsck:1;
 };
 
-void mail_index_header_init(struct mail_index_header *hdr);
 int mail_index_write_header(struct mail_index *index,
 			    const struct mail_index_header *hdr);
 

Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- a/mail-index.c	25 May 2004 23:13:57 -0000	1.126
+++ b/mail-index.c	28 May 2004 01:04:01 -0000	1.127
@@ -425,28 +425,6 @@
 	return ret;
 }
 
-void mail_index_header_init(struct mail_index_header *hdr)
-{
-	time_t now = time(NULL);
-
-	memset(hdr, 0, sizeof(*hdr));
-
-	hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
-	hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
-	hdr->header_size = sizeof(*hdr);
-
-#ifndef WORDS_BIGENDIAN
-	hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
-#endif
-	hdr->compat_data[1] = sizeof(uoff_t);
-	hdr->compat_data[2] = sizeof(time_t);
-	hdr->compat_data[3] = sizeof(keywords_mask_t);
-
-	hdr->indexid = now;
-
-	hdr->next_uid = 1;
-}
-
 int mail_index_write_header(struct mail_index *index,
 			    const struct mail_index_header *hdr)
 {
@@ -545,6 +523,28 @@
 	return 1;
 }
 
+static void mail_index_header_init(struct mail_index_header *hdr)
+{
+	time_t now = time(NULL);
+
+	memset(hdr, 0, sizeof(*hdr));
+
+	hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
+	hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
+	hdr->header_size = sizeof(*hdr);
+
+#ifndef WORDS_BIGENDIAN
+	hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+#endif
+	hdr->compat_data[1] = sizeof(uoff_t);
+	hdr->compat_data[2] = sizeof(time_t);
+	hdr->compat_data[3] = sizeof(keywords_mask_t);
+
+	hdr->indexid = now;
+
+	hdr->next_uid = 1;
+}
+
 static int mail_index_open_files(struct mail_index *index,
 				 enum mail_index_open_flags flags)
 {

Index: mail-transaction-log.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- a/mail-transaction-log.c	24 May 2004 01:50:16 -0000	1.30
+++ b/mail-transaction-log.c	28 May 2004 01:04:01 -0000	1.31
@@ -307,12 +307,13 @@
 			file->filepath);
 		return 0;
 	}
-	if (file->hdr.indexid != file->log->index->indexid &&
-	    file->log->index->indexid != 0) {
-		/* either index was just recreated, or transaction has wrong
-		   indexid. we don't know here which one is the case, so we'll
-		   just fail. If index->indexid == 0, we're rebuilding it and
-		   we just want to lock the transaction log. */
+	if (file->hdr.indexid != file->log->index->indexid) {
+		if (file->log->index->fd == -1) {
+			/* creating index file, silently rebuild
+			   transaction log as well */
+			return 0;
+		}
+
 		mail_index_set_error(file->log->index,
 			"Transaction log file %s: invalid indexid (%u != %u)",
 			file->filepath, file->hdr.indexid,



More information about the dovecot-cvs mailing list