]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: Log mbox file path for "Unexpectedly lost .." errors.
authorTimo Sirainen <tss@iki.fi>
Sat, 13 Sep 2008 10:23:36 +0000 (13:23 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 13 Sep 2008 10:23:36 +0000 (13:23 +0300)
--HG--
branch : HEAD

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

index 7c2792db5aaa2e0879109230dcf9ab73dd026f17..2dabe892be16ba1350bc3bd6fcb7eeb6cb1683f9 100644 (file)
@@ -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(struct iostream_private *stream)
 
        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(struct istream_private *stream)
            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_private *stream, bool exact)
        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_offset(struct istream *stream)
                (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(struct istream *stream)
 
                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);
                        }
index f51134b5a029cdde9953c0750b43c79082dfab9b..8bc4c8fa2c24b5500dc0347f4f03afcee609d7a8 100644 (file)
@@ -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);
index 1a06e2c1759cce9837ab714491c7eb5eed771872..d5a0c448f90e96181b28862eb300fb45a69c7204 100644 (file)
@@ -68,7 +68,8 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox)
                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_mailbox *mbox)
                                           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;
 }