dovecot-2.2: lib-storage: If we detect a broken cached message s...

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 17 22:55:51 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/babddd4c9ca9
changeset: 17963:babddd4c9ca9
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 18 01:55:02 2014 +0300
description:
lib-storage: If we detect a broken cached message size, log more information about it.
Also try to include one of the cached headers in the message, which could
allow detecting if the cached data pointed to a completely different
message.

diffstat:

 src/lib-storage/index/istream-mail.c |  36 +++++++++++++++++++++++++++++++++---
 1 files changed, 33 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r 6142d6b2ae98 -r babddd4c9ca9 src/lib-storage/index/istream-mail.c
--- a/src/lib-storage/index/istream-mail.c	Fri Oct 17 10:02:54 2014 -0700
+++ b/src/lib-storage/index/istream-mail.c	Sat Oct 18 01:55:02 2014 +0300
@@ -31,11 +31,36 @@
 	return mstream->expected_size != (uoff_t)-1;
 }
 
+static const char *
+i_stream_mail_get_cached_mail_id(struct mail_istream *mstream)
+{
+	static const char *headers[] = {
+		"Message-Id",
+		"Date",
+		"Subject"
+	};
+	struct mail *mail = mstream->mail;
+	enum mail_lookup_abort orig_lookup_abort;
+	const char *value, *ret = "";
+	unsigned int i;
+
+	orig_lookup_abort = mail->lookup_abort;
+	mail->lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE;
+	for (i = 0; i < N_ELEMENTS(headers); i++) {
+		if (mail_get_first_header(mail, headers[i], &value) > 0) {
+			ret = t_strdup_printf("%s=%s", headers[i], value);
+			break;
+		}
+	}
+	mail->lookup_abort = orig_lookup_abort;
+	return ret;
+}
+
 static void
 i_stream_mail_set_size_corrupted(struct mail_istream *mstream, size_t size)
 {
 	uoff_t cur_size = mstream->istream.istream.v_offset + size;
-	const char *str;
+	const char *str, *mail_id;
 	char chr;
 
 	if (mstream->expected_size < cur_size) {
@@ -46,10 +71,15 @@
 		chr = '>';
 	}
 
+	mail_id = i_stream_mail_get_cached_mail_id(mstream);
+	if (mail_id[0] != '\0')
+		mail_id = t_strconcat(", cached ", mail_id, NULL);
 	io_stream_set_error(&mstream->istream.iostream,
 		"Cached message size %s than expected "
-		"(%"PRIuUOFF_T" %c %"PRIuUOFF_T")", str,
-		mstream->expected_size, chr, cur_size);
+		"(%"PRIuUOFF_T" %c %"PRIuUOFF_T", box=%s, UID=%u%s)", str,
+		mstream->expected_size, chr, cur_size,
+		mailbox_get_vname(mstream->mail->box),
+		mstream->mail->uid, mail_id);
 	mail_storage_set_critical(mstream->mail->box->storage, "%s",
 				  mstream->istream.iostream.error);
 	mail_set_cache_corrupted(mstream->mail, MAIL_FETCH_PHYSICAL_SIZE);


More information about the dovecot-cvs mailing list