dovecot-2.1: imapc: Fixed closing mail properly.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Oct 5 17:44:58 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/e026ff4467a8
changeset: 13606:e026ff4467a8
user: Timo Sirainen <tss at iki.fi>
date: Wed Oct 05 17:34:51 2011 +0300
description:
imapc: Fixed closing mail properly.
diffstat:
src/lib-storage/index/imapc/imapc-mail.c | 6 ++--
src/lib-storage/index/index-mail.c | 34 ++++++++++++++++++-------------
src/lib-storage/index/index-mail.h | 1 +
3 files changed, 24 insertions(+), 17 deletions(-)
diffs (95 lines):
diff -r 0602a0d36164 -r e026ff4467a8 src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c Wed Oct 05 17:34:16 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail.c Wed Oct 05 17:34:51 2011 +0300
@@ -145,7 +145,7 @@
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 @@
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 @@
}
if (mail->body != NULL)
buffer_free(&mail->body);
-
- index_mail_close(_mail);
}
struct mail_vfuncs imapc_mail_vfuncs = {
diff -r 0602a0d36164 -r e026ff4467a8 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Wed Oct 05 17:34:16 2011 +0300
+++ b/src/lib-storage/index/index-mail.c Wed Oct 05 17:34:51 2011 +0300
@@ -1126,10 +1126,28 @@
}
}
+void index_mail_close_streams(struct index_mail *mail)
+{
+ struct message_part *parts;
+
+ if (mail->data.parser_ctx != NULL) {
+ if (message_parser_deinit(&mail->data.parser_ctx, &parts) < 0) {
+ mail_set_cache_corrupted(&mail->mail.mail,
+ MAIL_FETCH_MESSAGE_PARTS);
+ }
+ }
+ if (mail->data.filter_stream != NULL)
+ i_stream_unref(&mail->data.filter_stream);
+ if (mail->data.stream != NULL) {
+ mail->data.destroying_stream = TRUE;
+ i_stream_unref(&mail->data.stream);
+ i_assert(!mail->data.destroying_stream);
+ }
+}
+
void index_mail_close(struct 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
@@ -1141,19 +1159,7 @@
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_FETCH_MESSAGE_PARTS);
- }
- }
- if (mail->data.filter_stream != NULL)
- i_stream_unref(&mail->data.filter_stream);
- if (mail->data.stream != NULL) {
- mail->data.destroying_stream = TRUE;
- i_stream_unref(&mail->data.stream);
- i_assert(!mail->data.destroying_stream);
- }
+ index_mail_close_streams(mail);
}
static void index_mail_reset(struct index_mail *mail)
diff -r 0602a0d36164 -r e026ff4467a8 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Wed Oct 05 17:34:16 2011 +0300
+++ b/src/lib-storage/index/index-mail.h Wed Oct 05 17:34:51 2011 +0300
@@ -162,6 +162,7 @@
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);
More information about the dovecot-cvs
mailing list