changeset 2491:e7e99c2b3cb5 HEAD

We kept exclusive index lock too long which caused deadlocks.
author Timo Sirainen <tss@iki.fi>
date Wed, 25 Aug 2004 11:06:15 +0300
parents 0284ec4e6ed7
children 11da9df0890c
files src/lib-index/mail-index-lock.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-lock.c	Tue Aug 24 13:12:00 2004 +0300
+++ b/src/lib-index/mail-index-lock.c	Wed Aug 25 11:06:15 2004 +0300
@@ -276,16 +276,6 @@
 
 static int mail_index_copy_lock_finish(struct mail_index *index)
 {
-	if (index->shared_lock_count > 0 && !index->fcntl_locks_disable) {
-		/* leave ourself shared locked. */
-		if (file_try_lock(index->fd, F_RDLCK) <= 0) {
-			mail_index_file_set_syscall_error(index,
-							  index->copy_lock_path,
-							  "file_try_lock()");
-			return -1;
-		}
-	}
-
 	if (fsync(index->fd) < 0) {
 		mail_index_file_set_syscall_error(index, index->copy_lock_path,
 						  "fsync()");
@@ -324,6 +314,15 @@
 			(void)close(fd);
 	}
 
+	if (index->shared_lock_count > 0 && !index->fcntl_locks_disable) {
+		/* leave ourself shared locked. */
+		if (file_try_lock(index->fd, F_RDLCK) <= 0) {
+			mail_index_file_set_syscall_error(index,
+							  index->copy_lock_path,
+							  "file_try_lock()");
+		}
+	}
+
 	if (index->copy_lock_path != NULL) {
 		i_assert(index->log_locked);