summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2020-08-26 21:36:25 +0200
committerGitHub <noreply@github.com>2020-08-26 21:36:25 +0200
commit80a604ead86de08b50ff7e64c79e8bb866cc72eb (patch)
tree2c67e804a8423fa6c37d4b821f82a88ec9295dc0
parent75f62ae39027c656a5c4a936ecd2be10b0ac0293 (diff)
parent0c2d1a119120df3e6f615c82cbb23d39e9763dfa (diff)
downloadATCD-80a604ead86de08b50ff7e64c79e8bb866cc72eb.tar.gz
Merge pull request #1225 from jwillemsen/likema-thr-mgr-join-leak-deadlock
Fix ACE_Thread_Manager::join memory leak
-rw-r--r--ACE/ace/Log_Msg_Callback.h38
-rw-r--r--ACE/ace/Thread_Manager.cpp8
2 files changed, 25 insertions, 21 deletions
diff --git a/ACE/ace/Log_Msg_Callback.h b/ACE/ace/Log_Msg_Callback.h
index 0493a076933..f61587013ee 100644
--- a/ACE/ace/Log_Msg_Callback.h
+++ b/ACE/ace/Log_Msg_Callback.h
@@ -27,27 +27,27 @@ class ACE_Log_Record;
*
* @brief An interface class used to get logging callbacks.
*
- * Users who are interested in getting the logging messages
- * directly, can subclass this interface and override the log()
- * method. They must then register their subclass with the
- * Log_Msg class and make sure that they turn on the
- * ACE_Log_Msg::MSG_CALLBACK flag.
+ * Users who are interested in getting the logging messages
+ * directly, can subclass this interface and override the log()
+ * method. They must then register their subclass with the
+ * Log_Msg class and make sure that they turn on the
+ * ACE_Log_Msg::MSG_CALLBACK flag.
*
- * Your log() routine is called with an instance of
- * ACE_Log_Record. From this class, you can get the log
- * message, the verbose log message, message type, message
- * priority, and so on.
+ * Your log() routine is called with an instance of
+ * ACE_Log_Record. From this class, you can get the log
+ * message, the verbose log message, message type, message
+ * priority, and so on.
*
- * Remember that there is one Log_Msg object per thread.
- * Therefore, you may need to register your callback object with
- * many ACE_Log_Msg objects (and have the correct
- * synchronization in the log() method) or have a separate
- * callback object per Log_Msg object. Moreover,
- * ACE_Log_Msg_Callbacks are not inherited when a new thread
- * is spawned because it might have been allocated off of the
- * stack of the original thread, in which case all hell would
- * break loose... Therefore, you'll need to reset these in each
- * new thread.
+ * Remember that there is one Log_Msg object per thread.
+ * Therefore, you may need to register your callback object with
+ * many ACE_Log_Msg objects (and have the correct
+ * synchronization in the log() method) or have a separate
+ * callback object per Log_Msg object. Moreover,
+ * ACE_Log_Msg_Callbacks are not inherited when a new thread
+ * is spawned because it might have been allocated off of the
+ * stack of the original thread, in which case all hell would
+ * break loose... Therefore, you'll need to reset these in each
+ * new thread.
*/
class ACE_Export ACE_Log_Msg_Callback
{
diff --git a/ACE/ace/Thread_Manager.cpp b/ACE/ace/Thread_Manager.cpp
index 172e4a43af8..0d6de7694ca 100644
--- a/ACE/ace/Thread_Manager.cpp
+++ b/ACE/ace/Thread_Manager.cpp
@@ -1496,14 +1496,18 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
{
if (ACE_OS::thr_equal (biter.next ()->thr_id_, tid))
{
- ACE_Thread_Descriptor_Base *tdbl = biter.advance_and_remove (false);
+#if defined (ACE_HAS_CPP11)
+ std::unique_ptr<ACE_Thread_Descriptor_Base> tdbl (biter.advance_and_remove (false));
+#else
+ auto_ptr<ACE_Thread_Descriptor_Base> tdbl (biter.advance_and_remove (false));
+#endif /* ACE_HAS_CPP11 */
+ ace_mon.release();
#ifndef ACE_LACKS_PTHREAD_JOIN
if (ACE_Thread::join (tdbl->thr_handle_, status) == -1)
{
return -1;
}
#endif
- delete tdbl;
// return immediately if we've found the thread we want to join.
return 0;