fixed GH #424: Poco::Timer deadlock

This commit is contained in:
Guenter Obiltschnig
2014-06-05 15:02:46 +02:00
parent c2704199ae
commit 6512ff1f6d

View File

@@ -61,14 +61,27 @@ void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority
{
Clock nextInvocation;
nextInvocation += static_cast<Clock::ClockVal>(_startInterval)*1000;
poco_assert (!_pCallback);
FastMutex::ScopedLock lock(_mutex);
if (_pCallback)
{
throw Poco::IllegalStateException("Timer already running");
}
_nextInvocation = nextInvocation;
_pCallback = method.clone();
_wakeUp.reset();
threadPool.startWithPriority(priority, *this);
try
{
threadPool.startWithPriority(priority, *this);
}
catch (...)
{
delete _pCallback;
_pCallback = 0;
throw;
}
}