diff --git a/src/XrdFileCache/XrdFileCacheIOEntireFile.cc b/src/XrdFileCache/XrdFileCacheIOEntireFile.cc index 09ff327a14f..ed009b61ec9 100644 --- a/src/XrdFileCache/XrdFileCacheIOEntireFile.cc +++ b/src/XrdFileCache/XrdFileCacheIOEntireFile.cc @@ -86,7 +86,9 @@ int IOEntireFile::Read (char *buff, long long off, int size) clLog()->Debug(XrdCl::AppMsg, "IO::Read() [%p] %lld@%d %s", this, off, size, m_io.Path()); // protect from reads over the file size - if (off >= m_io.FSize() || off < 0) + if (off >= m_io.FSize()) + return 0; + if (off < 0) { errno = EINVAL; return -1; diff --git a/src/XrdFileCache/XrdFileCacheIOFileBlock.cc b/src/XrdFileCache/XrdFileCacheIOFileBlock.cc index ed3e54c4b24..e2ef7ae55e4 100644 --- a/src/XrdFileCache/XrdFileCacheIOFileBlock.cc +++ b/src/XrdFileCache/XrdFileCacheIOFileBlock.cc @@ -127,7 +127,9 @@ bool IOFileBlock::ioActive() int IOFileBlock::Read (char *buff, long long off, int size) { // protect from reads over the file size - if (off >= m_io.FSize() || off < 0) + if (off >= m_io.FSize()) + return 0; + if (off < 0) { errno = EINVAL; return -1; diff --git a/src/XrdFileCache/XrdFileCachePrefetch.cc b/src/XrdFileCache/XrdFileCachePrefetch.cc index c21b20c384d..9d4bed9ae35 100644 --- a/src/XrdFileCache/XrdFileCachePrefetch.cc +++ b/src/XrdFileCache/XrdFileCachePrefetch.cc @@ -871,6 +871,19 @@ ssize_t Prefetch::ReadInBlocks(char *buff, off_t off, size_t size) int Prefetch::ReadV (const XrdOucIOVec *readV, int n) { + { + XrdSysCondVarHelper monitor(m_stateCond); + + // AMT check if this can be done once during initalization + if (m_failed) return m_input.ReadV(readV, n); + + if ( ! m_started) + { + m_stateCond.Wait(); + if (m_failed) return 0; + } + } + // check if read sizes are big enough to cache XrdCl::XRootDStatus Status;