]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Set input stream names for mail file streams.
authorTimo Sirainen <tss@iki.fi>
Sat, 6 Mar 2010 12:04:42 +0000 (14:04 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 6 Mar 2010 12:04:42 +0000 (14:04 +0200)
--HG--
branch : HEAD

src/lda/main.c
src/lib-storage/index/cydir/cydir-mail.c
src/lib-storage/index/dbox-common/dbox-file.c
src/lib-storage/index/maildir/maildir-mail.c
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
src/lib-storage/index/raw/raw-storage.c
src/plugins/zlib/zlib-plugin.c

index 5b01ebd52fd215dfbe0dd035967e3ecaa3452005..8a0743799a21f77e80178fe64f39c1fde8135c14 100644 (file)
@@ -404,6 +404,7 @@ int main(int argc, char *argv[])
                i_fatal("Couldn't create internal raw storage: %s", errstr);
        if (path == NULL) {
                input = create_raw_stream(&ctx, 0, &mtime);
+               i_stream_set_name(input, "stdin");
                box = mailbox_alloc(raw_ns->list, "Dovecot Delivery Mail",
                                    MAILBOX_FLAG_NO_INDEX_FILES);
                if (mailbox_open_stream(box, input) < 0) {
index 7d231d215d87f1c8166b35d08b28574cb7a85ed1..f8ef8bb1ac9df6207b62ca1be46194c89931fa33 100644 (file)
@@ -113,6 +113,7 @@ cydir_mail_get_stream(struct mail *_mail, struct message_size *hdr_size,
                        return -1;
                }
                mail->data.stream = i_stream_create_fd(fd, 0, TRUE);
+               i_stream_set_name(mail->data.stream, path);
                index_mail_set_read_buffer_size(_mail, mail->data.stream);
        }
 
index e93f2aa4e59f1187918420c36ad029c3d1d0c41d..a1845dbc1c5d9a18d3a6dcfceeb94fe0fb3269f4 100644 (file)
@@ -204,6 +204,7 @@ static int dbox_file_open_full(struct dbox_file *file, bool try_altpath,
        }
 
        file->input = i_stream_create_fd(file->fd, 0, FALSE);
+       i_stream_set_name(file->input, file->cur_path);
        i_stream_set_init_buffer_size(file->input, DBOX_READ_BLOCK_SIZE);
        return dbox_file_read_header(file);
 }
index ec14b364c2294303e92b038876313776f9439ee3..b6475289910bd9d3ee92283079e4c2d70035d9c7 100644 (file)
 #include <unistd.h>
 #include <sys/stat.h>
 
+struct maildir_open_context {
+       int fd;
+       char *path;
+};
+
 static int
-do_open(struct maildir_mailbox *mbox, const char *path, int *fd)
+do_open(struct maildir_mailbox *mbox, const char *path,
+       struct maildir_open_context *ctx)
 {
-       *fd = open(path, O_RDONLY);
-       if (*fd != -1)
+       ctx->fd = open(path, O_RDONLY);
+       if (ctx->fd != -1) {
+               ctx->path = i_strdup(path);
                return 1;
+       }
        if (errno == ENOENT)
                return 0;
 
@@ -57,27 +65,32 @@ maildir_open_mail(struct maildir_mailbox *mbox, struct mail *mail,
        struct mail_private *p = (struct mail_private *)mail;
        struct istream *input;
        const char *path;
-       int fd = -1;
+       struct maildir_open_context ctx;
 
        *deleted_r = FALSE;
 
+       ctx.fd = -1;
+       ctx.path = NULL;
+
        p->stats_open_lookup_count++;
        if (mail->uid != 0) {
-               if (maildir_file_do(mbox, mail->uid, do_open, &fd) < 0)
+               if (maildir_file_do(mbox, mail->uid, do_open, &ctx) < 0)
                        return NULL;
        } else {
                path = maildir_save_file_get_path(mail->transaction, mail->seq);
-               if (do_open(mbox, path, &fd) <= 0)
+               if (do_open(mbox, path, &ctx) <= 0)
                        return NULL;
        }
 
-       if (fd == -1) {
+       if (ctx.fd == -1) {
                *deleted_r = TRUE;
                return NULL;
        }
 
-       input = i_stream_create_fd(fd, 0, TRUE);
+       input = i_stream_create_fd(ctx.fd, 0, TRUE);
+       i_stream_set_name(input, ctx.path);
        index_mail_set_read_buffer_size(mail, input);
+       i_free(ctx.path);
        return input;
 }
 
index 9fc255edce51e04389cfc57337d74fd500ee602f..2cdc97bda5789796ea485d63d2d12d2b863961a4 100644 (file)
@@ -10,7 +10,7 @@ struct raw_mbox_istream {
        struct istream_private istream;
 
        time_t received_time, next_received_time;
-       char *path, *sender, *next_sender;
+       char *sender, *next_sender;
 
        uoff_t from_offset, hdr_offset, body_offset, mail_size;
        uoff_t input_peak_offset;
@@ -30,7 +30,6 @@ 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);
@@ -257,7 +256,8 @@ static ssize_t i_stream_raw_mbox_read(struct istream_private *stream)
                if (mbox_read_from_line(rstream) < 0) {
                        if (stream->istream.v_offset != 0) {
                                i_error("Next message unexpectedly corrupted in mbox file "
-                                       "%s at %"PRIuUOFF_T, rstream->path,
+                                       "%s at %"PRIuUOFF_T,
+                                       i_stream_get_name(&stream->istream),
                                        stream->istream.v_offset);
                        }
                        stream->pos = 0;
@@ -358,7 +358,8 @@ static ssize_t i_stream_raw_mbox_read(struct istream_private *stream)
                /* istream_raw_mbox_set_next_offset() used invalid
                   cached next_offset? */
                i_error("Next message unexpectedly lost from mbox file "
-                       "%s at %"PRIuUOFF_T" (%s)", rstream->path,
+                       "%s at %"PRIuUOFF_T" (%s)",
+                       i_stream_get_name(&stream->istream),
                        rstream->hdr_offset + rstream->mail_size,
                        rstream->mail_size_forced ? "cached" : "noncached");
                rstream->eof = TRUE;
@@ -423,17 +424,14 @@ i_stream_raw_mbox_stat(struct istream_private *stream, bool exact)
        return &stream->statbuf;
 }
 
-struct istream *
-i_stream_create_raw_mbox(struct istream *input, const char *path)
+struct istream *i_stream_create_raw_mbox(struct istream *input)
 {
        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;
@@ -517,7 +515,8 @@ uoff_t istream_raw_mbox_get_header_offset(struct istream *stream)
 
        if (rstream->corrupted) {
                i_error("Unexpectedly lost From-line from mbox file %s at "
-                       "%"PRIuUOFF_T, rstream->path, rstream->from_offset);
+                       "%"PRIuUOFF_T, i_stream_get_name(stream),
+                       rstream->from_offset);
                return (uoff_t)-1;
        }
 
@@ -545,7 +544,8 @@ 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 from mbox file "
-                                       "%s at %"PRIuUOFF_T, rstream->path,
+                                       "%s at %"PRIuUOFF_T,
+                                       i_stream_get_name(stream),
                                        rstream->from_offset);
                        } else {
                                i_assert(rstream->body_offset != (uoff_t)-1);
index 4f2705d1d6d6bf193f5dc5161c8e6b1123716ed2..f9ce166f3946c556b6afa4e78e55d3226f35be5a 100644 (file)
@@ -4,8 +4,7 @@
 /* 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.
    path is used only for logging purposes. */
-struct istream *i_stream_create_raw_mbox(struct istream *input,
-                                        const char *path);
+struct istream *i_stream_create_raw_mbox(struct istream *input);
 
 /* Return offset to beginning of the "\nFrom"-line. */
 uoff_t istream_raw_mbox_get_start_offset(struct istream *stream);
index 9aef60cae07b8c3edd5db68a49396abea2004f80..99a52325805f4126e471d7098c7cd88ab3b34ba9 100644 (file)
@@ -86,10 +86,10 @@ int mbox_file_open_stream(struct mbox_mailbox *mbox)
                        i_stream_set_init_buffer_size(mbox->mbox_file_stream,
                                                      MBOX_READ_BLOCK_SIZE);
                }
+               i_stream_set_name(mbox->mbox_file_stream, mbox->box.path);
        }
 
-       mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream,
-                                                    mbox->box.path);
+       mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream);
        if (mbox->mbox_lock_type != F_UNLCK)
                istream_raw_mbox_set_locked(mbox->mbox_stream);
        return 0;
index 9da9df532a839ef404b745f0883b9caa9b975d52..827923d0d5fa0ea1f1a741aac5ca56e6c8f091ea 100644 (file)
@@ -82,6 +82,7 @@ static int raw_mailbox_open(struct mailbox *box)
                return -1;
        }
        box->input = i_stream_create_fd(fd, MAIL_READ_FULL_BLOCK_SIZE, TRUE);
+       i_stream_set_name(box->input, box->path);
        i_stream_set_init_buffer_size(box->input, MAIL_READ_FULL_BLOCK_SIZE);
        return index_storage_mailbox_open(box, FALSE);
 }
index b4d0d45997417618eee4d0f8b4155b8c0cce91ee..7c906cff17d304438e4b859b98120db209664a78 100644 (file)
@@ -340,6 +340,7 @@ static int zlib_mailbox_open_input(struct mailbox *box)
                        return -1;
                }
                input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE);
+               i_stream_set_name(input, box->path);
                box->input = handler->create_istream(input, TRUE);
                i_stream_unref(&input);
                box->flags |= MAILBOX_FLAG_READONLY;