missing Lock on parseur added. 46/16946/2
Cedric Delamarre [Fri, 31 Jul 2015 14:48:59 +0000 (16:48 +0200)]
Change-Id: Ibedce4c81d18effaf9e30cbe7179d9de116d5b14

scilab/modules/core/src/cpp/tasks.cpp
scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp

index 41a7e94..66c4aa3 100644 (file)
@@ -21,6 +21,7 @@
 #include "debugvisitor.hxx"
 #include "stepvisitor.hxx"
 #include "visitor_common.hxx"
+#include "threadmanagement.hxx"
 
 #include "scilabWrite.hxx"
 #include "runner.hxx"
@@ -228,15 +229,18 @@ void execScilabStartTask(bool _bSerialize)
     wstring stSCI = ConfigVariable::getSCIPath();
 
     stSCI += SCILAB_START;
+    ThreadManagement::LockParser();
     parse.parseFile(stSCI, L"");
 
     if (parse.getExitStatus() != Parser::Succeded)
     {
         scilabWriteW(parse.getErrorMessage());
         scilabWriteW(L"Failed to parse scilab.start");
+        ThreadManagement::UnlockParser();
         return;
     }
 
+    ThreadManagement::UnlockParser();
     execAstTask(parse.getTree(), _bSerialize, false, false, false, true, true, false);
 }
 
@@ -250,15 +254,18 @@ void execScilabQuitTask(bool _bSerialize)
     wstring stSCI = ConfigVariable::getSCIPath();
 
     stSCI += SCILAB_QUIT;
+    ThreadManagement::LockParser();
     parse.parseFile(stSCI, L"");
 
     if (parse.getExitStatus() != Parser::Succeded)
     {
         scilabWriteW(parse.getErrorMessage());
         scilabWriteW(L"Failed to parse scilab.quit");
+        ThreadManagement::UnlockParser();
         return;
     }
 
+    ThreadManagement::UnlockParser();
     execAstTask(parse.getTree(), _bSerialize, false, false, false, true, true, false);
 }
 
index f898a09..fa01a40 100644 (file)
@@ -161,6 +161,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
             return Function::Error;
         }
 
+        ThreadManagement::LockParser();
         parser.parseFile(pwstTemp, L"exec");
         FREE(pwstTemp);
         if (parser.getExitStatus() !=  Parser::Succeded)
@@ -174,6 +175,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
                 ConfigVariable::setLastErrorNumber(999);
                 delete parser.getTree();
                 mclose(iID);
+                ThreadManagement::UnlockParser();
                 return Function::OK;
             }
 
@@ -183,6 +185,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
 
             delete parser.getTree();
             mclose(iID);
+            ThreadManagement::UnlockParser();
             return Function::Error;
         }
 
@@ -205,6 +208,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
             pExp = parser.getTree();
         }
 
+        ThreadManagement::UnlockParser();
         // update where to set the name of the executed file.
         ConfigVariable::setFileNameToLastWhere(pwstFile);
 
index 585957b..0c06a81 100644 (file)
@@ -22,6 +22,7 @@
 #include "scilabWrite.hxx"
 #include "scilabexception.hxx"
 #include "configvariable.hxx"
+#include "threadmanagement.hxx"
 
 #include <iostream>
 #include <fstream>
@@ -139,6 +140,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
         pstCommand[iPos] = 0;
     }
 
+    ThreadManagement::LockParser();
     parser.parse(pstCommand);
     FREE(pstCommand);
     if (parser.getExitStatus() !=  Parser::Succeded)
@@ -150,6 +152,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
             ConfigVariable::setLastErrorCall();
             ConfigVariable::setLastErrorMessage(parser.getErrorMessage());
             ConfigVariable::setLastErrorNumber(999);
+            ThreadManagement::UnlockParser();
             return Function::OK;
         }
         else
@@ -157,6 +160,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
             char* pst = wide_string_to_UTF8(parser.getErrorMessage());
             Scierror(999, "%s", pst);
             FREE(pst);
+            ThreadManagement::UnlockParser();
             return Function::Error;
         }
     }
@@ -180,6 +184,8 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
         pExp = parser.getTree();
     }
 
+    ThreadManagement::UnlockParser();
+
     if (pExp == NULL)
     {
         return Function::Error;