From e1566c2207d340a7521e846d1cdd39350737f2be Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Tue, 7 Apr 2015 17:04:34 +0200 Subject: [PATCH] Fix race condition that could cause a segmentation fault This segmentation fault happened randomly on schemas limited by YACS max number of threads. --- src/engine/Executor.cxx | 3 +++ 1 file changed, 3 insertions(+) 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(); -- 2.39.2