Skip to content

Commit

Permalink
XrdApps::JCache: handle incomplete reads in vector cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Joachim Peters committed Jun 10, 2024
1 parent b8c8af9 commit 0e27a6c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/XrdApps/XrdClJCachePlugin/vector/XrdClVectorCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ bool VectorCache::retrieve() const {
std::ifstream inFile(fileName, std::ios::binary);
if (inFile.is_open()) {
inFile.read((char*)data, fileInfo.st_size);
if (inFile.fail()) {
if (verbose) {
std::cerr << "error: failed to read cached data" << std::endl;
}
} else {
std::streamsize bytesRead = inFile.gcount();
if (bytesRead != fileInfo.st_size) {
if (verbose) {
std::cerr << "error: read only " << bytesRead << " bytes instead of " << fileInfo.st_size << " !"<< std::endl;
}
return false;
}
}
inFile.close();
return true;
} else {
Expand Down

0 comments on commit 0e27a6c

Please sign in to comment.