dovecot-2.0: lib-storage: If plugin changes mail's input stream,...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 01:15:24 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/d73634c82feb
changeset: 10692:d73634c82feb
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 13 00:42:59 2010 +0200
description:
lib-storage: If plugin changes mail's input stream, don't assert-crash on close.

diffstat:

2 files changed, 8 insertions(+), 2 deletions(-)
src/lib-storage/index/index-mail.c |    9 +++++++--
src/lib-storage/index/index-mail.h |    1 +

diffs (30 lines):

diff -r fe70069debcb -r d73634c82feb src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Fri Feb 12 23:29:31 2010 +0200
+++ b/src/lib-storage/index/index-mail.c	Sat Feb 13 00:42:59 2010 +0200
@@ -831,8 +831,13 @@ int index_mail_init_stream(struct index_
 		data->initialized_wrapper_stream = TRUE;
 	}
 
-	i_stream_set_destroy_callback(data->stream,
-				      index_mail_stream_destroy_callback, mail);
+	if (!data->destroy_callback_set) {
+		/* do this only once in case a plugin changes the stream.
+		   otherwise the check would break. */
+		data->destroy_callback_set = TRUE;
+		i_stream_set_destroy_callback(data->stream,
+			index_mail_stream_destroy_callback, mail);
+	}
 
 	if (hdr_size != NULL || body_size != NULL)
 		(void)get_cached_msgpart_sizes(mail);
diff -r fe70069debcb -r d73634c82feb src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Fri Feb 12 23:29:31 2010 +0200
+++ b/src/lib-storage/index/index-mail.h	Sat Feb 13 00:42:59 2010 +0200
@@ -111,6 +111,7 @@ struct index_mail_data {
 	unsigned int forced_no_caching:1;
 	unsigned int destroying_stream:1;
 	unsigned int initialized_wrapper_stream:1;
+	unsigned int destroy_callback_set:1;
 };
 
 struct index_mail {


More information about the dovecot-cvs mailing list