JFJochXFELReader: the positional-read handles are held for the most recent files only

The direct chunk read opened one HDF5ImageSource::RawFile per file and never released it, so the
MAX_OPEN_FILES bound on the HDF5 handles did not hold for that path: a dataset stored one frame per
file would keep a descriptor per file open. They now follow the same least-recently-used bound; a
reading thread still holding a released handle keeps it through its shared_ptr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-21 01:52:55 +02:00
1 parent 2bd3616388
commit 3d8728e3a1
2 files changed
+10 -1

No files matched your search

+7
View File
@@ -84,6 +84,7 @@ std::shared_ptr<const HDF5ImageSource::RawFile> JFJochXFELReader::RawFileAt(size
if (raw_files_.size() != files_.size()) {
raw_files_.assign(files_.size(), nullptr);
user_block_.assign(files_.size(), 0);
raw_order_.clear();
}
if (!raw_files_[file]) {
const hid_t fcpl = H5Fget_create_plist(FileAt(file).GetID());
@@ -97,6 +98,11 @@ std::shared_ptr<const HDF5ImageSource::RawFile> JFJochXFELReader::RawFileAt(size
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot open " + files_[file]);
raw_files_[file] = raw;
user_block_[file] = user_block;
raw_order_.push_back(file);
if (raw_order_.size() > MAX_OPEN_FILES) {
raw_files_[raw_order_.front()].reset();
raw_order_.erase(raw_order_.begin());
}
}
return raw_files_[file];
}
@@ -718,6 +724,7 @@ void JFJochXFELReader::Close() {
open_files_.clear();
raw_files_.clear();
user_block_.clear();
raw_order_.clear();
files_.clear();
frames_.clear();
dataset_.reset();
+3 -1
View File
@@ -84,9 +84,11 @@ class JFJochXFELReader : public JFJochReader {
};
Layout layout_;
// Positional-read handles on the files, opened as first needed (under hdf5_mutex), with the size of
// each file's user block, which HDF5 chunk addresses count from.
// each file's user block, which HDF5 chunk addresses count from. Like open_files_, only the most
// recently used MAX_OPEN_FILES are held (raw_order_); a reader still using a released one keeps it.
mutable std::vector<std::shared_ptr<const HDF5ImageSource::RawFile>> raw_files_;
mutable std::vector<uint64_t> user_block_;
mutable std::vector<size_t> raw_order_;
static Layout ReadLayout(HDF5ReadOnlyFile &file, const Frame &frame);
// The files, in the order given, every frame in them, and the run's mean of every value the geometry