From 8dfe080bf03fde34415f3edfbb0426260eeaeaec Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 1 Apr 2012 00:06:59 -0700 Subject: The TaskEvent wasn't thread-safe. --- src/Task.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Task.cc b/src/Task.cc index 0a1b2db..0938ff3 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -150,6 +150,7 @@ void Balau::Events::BaseEvent::doSignal() { } Balau::Events::TaskEvent::TaskEvent(Task * taskWaited) : m_taskWaited(taskWaited), m_ack(false), m_distant(false) { + ScopeLock lock(m_taskWaited->m_eventLock); m_taskWaited->m_waitedBy.push_back(this); } @@ -184,14 +185,15 @@ void Balau::Events::TaskEvent::ack() { AAssert(!m_ack, "You can't ack() a task event twice."); bool deleted = false; Task * t = m_taskWaited; - Task::waitedByList_t::iterator i; - for (i = t->m_waitedBy.begin(); i != t->m_waitedBy.end(); i++) { + t->m_eventLock.enter(); + for (auto i = t->m_waitedBy.begin(); i != t->m_waitedBy.end(); i++) { if (*i == this) { t->m_waitedBy.erase(i); deleted = true; break; } } + t->m_eventLock.leave(); Printer::elog(E_TASK, "TaskEvent at %p being ack; removing from the 'waited by' list of %p (%s - %s); deleted = %s", this, t, t->getName(), ClassName(t).c_str(), deleted ? "true" : "false"); IAssert(deleted, "We didn't find task %p in the waitedBy lists... ?", this); m_ack = true; -- cgit v1.2.3