[asterisk-scf-commits] asterisk-scf/release/media_operations_core.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 22 10:43:58 CDT 2011


branch "master" has been updated
       via  4a225125a0701d5446c0e27c93c8610ba18f01c2 (commit)
       via  d4088b2c7514a2dcfbb7036fc4d0cfee9a046626 (commit)
      from  52a1c399215cca3fd4c3627818639113e30d1148 (commit)

Summary of changes:
 src/MediaOperationsCore.cpp |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 4a225125a0701d5446c0e27c93c8610ba18f01c2
Merge: d4088b2 52a1c39
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Sep 22 10:43:55 2011 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/release/media_operations_core


commit d4088b2c7514a2dcfbb7036fc4d0cfee9a046626
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Sep 22 10:40:49 2011 -0500

    Various PJLIB-related fixes to resolve a crash problem.
    
    After starting this component, and leaving it idle, the Ice runtime will decide
    to terminate a number of the threads it started initially. At this point, the
    component crashed due a double-free being attempted. The underlying cause for
    this was not calling pj_init() before calling pj_thread_register(), so this
    patch corrects that and also changes a few other things.
    
    * Add a constructor to ThreadDescWrapper to ensure that mDesc is zeroed.
    * Add a constructor to pjLibHook to call pj_init().
    * Rename pjLibHook::pjThreads to mpjThreads to conform to coding guidelines.
    * Test for a non-success result from pj_thread_register() (although unfortunately
      it does not return a failure in the situation described above).

diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 296d41b..7c80d67 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -102,6 +102,11 @@ typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
 class ThreadDescWrapper
 {
 public:
+    ThreadDescWrapper()
+    {
+        memset(mDesc, 0, sizeof(mDesc));
+    }
+
     /**
      * pjthread thread description information, must persist for the life of the thread
      */
@@ -120,17 +125,28 @@ typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
 class pjlibHook : public Ice::ThreadNotification
 {
 public:
+    pjlibHook()
+    {
+	    pj_init();
+    }
+
     /**
      * Implementation of the start function which is called when a thread starts.
      */
     void start()
     {
-        ThreadDescWrapperPtr wrapper = ThreadDescWrapperPtr(new ThreadDescWrapper());
+        ThreadDescWrapperPtr wrapper(new ThreadDescWrapper());
         pj_thread_t *thread;
-        pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
+        pj_status_t win = pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
+	if (win != PJ_SUCCESS)
+	{
+            lg(Critical) << "Unable to register thread with PJLIB.";
+	    return;
+	}
+	else
         {
             boost::lock_guard<boost::mutex> lock(mLock);
-            pjThreads.insert(std::make_pair(thread, wrapper));
+            mpjThreads.insert(std::make_pair(thread, wrapper));
         }
     }
 
@@ -142,7 +158,7 @@ public:
         if (pj_thread_is_registered())
         {
             boost::lock_guard<boost::mutex> lock(mLock);
-            pjThreads.erase(pj_thread_this());
+            mpjThreads.erase(pj_thread_this());
         }
     }
 
@@ -150,7 +166,7 @@ private:
     /**
      * A map containing thread lifetime persistent data.
      */
-    std::map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
+    std::map<pj_thread_t*, ThreadDescWrapperPtr> mpjThreads;
     /**
      * Mutex to protect the map
      */

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


-- 
asterisk-scf/release/media_operations_core.git



More information about the asterisk-scf-commits mailing list