Salome HOME
First test qui HPsalome container is running.
[modules/yacs.git] / src / runtime / XMLNode.cxx
index e2563387569b712c79b3b7289b52674c9d65bc48..e44a60a32ce3009b89de56e33bf95f1d2f2a0c33 100644 (file)
@@ -21,6 +21,7 @@
 #include "XMLPorts.hxx"
 #include "Mutex.hxx"
 #include "TypeCode.hxx"
+#include "AutoLocker.hxx"
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -91,21 +92,22 @@ void XmlNode::execute()
   DEBTRACE("execute");
   char dir[]="yacsXXXXXX";
   // add a lock around mkdtemp (seems not thread safe)
-  MUTEX.lock();
+  {
+    YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&MUTEX);
 #ifdef WIN32
-  char mdir [512+1];
-  GetTempPath(MAX_PATH+1, mdir);
-  CreateDirectory(mdir, NULL);
+    char mdir [512+1];
+    GetTempPath(MAX_PATH+1, mdir);
+    CreateDirectory(mdir, NULL);
 #else
-  char* mdir=mkdtemp(dir);
+    char* mdir=mkdtemp(dir);
 #endif
-  MUTEX.unlock();
-  if(mdir==NULL)
-    {
-      perror("mkdtemp failed");
-      std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl;
-      throw Exception("Execution problem in mkdtemp");
-    }
+    if(mdir==NULL)
+      {
+        perror("mkdtemp failed");
+        std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl;
+        throw Exception("Execution problem in mkdtemp");
+      }
+  }
   std::string sdir(dir);
   std::string input=sdir+"/input";
   std::ofstream f(input.c_str());