if (data->filter_stream != NULL)
i_stream_unref(&data->filter_stream);
if (data->stream != NULL) {
+ struct istream *orig_stream = data->stream;
+
data->destroying_stream = TRUE;
if (!closing && data->destroy_callback_set) {
/* we're replacing the stream with a new one. it's
index_mail_stream_destroy_callback);
}
i_stream_unref(&data->stream);
- if (closing) {
- /* there must be no references to the mail when the
- mail is being closed. */
- i_assert(!mail->data.destroying_stream);
- } else {
+ /* there must be no references to the mail when the
+ mail is being closed. */
+ if (!closing)
data->destroying_stream = FALSE;
+ else if (mail->data.destroying_stream) {
+ i_panic("Input stream %s unexpectedly has references",
+ i_stream_get_name(orig_stream));
}
data->initialized_wrapper_stream = FALSE;