From: Renaud Barate Date: Tue, 7 Apr 2015 15:04:34 +0000 (+0200) Subject: Fix race condition that could cause a segmentation fault X-Git-Tag: V7_6_0b1~3^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e1566c2207d340a7521e846d1cdd39350737f2be;p=modules%2Fyacs.git Fix race condition that could cause a segmentation fault This segmentation fault happened randomly on schemas limited by YACS max number of threads. --- diff --git a/src/engine/Executor.cxx b/src/engine/Executor.cxx index 6496b8141..daa578be6 100644 --- a/src/engine/Executor.cxx +++ b/src/engine/Executor.cxx @@ -997,6 +997,8 @@ void Executor::launchTask(Task *task) DEBTRACE("before _semForMaxThreads.wait " << _semThreadCnt); if(_semThreadCnt == 0) { + // --- Critical section + YACS::BASES::AutoLocker alck(&_mutexForSchedulerUpdate); //check if we have enough threads to run std::set tmpSet=_runningTasks; std::set::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();