]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added struct istream.readable_fd, which is used to determine if sendfile() can be...
authorTimo Sirainen <tss@iki.fi>
Sun, 28 Jun 2009 01:08:45 +0000 (21:08 -0400)
committerTimo Sirainen <tss@iki.fi>
Sun, 28 Jun 2009 01:08:45 +0000 (21:08 -0400)
--HG--
branch : HEAD

13 files changed:
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

index 5a779d445b5cfa3b60b0dfb62a21962c69b8f154..917131502275557c7a29f6a45172d6a79e43043c 100644 (file)
@@ -232,6 +232,7 @@ struct istream *i_stream_create_dot(struct istream *input, bool send_last_lf)
        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;
index 4030de228ef42f41654b775757750f6cd7c4b425..858d66177375d5731e012638b7fb5d3b0b23c7cc 100644 (file)
@@ -415,6 +415,7 @@ i_stream_create_header_filter(struct istream *input,
        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;
 
index 556173950f10de22186140178325908f2556f904..55eb615b22cbcfa3aa08a6c1501c747f376a0d3b 100644 (file)
@@ -438,6 +438,7 @@ i_stream_create_raw_mbox(struct istream *input, const char *path)
        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;
 
index d18a455d3da4bc87eb0bae9c3cb1ffe7c7b8d3ae..343837487676ae687f27368f4a5e7f2e51117abe 100644 (file)
@@ -269,6 +269,7 @@ struct istream *i_stream_create_concat(struct istream *input[])
        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);
index 28d98d342fe4fa051a3f5f0f0beb189bb44d1743..50562645b5731fae2c1914184775b4e76bc0ce0a 100644 (file)
@@ -151,6 +151,7 @@ i_stream_create_crlf_full(struct istream *input, bool crlf)
                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,
index f7b1114443122104e652fdc6498abcc3aaf4242e..d493cb7132238a99c34869ac68d754f7853a4573 100644 (file)
@@ -27,6 +27,7 @@ struct istream *i_stream_create_from_data(const void *data, size_t size)
        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);
index e224dcc00d3881253eebeae77648b39a21cfef3c..e3cd90d9fb58d97801d206dadf7c286d1c4e8f68 100644 (file)
@@ -162,6 +162,7 @@ struct istream *i_stream_create_fd(int fd, size_t max_buffer_size,
                fstream->istream.istream.blocking = TRUE;
                fstream->istream.istream.seekable = TRUE;
        }
+       fstream->istream.istream.readable_fd = TRUE;
 
        return i_stream_create(&fstream->istream, NULL, fd);
 }
index d4f5f4dd69e5f8f950f5aa046795125c42dc4c24..343d228c852766dcadebd02b391f33c009958bb4 100644 (file)
@@ -138,6 +138,7 @@ struct istream *i_stream_create_limit(struct istream *input, uoff_t v_size)
        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,
index 7a0e259c120f550d89590b5c45c0f4c335ba7520..5781697156e6b749bba6309ac7bf991ffc1ae8fd 100644 (file)
@@ -219,6 +219,7 @@ struct istream *i_stream_create_mmap(int fd, size_t block_size,
        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;
index 48705743a82c6c1e6dab6c025d4f546cf7a82152..49e3a1622d12dc880023de137bbebbbab0f5700a 100644 (file)
@@ -319,6 +319,7 @@ i_stream_create_seekable(struct istream *input[],
        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);
index 9c99af23750e5b67c6f3a9f0e604894181847f28..bac9ca74b11b54e83cbd9ae67b36a4676f77455c 100644 (file)
@@ -11,6 +11,8 @@ struct istream {
        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) */
index 6e041fb3b1c0ba2d74ab9b03a082342f8ca6c765..a0f3317b2821bb028dca82eb69406ceae18164d4 100644 (file)
@@ -856,7 +856,7 @@ static off_t o_stream_file_send_istream(struct ostream_private *outstream,
        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
index 2a101f20605ac80d8fb2731f656a21fa360395d2..69f8c3819e39025a45ee5dbac8ecca1281239136 100644 (file)
@@ -237,6 +237,7 @@ struct istream *i_stream_create_zlib(int fd)
                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