diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-08-13 05:43:00 +0200 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-08-13 05:47:43 +0200 |
commit | 735604976485ab69cd813d13ef53505bc454c201 (patch) | |
tree | dbec4f89a031316f73bba9460795bc21268ddbd9 /src/TaskMan.cc | |
parent | f6bb2cd9acaaeaae1d72edc49d321507f6893f8e (diff) |
Fixing rare multithreading crash.
-) Make sure to acquire the eventLock when possibly deleting a Task.
-) Keep the lock until we're done with it.
Diffstat (limited to 'src/TaskMan.cc')
-rw-r--r-- | src/TaskMan.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/TaskMan.cc b/src/TaskMan.cc index ae6cdcc..71d5bc6 100644 --- a/src/TaskMan.cc +++ b/src/TaskMan.cc @@ -333,6 +333,7 @@ int Balau::TaskMan::mainLoop() { for (auto iH = stopped.begin(); iH != stopped.end(); iH++) { Task * t = *iH; IAssert((t->getStatus() == Task::STOPPED) || (t->getStatus() == Task::FAULTED), "Task %p in stopped list but isn't stopped.", t); + t->m_eventLock.enter(); if (t->m_waitedBy.size() == 0) { freeStack(t->m_stack); stopped.erase(iH); @@ -340,10 +341,13 @@ int Balau::TaskMan::mainLoop() { IAssert(iH != m_tasks.end(), "Task %p in stopped list but not in m_tasks...", t); m_tasks.erase(iH); IAssert(yielded.find(t) == yielded.end(), "Task %p is deleted but is in yielded list... ?", t); + t->m_eventLock.leave(); delete t; didDelete = true; break; } + if (!didDelete) + t->m_eventLock.leave(); } } while (didDelete); |