[ismrmrd] 23/281: Fixed bug which caused problems when trying to write images to a non-existing file from multiple threads

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:00:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit 599d8f9b96fb49feec050f7746843b675bd23632
Author: Michael S. Hansen <michael.hansen at nih.gov>
Date:   Sun Sep 2 13:24:41 2012 -0400

    Fixed bug which caused problems when trying to write images to a non-existing file from multiple threads
---
 ismrmrd_hdf5.cpp | 9 +++++++++
 ismrmrd_hdf5.h   | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ismrmrd_hdf5.cpp b/ismrmrd_hdf5.cpp
index 117aa9a..1e1d42f 100644
--- a/ismrmrd_hdf5.cpp
+++ b/ismrmrd_hdf5.cpp
@@ -19,6 +19,7 @@ int IsmrmrdDataset::openHDF5File()
 				return -1;
 			}
 			file_ = boost::shared_ptr<H5File>(new H5File(filename_, H5F_ACC_RDWR));
+
 		} catch (...) {
 			std::cerr << "Failed to open HDF5 file." << std::endl;
 			return -1;
@@ -27,6 +28,14 @@ int IsmrmrdDataset::openHDF5File()
 	} else if (create_file_if_needed_){
 		try {
 			file_ = boost::shared_ptr<H5File>(new H5File(filename_, H5F_ACC_TRUNC));
+
+			//We will close and then immediately open the file again.
+			//We need to make sure the file is saved as an HDF5 file in case other processes and functions
+			//need to access it immediately. The line above does not cause the file to be marked as and HDF5 file.
+			//H5File::isHdf5(filename_.c_str()) will return false at this point.
+			file_->close();
+			file_ = boost::shared_ptr<H5File>(new H5File(filename_, H5F_ACC_RDWR));
+
 		} catch (...) {
 			std::cerr << "Failed to create and open HDF5 file." << std::endl;
 			return -1;
diff --git a/ismrmrd_hdf5.h b/ismrmrd_hdf5.h
index 84f522c..24ba78a 100644
--- a/ismrmrd_hdf5.h
+++ b/ismrmrd_hdf5.h
@@ -71,7 +71,7 @@ public:
 	, create_file_if_needed_(create_file_if_needed)
 	{
 		std::ifstream ifile(filename_.c_str());
-		file_exists_ = ifile;
+		file_exists_ = ifile.is_open();
 
 		if (openHDF5File() < 0) {
 			std::cerr << "IsmrmrdDataset: Error opening HDF file." << std::endl;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list