[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 4 12:03:42 CDT 2011


branch "master" has been updated
       via  0eb08367686faa45b4f1d6604dfb589686990c03 (commit)
      from  85f2a4943c854ec6f5f08c7ac8a609c912160fc3 (commit)

Summary of changes:
 include/AsteriskSCF/PJLib/ThreadHook.h |    2 +-
 src/PJLib/ThreadHook.cpp               |   28 ++++++++++++++++++----------
 2 files changed, 19 insertions(+), 11 deletions(-)


- Log -----------------------------------------------------------------
commit 0eb08367686faa45b4f1d6604dfb589686990c03
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Oct 4 12:03:21 2011 -0500

    Fixed nasty memory bug.

diff --git a/include/AsteriskSCF/PJLib/ThreadHook.h b/include/AsteriskSCF/PJLib/ThreadHook.h
index dbae437..300ab45 100644
--- a/include/AsteriskSCF/PJLib/ThreadHook.h
+++ b/include/AsteriskSCF/PJLib/ThreadHook.h
@@ -142,7 +142,7 @@ private:
     /**
      * A string indicating the group that threads being tracked by this hook belong to.
      */
-    const std::string& mThreadGroup;
+    const std::string mThreadGroup;
 };
 
 } // end namespace PJLib
diff --git a/src/PJLib/ThreadHook.cpp b/src/PJLib/ThreadHook.cpp
index 4467acb..5d3b887 100644
--- a/src/PJLib/ThreadHook.cpp
+++ b/src/PJLib/ThreadHook.cpp
@@ -59,18 +59,26 @@ ThreadHook::ThreadHook(const std::string& threadGroup) : mThreadGroup(threadGrou
  */
 void ThreadHook::start()
 {
-    ThreadDescWrapperPtr wrapper(new ThreadDescWrapper());
-    pj_thread_t *thread;
-    std::string threadDescription = mThreadGroup + " Thread";
-
-    pj_status_t status = pj_thread_register(threadDescription.c_str(), wrapper->mDesc, &thread);
-    if (status != PJ_SUCCESS)
+    try
     {
-        throw ThreadRegistrationFailed(status);
+        ThreadDescWrapperPtr wrapper(new ThreadDescWrapper());
+        pj_thread_t *thread;
+        std::string threadDescription = mThreadGroup + " Thread";
+
+        pj_status_t status = pj_thread_register(threadDescription.c_str(), wrapper->mDesc, &thread);
+        if (status != PJ_SUCCESS)
+        {
+            throw ThreadRegistrationFailed(status);
+        }
+
+        boost::lock_guard<boost::mutex> lock(mMapLock);
+        mpjThreads.insert(std::make_pair(thread, wrapper));
+    }
+    catch(std::exception& ex)
+    {
+        std::cout << "ThreadHook::start() - " << ex.what() << std::endl;
+        throw; // This catch only useful for debugging. Rethrow it, because we can't handle it.
     }
-
-    boost::lock_guard<boost::mutex> lock(mMapLock);
-    mpjThreads.insert(std::make_pair(thread, wrapper));
 }
 
 /**

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list