changeset 6074:47536814b011 HEAD

Don't crash if mail_index_reset() is the only change in transaction.
author Timo Sirainen <tss@iki.fi>
date Wed, 18 Jul 2007 08:36:55 +0300
parents 8418a23cb3f4
children 813c976ed476
files src/lib-index/mail-index-transaction.c src/lib-index/mail-transaction-log-append.c
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction.c	Wed Jul 18 08:36:20 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Wed Jul 18 08:36:55 2007 +0300
@@ -1187,7 +1187,6 @@
 	mail_index_transaction_reset(t);
 
 	t->reset = TRUE;
-	t->log_updates = TRUE;
 }
 
 struct mail_index_transaction_vfuncs trans_vfuncs = {
--- a/src/lib-index/mail-transaction-log-append.c	Wed Jul 18 08:36:20 2007 +0300
+++ b/src/lib-index/mail-transaction-log-append.c	Wed Jul 18 08:36:55 2007 +0300
@@ -469,6 +469,11 @@
 		   transactions. */
 		if (mail_transaction_log_rotate(log, TRUE) < 0)
 			return -1;
+
+		if (!t->log_updates && !t->log_ext_updates) {
+			/* we only wanted to reset */
+			return 0;
+		}
 	}
 
 	if (!index->log_locked) {
@@ -573,15 +578,15 @@
 	struct mail_index *index;
 	int ret;
 
-	if (!t->log_updates && !t->log_ext_updates) {
+	*log_file_seq_r = 0;
+	*log_file_offset_r = 0;
+
+	if (!t->log_updates && !t->log_ext_updates && !t->reset) {
 		/* nothing to append */
-		*log_file_seq_r = 0;
-		*log_file_offset_r = 0;
 		return 0;
 	}
 
 	index = mail_index_view_get_index(t->view);
-
 	if (index->log_locked) {
 		i_assert(t->external);
 	} else {