dovecot: Don't crash if mail_index_reset() is the only change in...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 18 09:26:39 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/47536814b011
changeset: 6074:47536814b011
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jul 18 08:36:55 2007 +0300
description:
Don't crash if mail_index_reset() is the only change in transaction.

diffstat:

2 files changed, 9 insertions(+), 5 deletions(-)
src/lib-index/mail-index-transaction.c      |    1 -
src/lib-index/mail-transaction-log-append.c |   13 +++++++++----

diffs (46 lines):

diff -r 8418a23cb3f4 -r 47536814b011 src/lib-index/mail-index-transaction.c
--- 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 @@ void mail_index_reset(struct mail_index_
 	mail_index_transaction_reset(t);
 
 	t->reset = TRUE;
-	t->log_updates = TRUE;
 }
 
 struct mail_index_transaction_vfuncs trans_vfuncs = {
diff -r 8418a23cb3f4 -r 47536814b011 src/lib-index/mail-transaction-log-append.c
--- 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 @@ mail_transaction_log_append_locked(struc
 		   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 @@ int mail_transaction_log_append(struct m
 	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 {


More information about the dovecot-cvs mailing list