dovecot-1.2: mbox: Log mbox file path for "Unexpectedly lost .."...

dovecot at dovecot.org dovecot at dovecot.org
Sat Sep 13 13:23:40 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/264f493b1575
changeset: 8197:264f493b1575
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Sep 13 13:23:36 2008 +0300
description:
mbox: Log mbox file path for "Unexpectedly lost .." errors.

diffstat:

3 files changed, 21 insertions(+), 11 deletions(-)
src/lib-storage/index/mbox/istream-raw-mbox.c |   20 +++++++++++++-------
src/lib-storage/index/mbox/istream-raw-mbox.h |    6 ++++--
src/lib-storage/index/mbox/mbox-file.c        |    6 ++++--

diffs (111 lines):

diff -r 40a07553606c -r 264f493b1575 src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Sat Sep 13 13:06:06 2008 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Sat Sep 13 13:23:36 2008 +0300
@@ -10,7 +10,7 @@ struct raw_mbox_istream {
 	struct istream_private istream;
 
 	time_t received_time, next_received_time;
-	char *sender, *next_sender;
+	char *path, *sender, *next_sender;
 
 	uoff_t from_offset, hdr_offset, body_offset, mail_size;
 	uoff_t input_peak_offset;
@@ -26,6 +26,7 @@ static void i_stream_raw_mbox_destroy(st
 
 	i_free(rstream->sender);
 	i_free(rstream->next_sender);
+	i_free(rstream->path);
 
 	i_stream_seek(rstream->istream.parent,
 		      rstream->istream.istream.v_offset);
@@ -303,7 +304,8 @@ static ssize_t i_stream_raw_mbox_read(st
 	    rstream->hdr_offset + new_pos > rstream->mail_size) {
 		/* istream_raw_mbox_set_next_offset() used invalid
 		   cached next_offset? */
-		i_error("Next message unexpectedly lost from %"PRIuUOFF_T,
+		i_error("Next message unexpectedly lost from mbox file "
+			"%s at %"PRIuUOFF_T, rstream->path,
 			rstream->hdr_offset + rstream->mail_size);
 		rstream->eof = TRUE;
 		rstream->corrupted = TRUE;
@@ -362,14 +364,17 @@ i_stream_raw_mbox_stat(struct istream_pr
 	return &stream->statbuf;
 }
 
-struct istream *i_stream_create_raw_mbox(struct istream *input)
+struct istream *
+i_stream_create_raw_mbox(struct istream *input, const char *path)
 {
 	struct raw_mbox_istream *rstream;
 
+	i_assert(path != NULL);
 	i_assert(input->v_offset == 0);
 
 	rstream = i_new(struct raw_mbox_istream, 1);
 
+	rstream->path = i_strdup(path);
 	rstream->body_offset = (uoff_t)-1;
 	rstream->mail_size = (uoff_t)-1;
 	rstream->received_time = (time_t)-1;
@@ -451,8 +456,8 @@ uoff_t istream_raw_mbox_get_header_offse
 		(void)i_stream_raw_mbox_read(&rstream->istream);
 
 	if (rstream->corrupted) {
-		i_error("Unexpectedly lost From-line at "
-			"%"PRIuUOFF_T, rstream->from_offset);
+		i_error("Unexpectedly lost From-line from mbox file %s at "
+			"%"PRIuUOFF_T, rstream->path, rstream->from_offset);
 		return (uoff_t)-1;
 	}
 
@@ -477,8 +482,9 @@ uoff_t istream_raw_mbox_get_body_offset(
 
 		if (i_stream_raw_mbox_read(&rstream->istream) < 0) {
 			if (rstream->corrupted) {
-				i_error("Unexpectedly lost From-line at "
-					"%"PRIuUOFF_T, rstream->from_offset);
+				i_error("Unexpectedly lost From-line from mbox file "
+					"%s at %"PRIuUOFF_T, rstream->path,
+					rstream->from_offset);
 			} else {
 				i_assert(rstream->body_offset != (uoff_t)-1);
 			}
diff -r 40a07553606c -r 264f493b1575 src/lib-storage/index/mbox/istream-raw-mbox.h
--- a/src/lib-storage/index/mbox/istream-raw-mbox.h	Sat Sep 13 13:06:06 2008 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.h	Sat Sep 13 13:23:36 2008 +0300
@@ -2,8 +2,10 @@
 #define ISTREAM_RAW_MBOX_H
 
 /* Create a mbox stream for parsing mbox. Reading stops before From-line,
-   you'll have to call istream_raw_mbox_next() to get to next message. */
-struct istream *i_stream_create_raw_mbox(struct istream *input);
+   you'll have to call istream_raw_mbox_next() to get to next message.
+   path is used only for logging purposes. */
+struct istream *i_stream_create_raw_mbox(struct istream *input,
+					 const char *path);
 
 /* Return offset to beginning of the "\nFrom"-line. */
 uoff_t istream_raw_mbox_get_start_offset(struct istream *stream);
diff -r 40a07553606c -r 264f493b1575 src/lib-storage/index/mbox/mbox-file.c
--- a/src/lib-storage/index/mbox/mbox-file.c	Sat Sep 13 13:06:06 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-file.c	Sat Sep 13 13:23:36 2008 +0300
@@ -68,7 +68,8 @@ int mbox_file_open_stream(struct mbox_ma
 		i_assert(mbox->mbox_fd == -1 && mbox->mbox_readonly);
 
 		mbox->mbox_stream =
-			i_stream_create_raw_mbox(mbox->mbox_file_stream);
+			i_stream_create_raw_mbox(mbox->mbox_file_stream,
+						 mbox->path);
 		return 0;
 	}
 
@@ -85,7 +86,8 @@ int mbox_file_open_stream(struct mbox_ma
 					   MAIL_READ_BLOCK_SIZE, FALSE);
 	}
 
-	mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream);
+	mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream,
+						     mbox->path);
 	return 0;
 }
 


More information about the dovecot-cvs mailing list