]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Fix race condition that could cause a segmentation fault
authorRenaud Barate <renaud.barate@edf.fr>
Tue, 7 Apr 2015 15:04:34 +0000 (17:04 +0200)
committerRenaud Barate <renaud.barate@edf.fr>
Tue, 7 Apr 2015 15:04:34 +0000 (17:04 +0200)
This segmentation fault happened randomly on
schemas limited by YACS max number of threads.

src/engine/Executor.cxx

index 6496b81414e7c4e97ee19510313cb54a44f27390..daa578be6bec8f1f1356f114175a126852ea49d9 100644 (file)
@@ -997,6 +997,8 @@ void Executor::launchTask(Task *task)
   DEBTRACE("before _semForMaxThreads.wait " << _semThreadCnt);
   if(_semThreadCnt == 0)
     {
+      // --- Critical section
+      YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
       //check if we have enough threads to run
       std::set<Task*> tmpSet=_runningTasks;
       std::set<Task*>::iterator it = tmpSet.begin();
@@ -1022,6 +1024,7 @@ void Executor::launchTask(Task *task)
           std::cerr << "WARNING: maybe you need more threads to run your schema (current value="<< _maxThreads << ")" << std::endl;
           std::cerr << "If it is the case, set the YACS_MAX_THREADS environment variable to a bigger value (export YACS_MAX_THREADS=xxx)" << std::endl;
         }
+      // --- End of critical section
     }
 
   _semForMaxThreads.wait();