]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Make it easier to debug mail's unclosed istream
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 2 May 2016 20:43:15 +0000 (23:43 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 3 May 2016 16:45:57 +0000 (19:45 +0300)
src/lib-storage/index/index-mail.c

index dceb2c949bb0dc1995f3fdc9a7c0b761d4f9bc0c..856822e71f3c11dd250d05c58552bd8fe95a11f3 100644 (file)
@@ -1499,6 +1499,8 @@ static void index_mail_close_streams_full(struct index_mail *mail, bool closing)
        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
@@ -1508,12 +1510,13 @@ static void index_mail_close_streams_full(struct index_mail *mail, bool closing)
                                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;