dovecot-2.2: lib-storage: Check and log stream errors when parsi...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 13:23:41 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/99965e11d9e1
changeset: 15266:99965e11d9e1
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 13:23:30 2012 +0200
description:
lib-storage: Check and log stream errors when parsing/searching messages.

diffstat:

 src/lib-storage/index/index-mail-headers.c |  6 +++++-
 src/lib-storage/index/index-mail.c         |  2 +-
 src/lib-storage/index/index-mail.h         |  1 +
 src/lib-storage/index/index-search.c       |  9 +++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diffs (80 lines):

diff -r 41018c6fcc53 -r 99965e11d9e1 src/lib-storage/index/index-mail-headers.c
--- a/src/lib-storage/index/index-mail-headers.c	Mon Oct 29 13:01:37 2012 +0200
+++ b/src/lib-storage/index/index-mail-headers.c	Mon Oct 29 13:23:30 2012 +0200
@@ -430,6 +430,8 @@
 				     hdr_parser_flags,
 				     index_mail_parse_header_cb, mail);
 	}
+	if (index_mail_stream_check_failure(mail) < 0)
+		return -1;
 	data->hdr_size_set = TRUE;
 	data->access_part &= ~PARSE_HDR;
 
@@ -475,15 +477,17 @@
 		mailbox_header_lookup_unref(&header_ctx);
 		return -1;
 	}
+	mailbox_header_lookup_unref(&header_ctx);
 
 	if (mail->data.envelope == NULL && stream != NULL) {
 		/* we got the headers from cache - parse them to get the
 		   envelope */
 		message_parse_header(stream, NULL, hdr_parser_flags,
 				     imap_envelope_parse_callback, mail);
+		if (index_mail_stream_check_failure(mail) < 0)
+			return -1;
 		mail->data.save_envelope = FALSE;
 	}
-	mailbox_header_lookup_unref(&header_ctx);
 
 	if (mail->data.stream != NULL)
 		i_stream_seek(mail->data.stream, old_offset);
diff -r 41018c6fcc53 -r 99965e11d9e1 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Mon Oct 29 13:01:37 2012 +0200
+++ b/src/lib-storage/index/index-mail.c	Mon Oct 29 13:23:30 2012 +0200
@@ -811,7 +811,7 @@
 	return 0;
 }
 
-static int index_mail_stream_check_failure(struct index_mail *mail)
+int index_mail_stream_check_failure(struct index_mail *mail)
 {
 	if (mail->data.stream->stream_errno == 0)
 		return 0;
diff -r 41018c6fcc53 -r 99965e11d9e1 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Mon Oct 29 13:01:37 2012 +0200
+++ b/src/lib-storage/index/index-mail.h	Mon Oct 29 13:23:30 2012 +0200
@@ -223,6 +223,7 @@
 void index_mail_set_cache_corrupted(struct mail *mail,
 				    enum mail_fetch_field field);
 int index_mail_opened(struct mail *mail, struct istream **stream);
+int index_mail_stream_check_failure(struct index_mail *mail);
 struct index_mail *index_mail_get_index_mail(struct mail *mail);
 
 bool index_mail_get_cached_uoff_t(struct index_mail *mail,
diff -r 41018c6fcc53 -r 99965e11d9e1 src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c	Mon Oct 29 13:01:37 2012 +0200
+++ b/src/lib-storage/index/index-search.c	Mon Oct 29 13:23:30 2012 +0200
@@ -626,6 +626,10 @@
 		ret = message_search_msg(msg_search_ctx, ctx->input, NULL);
 		i_assert(ret >= 0 || ctx->input->stream_errno != 0);
 	}
+	if (ctx->input->stream_errno != 0) {
+		mail_storage_set_critical(ctx->index_ctx->box->storage,
+			"read(%s) failed: %m", i_stream_get_name(ctx->input));
+	}
 
 	ARG_SET_RESULT(arg, ret);
 }
@@ -686,6 +690,11 @@
 			}
 			message_parse_header(input, NULL, hdr_parser_flags,
 					     search_header, &hdr_ctx);
+			if (input->stream_errno != 0) {
+				mail_storage_set_critical(ctx->box->storage,
+					"read(%s) failed: %m", i_stream_get_name(input));
+				failed = TRUE;
+			}
 		}
 	}
 	if (headers_ctx != NULL)


More information about the dovecot-cvs mailing list