]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: If plugin changes mail's input stream, don't assert-crash on close.
authorTimo Sirainen <tss@iki.fi>
Fri, 12 Feb 2010 22:42:59 +0000 (00:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 12 Feb 2010 22:42:59 +0000 (00:42 +0200)
--HG--
branch : HEAD

src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h

index 49e5c571c9a0997620a0d448a332bacca89fc0c2..1dce8fa0714fd5965d830918211932dd51c8d680 100644 (file)
@@ -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);
index d9c643801e3b943237dad955b4ac05ee9b5d0c0b..33bc2e39bcb741925808ee781ea99e69c5751f63 100644 (file)
@@ -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 {