changeset 269:a4eb58705351 HEAD

FSCK flag is removed at set_lock(), so it can't be directly set anywhere.. but using index->set_flags |= FSCK now keeps it. fixes mbox problems after flag changes.
author Timo Sirainen <tss@iki.fi>
date Tue, 17 Sep 2002 08:19:22 +0300
parents 7cb03d43a0ea
children 6dfdda80e822
files src/lib-index/mail-index.c src/lib-index/mbox/mbox-rewrite.c src/lib-storage/index/index-expunge.c
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Tue Sep 17 08:17:10 2002 +0300
+++ b/src/lib-index/mail-index.c	Tue Sep 17 08:19:22 2002 +0300
@@ -361,6 +361,8 @@
 
 int mail_index_set_lock(MailIndex *index, MailLockType lock_type)
 {
+	int keep_fsck;
+
 	if (index->lock_type == lock_type)
 		return TRUE;
 
@@ -373,10 +375,11 @@
 
 	if (index->lock_type == MAIL_LOCK_EXCLUSIVE) {
 		/* dropping exclusive lock (either unlock or to shared) */
+		keep_fsck = (index->set_flags & MAIL_INDEX_FLAG_FSCK) != 0;
 		mail_index_update_header_changes(index);
 
 		/* remove the FSCK flag only after successful fsync() */
-		if (mail_index_sync_file(index)) {
+		if (mail_index_sync_file(index) && !keep_fsck) {
 			index->header->flags &= ~MAIL_INDEX_FLAG_FSCK;
 			if (msync(index->mmap_base, sizeof(MailIndexHeader),
 				  MS_SYNC) < 0) {
--- a/src/lib-index/mbox/mbox-rewrite.c	Tue Sep 17 08:17:10 2002 +0300
+++ b/src/lib-index/mbox/mbox-rewrite.c	Tue Sep 17 08:19:22 2002 +0300
@@ -348,8 +348,10 @@
 
 	if (!failed) {
 		if (rename(path, index->mbox_path) == 0) {
-			/* all ok, we need to fsck the index next time */
-			index->header->flags |= MAIL_INDEX_FLAG_FSCK;
+			/* all ok, we need to fsck the index next time.
+			   use set_flags because set_lock() would remove it
+			   if we modified it directly */
+			index->set_flags |= MAIL_INDEX_FLAG_FSCK;
 			reset_dirty_flags(index);
 		} else {
 			index_set_error(index, "rename(%s, %s) failed: %m",
--- a/src/lib-storage/index/index-expunge.c	Tue Sep 17 08:17:10 2002 +0300
+++ b/src/lib-storage/index/index-expunge.c	Tue Sep 17 08:19:22 2002 +0300
@@ -32,7 +32,7 @@
 				hdr->first_deleted_uid_lowwater);
 
 			/* fsck should be enough to fix it */
-			ibox->index->header->flags |= MAIL_INDEX_FLAG_FSCK;
+			ibox->index->set_flags |= MAIL_INDEX_FLAG_FSCK;
 			return FALSE;
 		} else {
 			*seq = ibox->index->get_sequence(ibox->index, *rec);