diff options
Diffstat (limited to 'ace/Task.cpp')
-rw-r--r-- | ace/Task.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ace/Task.cpp b/ace/Task.cpp index 293bbb187f0..8617e6ec183 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -13,6 +13,8 @@ ACE_RCSID (ace, "$Id$") +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man) : thr_count_ (0), thr_mgr_ (thr_man), @@ -90,7 +92,7 @@ int ACE_Task_Base::suspend (void) { ACE_TRACE ("ACE_Task_Base::suspend"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); if (this->thr_count_ > 0) return this->thr_mgr_->suspend_task (this); @@ -102,7 +104,7 @@ int ACE_Task_Base::resume (void) { ACE_TRACE ("ACE_Task_Base::resume"); - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); if (this->thr_count_ > 0) return this->thr_mgr_->resume_task (this); @@ -124,7 +126,7 @@ ACE_Task_Base::activate (long flags, ACE_TRACE ("ACE_Task_Base::activate"); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1); // If the task passed in is zero, we will use <this> if (task == 0) @@ -214,9 +216,13 @@ ACE_Task_Base::cleanup (void *object, void *) { ACE_Task_Base *t = (ACE_Task_Base *) object; + // The thread count decrement and close must be done atomically + // so that thr_count checks from within close are correct. + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, t->lock_)); + // The thread count must be decremented first in case the <close> // hook does something crazy like "delete this". - t->thr_count_dec (); + --(t->thr_count_); // @@ Is it possible to pass in the exit status somehow? t->close (); @@ -272,3 +278,5 @@ ACE_Task_Base::svc_run (void *args) #endif return status; } + +ACE_END_VERSIONED_NAMESPACE_DECL |