dovecot-2.2: maildir: Returning mail's received/saved date or re...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 2 10:36:35 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9f1460682295
changeset: 17308:9f1460682295
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 02 13:36:00 2014 +0300
description:
maildir: Returning mail's received/saved date or refcount was sometimes broken with zlib plugin.
If the value wasn't already cached and the same transaction also accessed
the message body, i_stream_stat() was used, which ended up to
i_stream_seekable_stat() due to caching the file, which didn't again fstat()
the actual maildir file but just used some internal values.

diffstat:

 src/lib-storage/index/maildir/maildir-mail.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (33 lines):

diff -r 304b95de6a5f -r 9f1460682295 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c	Fri May 02 13:21:18 2014 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Fri May 02 13:36:00 2014 +0300
@@ -106,9 +106,8 @@
 {
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->box;
 	struct index_mail *imail = (struct index_mail *)mail;
-	const struct stat *stp;
 	const char *path;
-	int ret;
+	int fd, ret;
 
 	if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) {
 		mail_set_aborted(mail);
@@ -123,11 +122,15 @@
 		(void)mail_get_stream(mail, NULL, NULL, &input);
 	}
 
-	if (imail->data.stream != NULL) {
+	if (imail->data.stream != NULL &&
+	    (fd = i_stream_get_fd(imail->data.stream)) != -1) {
 		mail->transaction->stats.fstat_lookup_count++;
-		if (i_stream_stat(imail->data.stream, FALSE, &stp) < 0)
+		if (fstat(fd, st_r) < 0) {
+			mail_storage_set_critical(mail->box->storage,
+				"fstat(%s) failed: %m",
+				i_stream_get_name(imail->data.stream));
 			return -1;
-		*st_r = *stp;
+		}
 	} else if (!mail->saving) {
 		mail->transaction->stats.stat_lookup_count++;
 		ret = maildir_file_do(mbox, mail->uid, do_stat, st_r);


More information about the dovecot-cvs mailing list