From fba193569e09cedb03dce32042b91dfc1dd43c24 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Wed, 20 Oct 2010 16:29:52 +0000 Subject: ChangeLogTag:Wed Oct 20 16:07:09 UTC 2010 Steve Huston --- ChangeLog | 8 ++++++++ ace/Timer_Queue_Adapters.cpp | 12 ++++++++++-- ace/Timer_Queue_T.cpp | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 361108fdfa3..ca8f74c3f0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Oct 20 16:07:09 UTC 2010 Steve Huston + + * ace/Timer_Queue_Adapters.cpp (ACE_Thread_Timer_Queue_Adapter::svc): + * ace/Timer_Queue_T.cpp (expire): + Temporarily release and reacquire the mutex around timer dispatch. + This prevents a deadlock on user code with multiple threads doing + timer-related operations. + Thu Sep 02 11:18:34 EDT 2010 Steve Huston * ACE version 5.7b released. diff --git a/ace/Timer_Queue_Adapters.cpp b/ace/Timer_Queue_Adapters.cpp index 0c4fc51b573..6b6db9f1bf4 100644 --- a/ace/Timer_Queue_Adapters.cpp +++ b/ace/Timer_Queue_Adapters.cpp @@ -17,6 +17,7 @@ # include "ace/Timer_Queue_Adapters.inl" # endif /* __ACE_INLINE__ */ +#include "ace/Reverse_Lock_T.h" #include "ace/Signal.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_sys_time.h" @@ -278,8 +279,15 @@ ACE_Thread_Timer_Queue_Adapter::svc (void) } } - // Expire timers anyway, at worst this is a no-op. - this->timer_queue_->expire (); + // Expire timers anyway, at worst this is a no-op. Release the lock + // while dispatching; the timer queue has its own lock to protect + // itself. + { + ACE_Reverse_Lock rel (this->mutex_); + ACE_GUARD_RETURN (ACE_Reverse_Lock, + rmon, rel, -1); + this->timer_queue_->expire (); + } } // Thread cancellation point, if ACE supports it. diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 2ac9a29e9aa..5f5cb126d36 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -18,6 +18,7 @@ #include "ace/Guard_T.h" #include "ace/Log_Msg.h" #include "ace/Reactor_Timer_Interface.h" +#include "ace/Reverse_Lock_T.h" #include "ace/Null_Mutex.h" #include "ace/OS_NS_sys_time.h" @@ -267,6 +268,9 @@ ACE_Timer_Queue_T::expire (const ACE_Time_Value &cur_ti while ((result = this->dispatch_info_i (cur_time, info)) != 0) { + ACE_MT (ACE_Reverse_Lock rev_lk(this->mutex_)); + ACE_MT (ACE_GUARD_RETURN (ACE_Reverse_Lock, rmon, rev_lk, -1)); + const void *upcall_act = 0; this->preinvoke (info, cur_time, upcall_act); -- cgit v1.2.1