dovecot-2.1: lib-storage: If message parser's input stream is cl...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 4 16:10:59 EET 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/b15a98fd8e15
changeset: 14896:b15a98fd8e15
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 04 16:10:50 2013 +0200
description:
lib-storage: If message parser's input stream is closed early, don't treat it as error.
This seems to happen sometimes during message saving(?), although I'm not
exactly sure why. In any case it shouldn't log an error about it. This
behavior is probably better than failing. The caller should be the one to
figure out if saving has failed or not.

diffstat:

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

diffs (29 lines):

diff -r 23fb615c3628 -r b15a98fd8e15 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Mon Feb 04 16:03:54 2013 +0200
+++ b/src/lib-storage/index/index-mail.c	Mon Feb 04 16:10:50 2013 +0200
@@ -762,15 +762,20 @@
 		i_stream_ref(parser_input);
 		ret = message_parser_deinit(&mail->data.parser_ctx,
 					    &mail->data.parts) < 0 ? 0 : 1;
-		if (parser_input->stream_errno != 0) {
+		if (parser_input->stream_errno == 0 ||
+		    parser_input->stream_errno == EPIPE) {
+			/* EPIPE = input already closed. allow the caller to
+			   decide if that is an error or not. */
+			i_assert(i_stream_read(parser_input) == -1 &&
+				 !i_stream_have_bytes_left(parser_input));
+		} else {
 			errno = parser_input->stream_errno;
 			mail_storage_set_critical(mail->mail.mail.box->storage,
-					"read(%s) failed: %m",
-					i_stream_get_name(parser_input));
+				"mail parser: read(%s, box=%s) failed: %m",
+				i_stream_get_name(parser_input),
+				mail->mail.mail.box->vname);
 			ret = -1;
 		}
-		i_assert(i_stream_read(parser_input) == -1 &&
-			 !i_stream_have_bytes_left(parser_input));
 		i_stream_unref(&parser_input);
 	}
 	if (ret <= 0) {


More information about the dovecot-cvs mailing list