Index: src/libchcore/TTask.cpp =================================================================== diff -u -N -re96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3 -rba618764ec3c9221fa704e905a9f807bd85ed4c5 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision e96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision ba618764ec3c9221fa704e905a9f807bd85ed4c5) @@ -191,17 +191,40 @@ } } - void TTask::Store() + void TTask::Store(bool bForce) { if (GetTaskState() == eTaskState_LoadError) { DBTRACE0(_T("Task::Store() - not storing task as it was not loaded correctly\n")); return; } - TSimpleTimer timer(true); DBTRACE0(_T("###### Task::Store() - starting\n")); + // ensure we're only running one serialization of this task at a time; + // (this is usually called from the gui thread (on timer) and at specific points + // of task processing; there were times where + if(!bForce) + { + if (!m_mutexSerializer.try_lock()) + { + DBTRACE0(_T("###### Task::Store() - serialization already running. Skipping.\n")); + return; + } + } + else + { + if (!m_mutexSerializer.try_lock()) + { + DBTRACE0(_T("###### Task::Store() - waiting for serialization mutex...\n")); + m_mutexSerializer.lock(); + } + } + + std::unique_lock locke(m_mutexSerializer, std::adopt_lock); + + TSimpleTimer timer(true); + using namespace chcore; { @@ -550,7 +573,7 @@ m_tSubTaskContext.GetFilesCache().Clear(); // scanning for files did not finish processing, so the content of the files cache are useless // save progress before killed - Store(); + Store(true); // reset flags SetContinueFlag(false);