From: Timo Sirainen Date: Fri, 12 Feb 2010 22:42:59 +0000 (+0200) Subject: lib-storage: If plugin changes mail's input stream, don't assert-crash on close. X-Git-Tag: 2.0.beta3~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6df86fcb245e7cf8f199026269be644116efde9a;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: If plugin changes mail's input stream, don't assert-crash on close. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 49e5c571c9..1dce8fa071 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -831,8 +831,13 @@ int index_mail_init_stream(struct index_mail *mail, 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 --git a/src/lib-storage/index/index-mail.h b/src/lib-storage/index/index-mail.h index d9c643801e..33bc2e39bc 100644 --- a/src/lib-storage/index/index-mail.h +++ b/src/lib-storage/index/index-mail.h @@ -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 {