changeset 12300:0dae63c1af96

lib-index: More undoing of locking code changes.
author Timo Sirainen <tss@iki.fi>
date Mon, 18 Oct 2010 16:14:08 +0100
parents 7b47c5a321b9
children 17957b5082cd
files src/lib-index/mail-index-lock.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-lock.c	Mon Oct 18 16:07:17 2010 +0100
+++ b/src/lib-index/mail-index-lock.c	Mon Oct 18 16:14:08 2010 +0100
@@ -74,9 +74,15 @@
 		return 1;
 	}
 
-	i_assert(index->file_lock == NULL);
-	ret = mail_index_lock_fd(index, index->filepath, index->fd,
-				 lock_type, timeout_secs, &index->file_lock);
+	if (index->file_lock == NULL) {
+		i_assert(index->lock_type == F_UNLCK);
+		ret = mail_index_lock_fd(index, index->filepath, index->fd,
+					 lock_type, timeout_secs,
+					 &index->file_lock);
+	} else {
+		i_assert(index->lock_type == F_RDLCK && lock_type == F_WRLCK);
+		ret = file_lock_try_update(index->file_lock, lock_type);
+	}
 	if (ret <= 0)
 		return ret;