dovecot-2.2: lib-fs: If fs_read_stream() creates a seekable stre...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Feb 26 17:44:47 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/d84c7c11d7b7
changeset: 15980:d84c7c11d7b7
user: Timo Sirainen <tss at iki.fi>
date: Tue Feb 26 17:44:34 2013 +0200
description:
lib-fs: If fs_read_stream() creates a seekable stream, keep it open for future reads.
diffstat:
src/lib-fs/fs-api-private.h | 1 +
src/lib-fs/fs-api.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diffs (45 lines):
diff -r 9297e1fcbe9e -r d84c7c11d7b7 src/lib-fs/fs-api-private.h
--- a/src/lib-fs/fs-api-private.h Tue Feb 26 17:18:18 2013 +0200
+++ b/src/lib-fs/fs-api-private.h Tue Feb 26 17:44:34 2013 +0200
@@ -69,6 +69,7 @@
char *path;
enum fs_open_flags flags;
+ struct istream *seekable_input;
struct istream *pending_read_input;
bool write_pending;
diff -r 9297e1fcbe9e -r d84c7c11d7b7 src/lib-fs/fs-api.c
--- a/src/lib-fs/fs-api.c Tue Feb 26 17:18:18 2013 +0200
+++ b/src/lib-fs/fs-api.c Tue Feb 26 17:44:34 2013 +0200
@@ -166,6 +166,8 @@
if (file->pending_read_input != NULL)
i_stream_unref(&file->pending_read_input);
+ if (file->seekable_input != NULL)
+ i_stream_unref(&file->seekable_input);
if (file->copy_input != NULL) {
i_stream_unref(&file->copy_input);
@@ -287,6 +289,11 @@
ssize_t ret;
bool want_seekable = FALSE;
+ if (file->seekable_input != NULL) {
+ i_stream_seek(file->seekable_input, 0);
+ i_stream_ref(file->seekable_input);
+ return file->seekable_input;
+ }
input = file->fs->v.read_stream(file, max_buffer_size);
if (input->stream_errno != 0) {
/* read failed already */
@@ -306,6 +313,9 @@
file->fs->temp_path_prefix);
i_stream_set_name(input, i_stream_get_name(inputs[0]));
i_stream_unref(&inputs[0]);
+
+ file->seekable_input = input;
+ i_stream_ref(file->seekable_input);
}
if ((file->flags & FS_OPEN_FLAG_ASYNC) == 0 && !input->blocking) {
/* read the whole input stream before returning */
More information about the dovecot-cvs
mailing list