dovecot: Assert-crash if there are mails belonging to a transact...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 28 08:57:09 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/901467b1506e
changeset: 6867:901467b1506e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 28 08:56:51 2007 +0200
description:
Assert-crash if there are mails belonging to a transaction while it's being
committed or rolled back.

diffstat:

3 files changed, 9 insertions(+)
src/lib-storage/index/index-mail.c        |    4 ++++
src/lib-storage/index/index-storage.h     |    1 +
src/lib-storage/index/index-transaction.c |    4 ++++

diffs (53 lines):

diff -r b223a34c64cb -r 901467b1506e src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Wed Nov 28 08:11:18 2007 +0200
+++ b/src/lib-storage/index/index-mail.c	Wed Nov 28 08:56:51 2007 +0200
@@ -986,6 +986,7 @@ void index_mail_init(struct index_mail *
 	hdr = mail_index_get_header(t->ibox->view);
 	mail->uid_validity = hdr->uid_validity;
 
+	t->mail_ref_count++;
 	mail->data_pool = pool_alloconly_create("index_mail", 16384);
 	mail->ibox = t->ibox;
 	mail->trans = t;
@@ -1195,6 +1196,9 @@ void index_mail_free(struct mail *_mail)
 
 	mail->mail.v.close(_mail);
 
+	i_assert(mail->trans->mail_ref_count > 0);
+	mail->trans->mail_ref_count--;
+
 	if (mail->header_data != NULL)
 		buffer_free(&mail->header_data);
 	if (array_is_created(&mail->header_lines))
diff -r b223a34c64cb -r 901467b1506e src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h	Wed Nov 28 08:11:18 2007 +0200
+++ b/src/lib-storage/index/index-storage.h	Wed Nov 28 08:56:51 2007 +0200
@@ -72,6 +72,7 @@ struct index_transaction_context {
 
 	struct index_mailbox *ibox;
 	enum mailbox_transaction_flags flags;
+	int mail_ref_count;
 
 	struct mail_index_transaction *trans;
 	struct mail_index_view *trans_view;
diff -r b223a34c64cb -r 901467b1506e src/lib-storage/index/index-transaction.c
--- a/src/lib-storage/index/index-transaction.c	Wed Nov 28 08:11:18 2007 +0200
+++ b/src/lib-storage/index/index-transaction.c	Wed Nov 28 08:56:51 2007 +0200
@@ -33,6 +33,8 @@ int index_transaction_finish_commit(stru
 {
 	int ret;
 
+	i_assert(t->mail_ref_count == 0);
+
 	ret = t->super.commit(t->trans, log_file_seq_r, log_file_offset_r);
 	if (ret < 0)
 		mail_storage_set_index_error(t->ibox);
@@ -49,6 +51,8 @@ int index_transaction_finish_commit(stru
 
 void index_transaction_finish_rollback(struct index_transaction_context *t)
 {
+	i_assert(t->mail_ref_count == 0);
+
 	t->super.rollback(t->trans);
 	index_transaction_free(t);
 }


More information about the dovecot-cvs mailing list