From 178cc6870b95ae8c44c7752b945f8593fe4d4f20 Mon Sep 17 00:00:00 2001 From: FlyingSamson Date: Wed, 4 Dec 2024 14:58:56 +0100 Subject: [PATCH] Destroy `Node`'s handle before its `Link` 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. --- src/h5cpp/node/node.cpp | 12 ++++++------ src/h5cpp/node/node.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/h5cpp/node/node.cpp b/src/h5cpp/node/node.cpp index 0e0d4b5855..2d2a25c9bc 100644 --- a/src/h5cpp/node/node.cpp +++ b/src/h5cpp/node/node.cpp @@ -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) diff --git a/src/h5cpp/node/node.hpp b/src/h5cpp/node/node.hpp index bf76821698..4c51ff13a6 100644 --- a/src/h5cpp/node/node.hpp +++ b/src/h5cpp/node/node.hpp @@ -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);