Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8197:264f493b1575 HEAD
mbox: Log mbox file path for "Unexpectedly lost .." errors.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 13 Sep 2008 13:23:36 +0300 |
parents | 40a07553606c |
children | b50faeeefb4c |
files | src/lib-storage/index/mbox/istream-raw-mbox.c src/lib-storage/index/mbox/istream-raw-mbox.h src/lib-storage/index/mbox/mbox-file.c |
diffstat | 3 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 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 @@ 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 @@ 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 @@ 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 @@ (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 @@ 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); }
--- 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);
--- 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 @@ 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 @@ 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; }