From ae1de7745389f7b76f19f3a634eca7518bbdc104 Mon Sep 17 00:00:00 2001
From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk>
Date: Mon, 19 Nov 2012 11:01:28 +0000
Subject: [PATCH] Re #5963. Temporary fix by preventing parallel file checking

---
 .../Framework/DataHandling/inc/MantidDataHandling/Load.h    | 4 ++++
 Code/Mantid/Framework/DataHandling/src/Load.cpp             | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h
index 12fa72f6b2f..1de6f00cf34 100644
--- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h
+++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h
@@ -5,6 +5,8 @@
 // Includes
 //----------------------------------------------------------------------
 #include "MantidAPI/IDataFileChecker.h"
+#include <Poco/Mutex.h>
+
 #include <list>
 
 namespace Mantid
@@ -104,6 +106,8 @@ namespace Mantid
       std::set<std::string> m_baseProps;
       /// The actual loader
       API::IDataFileChecker_sptr m_loader;
+      /// Mutex for temporary fix for #5963
+      static Poco::Mutex m_mutex;
      };
 
   } // namespace DataHandling
diff --git a/Code/Mantid/Framework/DataHandling/src/Load.cpp b/Code/Mantid/Framework/DataHandling/src/Load.cpp
index 061d9ff66e9..3deb40c59dd 100644
--- a/Code/Mantid/Framework/DataHandling/src/Load.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/Load.cpp
@@ -51,7 +51,6 @@ Load('event_ws', Filename='INSTR_1000_event.nxs',Precount=True)
 #include "MantidAPI/IMDEventWorkspace.h"
 #include <cstdio>
 
-
 namespace
 {
   /**
@@ -147,6 +146,9 @@ namespace Mantid
     // Register the algorithm into the algorithm factory
     DECLARE_ALGORITHM(Load);
     
+    // The mutex
+    Poco::Mutex Load::m_mutex;
+
     /// Sets documentation strings for this algorithm
     void Load::initDocs()
     {
@@ -273,6 +275,8 @@ namespace Mantid
         throw std::runtime_error("Error while closing file \"" + filePath + "\"");
       } 
 
+      Poco::Mutex::ScopedLock lock( m_mutex );
+
       // Iterate through all loaders and attempt to find the best qualified for the job.
       // Each algorithm has a quick and long file check. The long version returns an integer
       // giving its certainty about be able to load the file. The highest wins.
-- 
GitLab