dovecot: Assert-crash if mail's input stream is closed too early...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Dec 22 03:05:34 EET 2007
details: http://hg.dovecot.org/dovecot/rev/b42691420ff8
changeset: 7024:b42691420ff8
user: Timo Sirainen <tss at iki.fi>
date: Sat Dec 22 02:56:01 2007 +0200
description:
Assert-crash if mail's input stream is closed too early or too late.
diffstat:
2 files changed, 15 insertions(+), 1 deletion(-)
src/lib-storage/index/index-mail.c | 15 ++++++++++++++-
src/lib-storage/index/index-mail.h | 1 +
diffs (50 lines):
diff -r 56a5a00e490c -r b42691420ff8 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Sat Dec 22 02:54:58 2007 +0200
+++ b/src/lib-storage/index/index-mail.c Sat Dec 22 02:56:01 2007 +0200
@@ -754,12 +754,22 @@ static int index_mail_parse_body(struct
return ret;
}
+static void index_mail_stream_destroy_callback(struct index_mail *mail)
+{
+ i_assert(mail->data.destroying_stream);
+
+ mail->data.destroying_stream = FALSE;
+}
+
int index_mail_init_stream(struct index_mail *mail,
struct message_size *hdr_size,
struct message_size *body_size,
struct istream **stream_r)
{
struct index_mail_data *data = &mail->data;
+
+ 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);
@@ -1024,8 +1034,11 @@ void index_mail_close(struct mail *_mail
if (mail->data.parser_ctx != NULL)
(void)message_parser_deinit(&mail->data.parser_ctx);
- if (mail->data.stream != NULL)
+ if (mail->data.stream != NULL) {
+ mail->data.destroying_stream = TRUE;
i_stream_unref(&mail->data.stream);
+ i_assert(!mail->data.destroying_stream);
+ }
if (mail->data.filter_stream != NULL)
i_stream_unref(&mail->data.filter_stream);
}
diff -r 56a5a00e490c -r b42691420ff8 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Sat Dec 22 02:54:58 2007 +0200
+++ b/src/lib-storage/index/index-mail.h Sat Dec 22 02:56:01 2007 +0200
@@ -103,6 +103,7 @@ struct index_mail_data {
unsigned int body_size_set:1;
unsigned int messageparts_saved_to_cache:1;
unsigned int header_parsed:1;
+ unsigned int destroying_stream:1;
};
struct index_mail {
More information about the dovecot-cvs
mailing list