X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fbase%2Fthread.cpp;h=fa923debe3ddf08aed24ec059b663a1b7486e071;hb=f511d4deb0207bc0ef18a2b2bbf7cfac9540a319;hp=58c4fd72619a1064f2971fe265a0f41d3df8c5b7;hpb=be6b92c9568ef62e88f517ad0a62edc32fc63d61;p=vuplus_dvbapp diff --git a/lib/base/thread.cpp b/lib/base/thread.cpp index 58c4fd7..fa923de 100644 --- a/lib/base/thread.cpp +++ b/lib/base/thread.cpp @@ -9,12 +9,9 @@ void eThread::thread_completed(void *ptr) eThread *p = (eThread*) ptr; p->m_alive = 0; - /* recover state */ - if (!p->m_state.value()) - { - p->m_state.up(); - ASSERT(p->m_state.value() == 1); - } + /* recover state in case thread was cancelled before calling hasStarted */ + if (!p->m_started) + p->hasStarted(); p->thread_finished(); } @@ -48,6 +45,7 @@ int eThread::runAsync(int prio, int policy) ASSERT(m_state.value() == 0); m_alive = 1; + m_started = 0; /* start thread. */ pthread_attr_t attr; @@ -125,5 +123,6 @@ void eThread::kill(bool sendcancel) void eThread::hasStarted() { ASSERT(!m_state.value()); + m_started = 1; m_state.up(); }