dovecot-2.1: imapc: Mail body caching should be done at close(),...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 4 17:06:17 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/d3b30b82a225
changeset: 13600:d3b30b82a225
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 04 17:14:30 2011 +0300
description:
imapc: Mail body caching should be done at close(), not at free().
This cached wrong mail bodies when fetching multiple mails.
diffstat:
src/lib-storage/index/imapc/imapc-mail.c | 58 +++++++++++++------------------
1 files changed, 25 insertions(+), 33 deletions(-)
diffs (81 lines):
diff -r 6d1c20b1936c -r d3b30b82a225 src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c Mon Oct 03 20:00:55 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail.c Tue Oct 04 17:14:30 2011 +0300
@@ -26,33 +26,6 @@
return &mail->imail.mail.mail;
}
-static void imapc_mail_free(struct mail *_mail)
-{
- struct imapc_mail *mail = (struct imapc_mail *)_mail;
- struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
- struct imapc_mail_cache *cache = &mbox->prev_mail_cache;
-
- if (mail->body_fetched) {
- imapc_mail_cache_free(cache);
- cache->uid = _mail->uid;
- if (cache->fd != -1) {
- cache->fd = mail->fd;
- mail->fd = -1;
- } else {
- cache->buf = mail->body;
- mail->body = NULL;
- }
- }
- if (mail->fd != -1) {
- if (close(mail->fd) < 0)
- i_error("close(imapc mail) failed: %m");
- }
- if (mail->body != NULL)
- buffer_free(&mail->body);
-
- index_mail_free(_mail);
-}
-
static bool imapc_mail_is_expunged(struct mail *_mail)
{
struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
@@ -243,18 +216,37 @@
static void imapc_mail_close(struct mail *_mail)
{
- struct imapc_mail *imail = (struct imapc_mail *)_mail;
- struct imapc_storage *storage =
- (struct imapc_storage *)_mail->box->storage;
+ struct imapc_mail *mail = (struct imapc_mail *)_mail;
+ struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
+ struct imapc_mail_cache *cache = &mbox->prev_mail_cache;
- while (imail->fetch_count > 0)
- imapc_storage_run(storage);
+ while (mail->fetch_count > 0)
+ imapc_storage_run(mbox->storage);
+
+ if (mail->body_fetched) {
+ imapc_mail_cache_free(cache);
+ cache->uid = _mail->uid;
+ if (cache->fd != -1) {
+ cache->fd = mail->fd;
+ mail->fd = -1;
+ } else {
+ cache->buf = mail->body;
+ mail->body = NULL;
+ }
+ }
+ if (mail->fd != -1) {
+ if (close(mail->fd) < 0)
+ i_error("close(imapc mail) failed: %m");
+ }
+ if (mail->body != NULL)
+ buffer_free(&mail->body);
+
index_mail_close(_mail);
}
struct mail_vfuncs imapc_mail_vfuncs = {
imapc_mail_close,
- imapc_mail_free,
+ index_mail_free,
imapc_mail_set_seq,
index_mail_set_uid,
index_mail_set_uid_cache_updates,
More information about the dovecot-cvs
mailing list