From 149ab1186ad6e8b8e7a8879bf40d56c905ccce3a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 21 Apr 2018 10:15:35 -0700 Subject: [PATCH] epicsThread fix join --- modules/libcom/src/osi/epicsThread.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/libcom/src/osi/epicsThread.cpp b/modules/libcom/src/osi/epicsThread.cpp index 52819c8eb..7092900b1 100644 --- a/modules/libcom/src/osi/epicsThread.cpp +++ b/modules/libcom/src/osi/epicsThread.cpp @@ -154,8 +154,11 @@ bool epicsThread::exitWait ( const double delay ) throw () *this->pThreadDestroyed = true; } if(!joined) { + { + epicsGuard < epicsMutex > guard ( this->mutex ); + joined = true; + } epicsThreadJoin(this->id); - joined = true; } return true; } @@ -170,9 +173,11 @@ bool epicsThread::exitWait ( const double delay ) throw () epicsTime current = epicsTime::getCurrent (); exitWaitElapsed = current - exitWaitBegin; } - if(!joined) { - epicsThreadJoin(this->id); + if(this->terminated && !joined) { joined = true; + + epicsGuardRelease < epicsMutex > unguard ( guard ); + epicsThreadJoin(this->id); } } catch ( std :: exception & except ) {