diff --git a/mt/CThread.cpp b/mt/CThread.cpp index 0b2a098a..6e40060b 100644 --- a/mt/CThread.cpp +++ b/mt/CThread.cpp @@ -3,6 +3,7 @@ #include "XThread.h" #include "CLock.h" #include "CStopwatch.h" +#include "CLog.h" // // CThreadPtr @@ -75,6 +76,8 @@ void CThread::sleep(double timeout) void CThread::exit(void* result) { + CThreadPtr currentRep(CThreadRep::getCurrentThreadRep()); + log((CLOG_DEBUG "throw exit on thread %p", currentRep.operator->())); throw XThreadExit(result); } diff --git a/mt/CThreadRep.cpp b/mt/CThreadRep.cpp index 87847f29..cdcccd99 100644 --- a/mt/CThreadRep.cpp +++ b/mt/CThreadRep.cpp @@ -3,6 +3,7 @@ #include "CMutex.h" #include "CLock.h" #include "XThread.h" +#include "CLog.h" #include "IJob.h" #include @@ -229,14 +230,19 @@ void CThreadRep::doThreadFunc() catch (XThreadCancel&) { // client called cancel() + log((CLOG_DEBUG "caught cancel on thread %p", this)); } catch (XThreadExit& e) { // client called exit() result = e.m_result; + log((CLOG_DEBUG "caught exit on thread %p", this)); + } + catch (...) { + log((CLOG_DEBUG "caught exit on thread %p", this)); + // note -- don't catch (...) to avoid masking bugs + throw; } - - // note -- don't catch (...) to avoid masking bugs // done with job delete m_job; @@ -286,6 +292,7 @@ void CThreadRep::cancel() m_cancel = true; // break out of system calls + log((CLOG_DEBUG "cancel thread %p", this)); pthread_kill(m_thread, SIGALRM); } } @@ -304,6 +311,7 @@ void CThreadRep::testCancel() } // start cancel + log((CLOG_DEBUG "throw cancel on thread %p", this)); throw XThreadCancel(); } @@ -401,6 +409,7 @@ void CThreadRep::sleep(double timeout) void CThreadRep::cancel() { + log((CLOG_DEBUG "cancel thread %p", this)); SetEvent(m_cancel); } @@ -423,6 +432,7 @@ void CThreadRep::testCancel() } // start cancel + log((CLOG_DEBUG "throw cancel on thread %p", this)); throw XThreadCancel(); } diff --git a/mt/CTimerThread.cpp b/mt/CTimerThread.cpp index d1d7d48f..3d149c45 100644 --- a/mt/CTimerThread.cpp +++ b/mt/CTimerThread.cpp @@ -18,7 +18,10 @@ CTimerThread::CTimerThread(double timeout) : m_timeout(timeout) CTimerThread::~CTimerThread() { + log((CLOG_DEBUG "cancelling timeout")); m_timingThread->cancel(); + m_timingThread->wait(); + log((CLOG_DEBUG "cancelled timeout")); delete m_timingThread; delete m_callingThread; }