From 5d74b5cee1c11e7035ba99fa23d724175203319c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 8 May 2019 18:39:00 +0200 Subject: input/cache: first draft of the file cache --- src/input/BufferingInputStream.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/input/BufferingInputStream.cxx') diff --git a/src/input/BufferingInputStream.cxx b/src/input/BufferingInputStream.cxx index 8888f597c..9bdb91b49 100644 --- a/src/input/BufferingInputStream.cxx +++ b/src/input/BufferingInputStream.cxx @@ -152,6 +152,18 @@ BufferingInputStream::RunThreadLocked(std::unique_lock &lock) continue; } + /* enforce an upper limit for each + InputStream::Read() call; this is necessary + for plugins which are unable to do partial + reads, e.g. when reading local files, the + read() system call will not return until + all requested bytes have been read from the + hard disk, instead of returning when "some" + data has been read */ + constexpr size_t MAX_READ = 64 * 1024; + if (w.size > MAX_READ) + w.size = MAX_READ; + size_t nbytes = input->Read(lock, w.data, w.size); buffer.Commit(read_offset, read_offset + nbytes); -- cgit v1.2.3