mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
new attempt to fix thread issues
This commit is contained in:
parent
383e40324d
commit
96012ef81f
@ -127,7 +127,13 @@ void RsTickingThread::fullstop()
|
||||
#ifdef DEBUG_THREADS
|
||||
THREAD_DEBUG << " waiting stop" << std::endl;
|
||||
#endif
|
||||
mHasStoppedSemaphore.wait();
|
||||
if(pthread_equal(mTid,pthread_self()))
|
||||
{
|
||||
std::cerr << "(WW) RsTickingThread::fullstop() called by same thread. This is unexpected." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
mHasStoppedSemaphore.wait_no_relock();
|
||||
#ifdef DEBUG_THREADS
|
||||
THREAD_DEBUG << " finished!" << std::endl;
|
||||
#endif
|
||||
|
@ -211,7 +211,9 @@ public:
|
||||
return s->val ;
|
||||
}
|
||||
|
||||
void wait()
|
||||
// waits but does not re-locks the semaphore
|
||||
|
||||
void wait_no_relock()
|
||||
{
|
||||
static const uint32_t max_waiting_time_before_warning=1000 *5 ; // 5 secs
|
||||
uint32_t tries=0;
|
||||
@ -224,10 +226,7 @@ public:
|
||||
|
||||
RS_STACK_MUTEX(s->mtx) ;
|
||||
if(s->val > 0)
|
||||
{
|
||||
--(s->val) ;
|
||||
return ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user