Skip to content

Commit b2669a3

Browse files
authored
Destroy Node's handle before its Link (#660)
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.
1 parent 517a81e commit b2669a3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/h5cpp/node/node.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ namespace node {
3232

3333
Node::Node():
3434
attributes(*this),
35-
handle_(),
36-
link_()
35+
link_(),
36+
handle_()
3737
{}
3838

3939
Node::Node(ObjectHandle &&handle,const Link &link):
4040
attributes(*this),
41-
handle_(std::move(handle)),
42-
link_(link)
41+
link_(link),
42+
handle_(std::move(handle))
4343
{}
4444

4545
Node::Node(const Node &node):
4646
attributes(*this),
47-
handle_(node.handle_),
48-
link_(node.link_)
47+
link_(node.link_),
48+
handle_(node.handle_)
4949
{}
5050

5151
Node &Node::operator=(const Node &node)

src/h5cpp/node/node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class DLL_EXPORT Node
130130
attribute::AttributeManager attributes;
131131

132132
private:
133-
ObjectHandle handle_; //!< access handle to the object
134133
Link link_; //!< stores the link to the object
134+
ObjectHandle handle_; //!< access handle to the object
135135
};
136136

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

0 commit comments

Comments
 (0)