Commit dfabb622 authored by Jan Kotanski's avatar Jan Kotanski
Browse files

workaround for problem with closing in STRONG mode

parent 32d85b1e
From: Jan Kotanski <jankotan@gmail.com>
Date: Thu, 12 Jul 2018 07:45:24 +0200
Subject: workaround for problem with closing in STRONG mode
---
src/h5cpp/core/object_handle.cpp | 4 ++++
src/h5cpp/file/file.cpp | 25 ++++++++++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/h5cpp/core/object_handle.cpp b/src/h5cpp/core/object_handle.cpp
index 7007789..abb4d9b 100644
--- a/src/h5cpp/core/object_handle.cpp
+++ b/src/h5cpp/core/object_handle.cpp
@@ -22,6 +22,7 @@
// Authors:
// Eugen Wintersberger <eugen.wintersberger@desy.de>
// Martin Shetty <martin.shetty@esss.se>
+// Jan Kotanski <jan.kotanski@desy.de>
// Created on: Aug 07, 2017
//
@@ -199,6 +200,9 @@ void ObjectHandle::close()
case ObjectHandle::Type::DATASPACE:
error_code = H5Sclose(handle_);
break;
+ case ObjectHandle::Type::GROUP:
+ error_code = H5Gclose(handle_);
+ break;
case ObjectHandle::Type::DATATYPE:
error_code = H5Tclose(handle_);
break;
diff --git a/src/h5cpp/file/file.cpp b/src/h5cpp/file/file.cpp
index f670887..eb6f234 100644
--- a/src/h5cpp/file/file.cpp
+++ b/src/h5cpp/file/file.cpp
@@ -19,8 +19,10 @@
// Boston, MA 02110-1301 USA
// ===========================================================================
//
-// Authors: Eugen Wintersberger <eugen.wintersberger@desy.de>
-// Author: Martin Shetty <martin.shetty@esss.se>
+// Authors:
+// Eugen Wintersberger <eugen.wintersberger@desy.de>
+// Martin Shetty <martin.shetty@esss.se>
+// Jan Kotanski <jan.kotanski@desy.de>
// Created on: Sep 8, 2017
//
@@ -28,6 +30,7 @@
#include <h5cpp/node/node.hpp>
#include <h5cpp/node/group.hpp>
#include <h5cpp/error/error.hpp>
+#include <h5cpp/property/file_access.hpp>
namespace hdf5 {
namespace file {
@@ -67,9 +70,25 @@ void File::flush(Scope scope) const
}
}
+
void File::close()
{
- handle_.close();
+ property::FileAccessList fapl = property::FileAccessList(ObjectHandle(H5Fget_access_plist(static_cast<hid_t>(*this))));
+
+ if(fapl.close_degree() == property::CloseDegree::STRONG)
+ {
+ hid_t mid= static_cast<hid_t>(*this);
+ handle_.close();
+ // closes all copies of file hid_t's created with Node::link_.parent_file_
+ while(H5Iget_type(mid) > 0)
+ {
+ H5Fclose(mid);
+ }
+ }
+ else
+ {
+ handle_.close();
+ }
}
boost::filesystem::path File::path() const
0001-workaround-for-problem-with-closing-in-STRONG-mode.patch
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment