dovecot-2.2: lib-storage: struct mail.close() now clears all of ...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Oct 29 17:55:53 EET 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/4c3dac1a94cf
changeset: 15293:4c3dac1a94cf
user: Timo Sirainen <tss at iki.fi>
date: Wed Oct 03 01:19:19 2012 +0300
description:
lib-storage: struct mail.close() now clears all of its data.
diffstat:
src/lib-storage/index/index-mail.c | 51 +++++++++++++++++++------------------
src/lib-storage/index/index-mail.h | 2 +
2 files changed, 28 insertions(+), 25 deletions(-)
diffs (104 lines):
diff -r 8c06fe0b280d -r 4c3dac1a94cf src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Wed Oct 03 01:12:13 2012 +0300
+++ b/src/lib-storage/index/index-mail.c Wed Oct 03 01:19:19 2012 +0300
@@ -1180,32 +1180,10 @@
index_mail_close_streams_full(mail, FALSE);
}
-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_full(mail, TRUE);
-
- if (mail->data.wanted_headers != NULL)
- mailbox_header_lookup_unref(&mail->data.wanted_headers);
-}
-
-static void index_mail_reset(struct index_mail *mail)
+static void index_mail_reset_data(struct index_mail *mail)
{
struct index_mail_data *data = &mail->data;
- mail->mail.v.close(&mail->mail.mail);
-
memset(data, 0, sizeof(*data));
p_clear(mail->data_pool);
@@ -1230,6 +1208,28 @@
mail->mail.mail.saving = FALSE;
}
+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_full(mail, TRUE);
+
+ if (mail->data.wanted_headers != NULL)
+ mailbox_header_lookup_unref(&mail->data.wanted_headers);
+ if (!mail->freeing)
+ index_mail_reset_data(mail);
+}
+
static void check_envelope(struct index_mail *mail)
{
struct mail *_mail = &mail->mail.mail;
@@ -1390,7 +1390,7 @@
if (mail->data.seq == seq)
return;
- index_mail_reset(mail);
+ mail->mail.v.close(&mail->mail.mail);
mail->data.seq = seq;
mail->mail.mail.seq = seq;
@@ -1458,7 +1458,7 @@
index_mail_set_seq(_mail, seq, FALSE);
return TRUE;
} else {
- index_mail_reset(mail);
+ mail->mail.v.close(&mail->mail.mail);
mail->mail.mail.uid = uid;
mail_set_expunged(&mail->mail.mail);
return FALSE;
@@ -1512,6 +1512,7 @@
directly */
i_assert(!mail->search_mail);
+ mail->freeing = TRUE;
mail->mail.v.close(_mail);
i_assert(_mail->transaction->mail_ref_count > 0);
diff -r 8c06fe0b280d -r 4c3dac1a94cf src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Wed Oct 03 01:12:13 2012 +0300
+++ b/src/lib-storage/index/index-mail.h Wed Oct 03 01:19:19 2012 +0300
@@ -146,6 +146,8 @@
unsigned int pop3_state_set:1;
/* mail created by mailbox_search_*() */
unsigned int search_mail:1;
+ /* close() is being called from mail_free() */
+ unsigned int freeing:1;
};
struct mail *
More information about the dovecot-cvs
mailing list