Mercurial > dovecot > core-2.2
changeset 9540:622509c562e8 HEAD
Added struct istream.readable_fd, which is used to determine if sendfile() can be used.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 27 Jun 2009 21:08:45 -0400 |
parents | 7e4fe0c07661 |
children | 56dc85882e9e |
files | src/lib-mail/istream-dot.c src/lib-mail/istream-header-filter.c src/lib-storage/index/mbox/istream-raw-mbox.c src/lib/istream-concat.c src/lib/istream-crlf.c src/lib/istream-data.c src/lib/istream-file.c src/lib/istream-limit.c src/lib/istream-mmap.c src/lib/istream-seekable.c src/lib/istream.h src/lib/ostream-file.c src/plugins/zlib/istream-zlib.c |
diffstat | 13 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/istream-dot.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib-mail/istream-dot.c Sat Jun 27 21:08:45 2009 -0400 @@ -232,6 +232,7 @@ dstream->istream.read = i_stream_dot_read; dstream->istream.stat = i_stream_dot_stat; + dstream->istream.istream.readable_fd = FALSE; dstream->istream.istream.blocking = input->blocking; dstream->istream.istream.seekable = FALSE; dstream->send_last_lf = send_last_lf;
--- a/src/lib-mail/istream-header-filter.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib-mail/istream-header-filter.c Sat Jun 27 21:08:45 2009 -0400 @@ -415,6 +415,7 @@ mstream->istream.sync = i_stream_header_filter_sync; mstream->istream.stat = i_stream_header_filter_stat; + mstream->istream.istream.readable_fd = FALSE; mstream->istream.istream.blocking = input->blocking; mstream->istream.istream.seekable = input->seekable;
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Jun 27 21:08:45 2009 -0400 @@ -438,6 +438,7 @@ rstream->istream.sync = i_stream_raw_mbox_sync; rstream->istream.stat = i_stream_raw_mbox_stat; + rstream->istream.istream.readable_fd = input->readable_fd; rstream->istream.istream.blocking = input->blocking; rstream->istream.istream.seekable = input->seekable;
--- a/src/lib/istream-concat.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-concat.c Sat Jun 27 21:08:45 2009 -0400 @@ -269,6 +269,7 @@ cstream->istream.seek = i_stream_concat_seek; cstream->istream.stat = i_stream_concat_stat; + cstream->istream.istream.readable_fd = FALSE; cstream->istream.istream.blocking = blocking; cstream->istream.istream.seekable = seekable; return i_stream_create(&cstream->istream, NULL, -1);
--- a/src/lib/istream-crlf.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-crlf.c Sat Jun 27 21:08:45 2009 -0400 @@ -151,6 +151,7 @@ i_stream_crlf_read_lf; cstream->istream.stat = i_stream_crlf_stat; + cstream->istream.istream.readable_fd = FALSE; cstream->istream.istream.blocking = input->blocking; cstream->istream.istream.seekable = FALSE; return i_stream_create(&cstream->istream, input,
--- a/src/lib/istream-data.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-data.c Sat Jun 27 21:08:45 2009 -0400 @@ -27,6 +27,7 @@ stream->read = i_stream_data_read; stream->seek = i_stream_data_seek; + stream->istream.readable_fd = FALSE; stream->istream.blocking = TRUE; stream->istream.seekable = TRUE; (void)i_stream_create(stream, NULL, -1);
--- a/src/lib/istream-file.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-file.c Sat Jun 27 21:08:45 2009 -0400 @@ -162,6 +162,7 @@ fstream->istream.istream.blocking = TRUE; fstream->istream.istream.seekable = TRUE; } + fstream->istream.istream.readable_fd = TRUE; return i_stream_create(&fstream->istream, NULL, fd); }
--- a/src/lib/istream-limit.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-limit.c Sat Jun 27 21:08:45 2009 -0400 @@ -138,6 +138,7 @@ lstream->istream.stat = i_stream_limit_stat; lstream->istream.get_size = i_stream_limit_get_size; + lstream->istream.istream.readable_fd = input->readable_fd; lstream->istream.istream.blocking = input->blocking; lstream->istream.istream.seekable = input->seekable; return i_stream_create(&lstream->istream, input,
--- a/src/lib/istream-mmap.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-mmap.c Sat Jun 27 21:08:45 2009 -0400 @@ -219,6 +219,7 @@ mstream->istream.sync = i_stream_mmap_sync; mstream->istream.stat = i_stream_mmap_stat; + mstream->istream.istream.readable_fd = TRUE; mstream->istream.abs_start_offset = start_offset; istream = i_stream_create(&mstream->istream, NULL, fd); istream->mmaped = TRUE;
--- a/src/lib/istream-seekable.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream-seekable.c Sat Jun 27 21:08:45 2009 -0400 @@ -319,6 +319,7 @@ sstream->istream.seek = i_stream_seekable_seek; sstream->istream.stat = i_stream_seekable_stat; + sstream->istream.istream.readable_fd = FALSE; sstream->istream.istream.blocking = blocking; sstream->istream.istream.seekable = TRUE; return i_stream_create(&sstream->istream, NULL, -1);
--- a/src/lib/istream.h Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/istream.h Sat Jun 27 21:08:45 2009 -0400 @@ -11,6 +11,8 @@ unsigned int mmaped:1; /* be careful when copying data */ unsigned int blocking:1; /* read() shouldn't return 0 */ unsigned int closed:1; + unsigned int readable_fd:1; /* fd can be read directly if necessary + (for sendfile()) */ unsigned int seekable:1; /* we can seek() backwards */ unsigned int eof:1; /* read() has reached to end of file (but may still be data available in buffer) */
--- a/src/lib/ostream-file.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/lib/ostream-file.c Sat Jun 27 21:08:45 2009 -0400 @@ -856,7 +856,7 @@ off_t in_abs_offset, ret; int in_fd; - in_fd = i_stream_get_fd(instream); + in_fd = !instream->readable_fd ? -1 : i_stream_get_fd(instream); if (in_fd == foutstream->fd) { /* copying data within same fd. we'll have to be careful with
--- a/src/plugins/zlib/istream-zlib.c Sat Jun 27 21:06:57 2009 -0400 +++ b/src/plugins/zlib/istream-zlib.c Sat Jun 27 21:08:45 2009 -0400 @@ -237,6 +237,7 @@ zstream->istream.istream.seekable = TRUE; } - return i_stream_create(&zstream->istream, NULL, -1); + zstream->istream.istream.readable_fd = FALSE; + return i_stream_create(&zstream->istream, NULL, fd); } #endif