Skip to content

Commit

Permalink
Destroy Node's handle before its Link
Browse files Browse the repository at this point in the history
Fixes #659.

Nodes must first delete the handle to the underlying hdf5
resource before deleting their link.
Otherwise (i.e., link is deleted first), hdf5 attempts to
close the file (if this was the last node referencing the
file), which might fail (e.g., when using mpi-io, or close
degree `Semi`) because the handle to the node would still
be around.
  • Loading branch information
FlyingSamson committed Dec 4, 2024
1 parent 517a81e commit 178cc68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/h5cpp/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ namespace node {

Node::Node():
attributes(*this),
handle_(),
link_()
link_(),
handle_()
{}

Node::Node(ObjectHandle &&handle,const Link &link):
attributes(*this),
handle_(std::move(handle)),
link_(link)
link_(link),
handle_(std::move(handle))
{}

Node::Node(const Node &node):
attributes(*this),
handle_(node.handle_),
link_(node.link_)
link_(node.link_),
handle_(node.handle_)
{}

Node &Node::operator=(const Node &node)
Expand Down
2 changes: 1 addition & 1 deletion src/h5cpp/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class DLL_EXPORT Node
attribute::AttributeManager attributes;

private:
ObjectHandle handle_; //!< access handle to the object
Link link_; //!< stores the link to the object
ObjectHandle handle_; //!< access handle to the object
};

DLL_EXPORT bool operator==(const Node &lhs, const Node &rhs);
Expand Down

0 comments on commit 178cc68

Please sign in to comment.