free allocated stack by execution thread
[scilab.git] / scilab / modules / core / src / cpp / runner.cpp
index f38a0dc..f8fc4c0 100644 (file)
@@ -19,7 +19,7 @@ __threadSignalLock Runner::m_awakeScilabLock;
 void Runner::init()
 {
     __InitSignal(&m_awakeScilab);
-    __InitSignalLock(&m_awakeScilabLock); 
+    __InitSignalLock(&m_awakeScilabLock);
 }
 
 void *Runner::launch(void *args)
@@ -38,7 +38,7 @@ void *Runner::launch(void *args)
     }
     catch(ScilabException se)
     {
-        YaspWriteW(se.GetErrorMessage().c_str());
+        YaspErrorW(se.GetErrorMessage().c_str());
     }
 
 
@@ -62,6 +62,8 @@ void *Runner::launch(void *args)
 void Runner::LockPrompt()
 {
     __LockSignal(&m_awakeScilabLock);
+    //free locker to release thread
+    __UnLock(&m_lock);
     __Wait(&m_awakeScilab, &m_awakeScilabLock);
     __UnLockSignal(&m_awakeScilabLock);
 }
@@ -93,10 +95,14 @@ void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
 
         //register thread
         ConfigVariable::addThread(new ThreadId(threadId, threadKey));
-        //free locker to release thread
-        __UnLock(&m_lock);
-        //wait and of thread execution
+        //free locker to release thread && wait and of thread execution
         LockPrompt();
+
+        types::ThreadId* pExecThread = ConfigVariable::getThread(threadKey);
+        if(pExecThread == NULL)
+        {//call ptrhad_join to clean stack allocation
+            __WaitThreadDie(threadId);
+        }
     }
     catch(ScilabException se)
     {