From 50dca7cf0ee2b15ea5c9d406d99a73f33bc77711 Mon Sep 17 00:00:00 2001 From: jamoflaw Date: Mon, 27 May 2019 23:05:20 +0100 Subject: [PATCH] Destroy semaphore after join I can't quite work out the logic behind this fix though I get a consistent hang on the worker threads (both my worker threads get stuck on sem_wait() - Line 181) when the semaphore is destroyed before the thread is joined, and the application never exits. This change resolves this. --- src/LinearMath/TaskScheduler/btThreadSupportPosix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LinearMath/TaskScheduler/btThreadSupportPosix.cpp b/src/LinearMath/TaskScheduler/btThreadSupportPosix.cpp index d80af09c7..a03f6dc57 100644 --- a/src/LinearMath/TaskScheduler/btThreadSupportPosix.cpp +++ b/src/LinearMath/TaskScheduler/btThreadSupportPosix.cpp @@ -304,8 +304,8 @@ void btThreadSupportPosix::stopThreads() checkPThreadFunction(sem_post(threadStatus.startSemaphore)); checkPThreadFunction(sem_wait(m_mainSemaphore)); - destroySem(threadStatus.startSemaphore); checkPThreadFunction(pthread_join(threadStatus.thread, 0)); + destroySem(threadStatus.startSemaphore); } destroySem(m_mainSemaphore); m_activeThreadStatus.clear();