]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fixed closing mail properly.
authorTimo Sirainen <tss@iki.fi>
Wed, 5 Oct 2011 14:34:51 +0000 (17:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 5 Oct 2011 14:34:51 +0000 (17:34 +0300)
src/lib-storage/index/imapc/imapc-mail.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h

index a5b90bfb3a1fef92124862a90e33cfd0bb55f7e8..5feff137ba799d9e333fcdf2b41746c10ea4ce10 100644 (file)
@@ -145,7 +145,7 @@ imapc_mail_get_stream(struct mail *_mail, bool get_body,
        if (get_body && !mail->body_fetched &&
            mail->imail.data.stream != NULL) {
                /* we've fetched the header, but we need the body now too */
-               i_stream_unref(&mail->imail.data.stream);
+               index_mail_close_streams(&mail->imail);
        }
 
        if (data->stream == NULL) {
@@ -231,6 +231,8 @@ static void imapc_mail_close(struct mail *_mail)
        while (mail->fetch_count > 0)
                imapc_storage_run(mbox->storage);
 
+       index_mail_close(_mail);
+
        if (mail->body_fetched) {
                imapc_mail_cache_free(cache);
                cache->uid = _mail->uid;
@@ -249,8 +251,6 @@ static void imapc_mail_close(struct mail *_mail)
        }
        if (mail->body != NULL)
                buffer_free(&mail->body);
-
-       index_mail_close(_mail);
 }
 
 struct mail_vfuncs imapc_mail_vfuncs = {
index 4312f8536500d37bf2b1b042d07e470c41767d32..a9caf34183c8e2a6953a49ead0e0b49512768b43 100644 (file)
@@ -1126,24 +1126,13 @@ void index_mail_init(struct index_mail *mail,
        }
 }
 
-void index_mail_close(struct mail *_mail)
+void index_mail_close_streams(struct index_mail *mail)
 {
-       struct index_mail *mail = (struct index_mail *)_mail;
        struct message_part *parts;
 
-       /* If uid == 0 but seq != 0, we came here from saving a (non-mbox)
-          message. If that happens, don't bother checking if anything should
-          be cached since it was already checked. Also by now the transaction
-          may have already been rollbacked and seq point to a nonexistent
-          message. */
-       if (mail->mail.mail.uid != 0) {
-               index_mail_cache_sizes(mail);
-               index_mail_cache_dates(mail);
-       }
-
        if (mail->data.parser_ctx != NULL) {
                if (message_parser_deinit(&mail->data.parser_ctx, &parts) < 0) {
-                       mail_set_cache_corrupted(_mail,
+                       mail_set_cache_corrupted(&mail->mail.mail,
                                                 MAIL_FETCH_MESSAGE_PARTS);
                }
        }
@@ -1156,6 +1145,23 @@ void index_mail_close(struct mail *_mail)
        }
 }
 
+void index_mail_close(struct mail *_mail)
+{
+       struct index_mail *mail = (struct index_mail *)_mail;
+
+       /* If uid == 0 but seq != 0, we came here from saving a (non-mbox)
+          message. If that happens, don't bother checking if anything should
+          be cached since it was already checked. Also by now the transaction
+          may have already been rollbacked and seq point to a nonexistent
+          message. */
+       if (mail->mail.mail.uid != 0) {
+               index_mail_cache_sizes(mail);
+               index_mail_cache_dates(mail);
+       }
+
+       index_mail_close_streams(mail);
+}
+
 static void index_mail_reset(struct index_mail *mail)
 {
        struct index_mail_data *data = &mail->data;
index 9e854b388c4c45f4f4e587e4dacbb579e0dbbc94..8534e42d0c461119c04662f3998f3fe5e5aee2f3 100644 (file)
@@ -162,6 +162,7 @@ bool index_mail_set_uid(struct mail *mail, uint32_t uid);
 void index_mail_set_uid_cache_updates(struct mail *mail, bool set);
 bool index_mail_prefetch(struct mail *mail);
 void index_mail_close(struct mail *mail);
+void index_mail_close_streams(struct index_mail *mail);
 void index_mail_free(struct mail *mail);
 
 bool index_mail_want_parse_headers(struct index_mail *mail);