summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-01-26 12:12:41 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-01-26 12:12:41 +0000
commit654ca084c7d1933dced2c4a1cd531c437f222d05 (patch)
treedf04bca52d05db4168f9de0da25698ee12aef3ce /fastos
parent8cf65d226a71500b928124e21ddd21396385d49a (diff)
Chunk large preads into multiple smaller preads of max 64MB.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/vespa/fastos/linux_file.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp
index 27beb1242d1..f1936ede2da 100644
--- a/fastos/src/vespa/fastos/linux_file.cpp
+++ b/fastos/src/vespa/fastos/linux_file.cpp
@@ -37,7 +37,18 @@ FastOS_Linux_File::FastOS_Linux_File(const char *filename)
ssize_t
FastOS_Linux_File::readInternal(int fh, void *buffer, size_t length, int64_t readOffset)
{
- return File_RW_Ops::pread(fh, buffer, length, readOffset);
+ char * data = static_cast<char *>(buffer);
+ ssize_t read(0);
+ while (read < ssize_t(length)) {
+ size_t lenNow = std::min(getChunkSize(), length - read);
+ ssize_t readNow = File_RW_Ops::pread(fh, data + read, lenNow, readOffset + read);
+ if (readNow > 0) {
+ read += readNow;
+ } else {
+ return (read > 0) ? read : readNow;
+ }
+ }
+ return read;
}