dovecot-2.0: Set input stream names for mail file streams.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 6 14:05:34 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/638c4ea4a9ce
changeset: 10849:638c4ea4a9ce
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 06 14:04:42 2010 +0200
description:
Set input stream names for mail file streams.
diffstat:
src/lda/main.c | 1 +
src/lib-storage/index/cydir/cydir-mail.c | 1 +
src/lib-storage/index/dbox-common/dbox-file.c | 1 +
src/lib-storage/index/maildir/maildir-mail.c | 29 +++++++++++++++++++++--------
src/lib-storage/index/mbox/istream-raw-mbox.c | 20 ++++++++++----------
src/lib-storage/index/mbox/istream-raw-mbox.h | 3 +--
src/lib-storage/index/mbox/mbox-file.c | 4 ++--
src/lib-storage/index/raw/raw-storage.c | 1 +
src/plugins/zlib/zlib-plugin.c | 1 +
9 files changed, 39 insertions(+), 22 deletions(-)
diffs (228 lines):
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lda/main.c
--- a/src/lda/main.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lda/main.c Sat Mar 06 14:04:42 2010 +0200
@@ -404,6 +404,7 @@
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) {
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/cydir/cydir-mail.c
--- a/src/lib-storage/index/cydir/cydir-mail.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/cydir/cydir-mail.c Sat Mar 06 14:04:42 2010 +0200
@@ -113,6 +113,7 @@
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);
}
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/dbox-common/dbox-file.c
--- a/src/lib-storage/index/dbox-common/dbox-file.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-file.c Sat Mar 06 14:04:42 2010 +0200
@@ -204,6 +204,7 @@
}
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);
}
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/maildir/maildir-mail.c Sat Mar 06 14:04:42 2010 +0200
@@ -13,12 +13,20 @@
#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 @@
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;
}
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Mar 06 14:04:42 2010 +0200
@@ -10,7 +10,7 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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);
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/mbox/istream-raw-mbox.h
--- a/src/lib-storage/index/mbox/istream-raw-mbox.h Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.h Sat Mar 06 14:04:42 2010 +0200
@@ -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);
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/mbox/mbox-file.c
--- a/src/lib-storage/index/mbox/mbox-file.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/mbox/mbox-file.c Sat Mar 06 14:04:42 2010 +0200
@@ -86,10 +86,10 @@
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;
diff -r 2375e84fd344 -r 638c4ea4a9ce src/lib-storage/index/raw/raw-storage.c
--- a/src/lib-storage/index/raw/raw-storage.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/lib-storage/index/raw/raw-storage.c Sat Mar 06 14:04:42 2010 +0200
@@ -82,6 +82,7 @@
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);
}
diff -r 2375e84fd344 -r 638c4ea4a9ce src/plugins/zlib/zlib-plugin.c
--- a/src/plugins/zlib/zlib-plugin.c Sat Mar 06 14:02:13 2010 +0200
+++ b/src/plugins/zlib/zlib-plugin.c Sat Mar 06 14:04:42 2010 +0200
@@ -340,6 +340,7 @@
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;
More information about the dovecot-cvs
mailing list