changeset 602:03ea377ed93b HEAD

If mbox opening fails, don't leave the lock files lying around.
author Timo Sirainen <tss@iki.fi>
date Wed, 13 Nov 2002 02:43:14 +0200
parents bfa9ab91eba7
children abb584aabe31
files src/lib-index/mail-index-open.c src/lib-index/mail-index.c
diffstat 2 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-open.c	Wed Nov 13 02:14:46 2002 +0200
+++ b/src/lib-index/mail-index-open.c	Wed Nov 13 02:43:14 2002 +0200
@@ -242,9 +242,6 @@
 	if (!mail_index_open_init(index, update_recent))
 		return FALSE;
 
-	if (!index->set_lock(index, MAIL_LOCK_UNLOCK))
-		return FALSE;
-
 	return TRUE;
 }
 
@@ -252,7 +249,7 @@
 				int update_recent, int fast)
 {
         MailIndexHeader hdr;
-	int fd;
+	int fd, failed;
 
 	/* the index file should already be checked that it exists and
 	   we're compatible with it. */
@@ -285,7 +282,12 @@
 	index->filepath = i_strdup(path);
 	index->indexid = hdr.indexid;
 
-	if (!index_open_and_fix(index, update_recent, fast)) {
+	failed = !index_open_and_fix(index, update_recent, fast);
+
+	if (!index->set_lock(index, MAIL_LOCK_UNLOCK))
+		failed = TRUE;
+
+	if (failed) {
 		mail_index_close(index);
 		return FALSE;
 	}
@@ -463,6 +465,8 @@
 		return TRUE;
 	} while (0);
 
+	(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
+
 	mail_index_close(index);
 	return FALSE;
 }
--- a/src/lib-index/mail-index.c	Wed Nov 13 02:14:46 2002 +0200
+++ b/src/lib-index/mail-index.c	Wed Nov 13 02:43:14 2002 +0200
@@ -418,7 +418,8 @@
 	}
 
 	if (index->lock_type == MAIL_LOCK_EXCLUSIVE) {
-		mail_modifylog_notify_lock_drop(index->modifylog);
+		if (index->modifylog != NULL)
+			mail_modifylog_notify_lock_drop(index->modifylog);
 
 		/* dropping exclusive lock (either unlock or to shared) */
 		keep_fsck = (index->set_flags & MAIL_INDEX_FLAG_FSCK) != 0;