changeset 2894:e7d6ae64fd68 HEAD

When committing transaction, don't do index locking unless we really want to try rotating the log file.
author Timo Sirainen <tss@iki.fi>
date Wed, 24 Nov 2004 22:41:35 +0200
parents fd431866c674
children 51be21fc2c9d
files src/lib-index/mail-transaction-log.c
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c	Wed Nov 24 22:40:39 2004 +0200
+++ b/src/lib-index/mail-transaction-log.c	Wed Nov 24 22:41:35 2004 +0200
@@ -1224,19 +1224,19 @@
 		}
 	}
 
-	if (mail_index_lock_shared(log->index, TRUE, &lock_id) < 0) {
-		if (!log->index->log_locked)
-			mail_transaction_log_file_unlock(log->head);
-		return -1;
-	}
-	idx_hdr = *log->index->hdr;
-	mail_index_unlock(log->index, lock_id);
-
 	if (log->head->sync_offset > MAIL_TRANSACTION_LOG_ROTATE_SIZE &&
 	    log->head->last_mtime <
 	    ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME) {
 		/* we might want to rotate, but check first that everything is
 		   synced in index. */
+		if (mail_index_lock_shared(log->index, TRUE, &lock_id) < 0) {
+			if (!log->index->log_locked)
+				mail_transaction_log_file_unlock(log->head);
+			return -1;
+		}
+		idx_hdr = *log->index->hdr;
+		mail_index_unlock(log->index, lock_id);
+
 		if (log->head->hdr.file_seq == idx_hdr.log_file_seq &&
 		    log->head->sync_offset == idx_hdr.log_file_int_offset &&
 		    log->head->sync_offset == idx_hdr.log_file_ext_offset) {