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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 25 17:17:28 CDT 2011


branch "master" has been updated
       via  fb9f4f3a7b813ee52200427d9c544eccb439ea37 (commit)
      from  c81b0fc11568a4b86ab67f8fc9de678f1692c2b8 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp   |    5 ++++-
 src/SipSession.cpp           |   29 ++++++++++++++++++++---------
 src/SipSessionManagerApp.cpp |    4 ++++
 3 files changed, 28 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit fb9f4f3a7b813ee52200427d9c544eccb439ea37
Author: Brent Eagles <beagles at digium.com>
Date:   Wed May 25 19:44:02 2011 -0230

    Resolving a problem where the PJSessionModInfo destructor was calling destroy
    on the SipSession, which unfortunately calls back on the module which is in the process
    of being deleted to get the work queue. This solution does a sort of lazy initialization
    of a work queue reference in the SipSession. It would probably be better to just hand
    the workqueue to the SipSession when it was created. A low impact change like this is
    probably more appropriate at the moment.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 5cb8e64..83cf223 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -77,6 +77,9 @@ PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
 
 PJSipSessionModInfo::~PJSipSessionModInfo()
 {
+    //
+    // TODO : remove ourselves from the invite session's mod_data.
+    //
     if (mSession)
     {
         mSession->destroy();
@@ -1019,7 +1022,7 @@ protected:
         {
             listener->end_indicated(mAsyncResult);
         }
-        catch (const Ice::Exception& ex)
+        catch (const Ice::Exception&)
         {
             lg(Error) << "Ice exception when attempting to indicate something or other";
         }
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 315d1c8..940697d 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -243,6 +243,8 @@ public:
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
 
     AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
+
+    SessionWorkPtr mSessionWork;
 };
 
 void SipSession::initializePJSIPStructs()
@@ -299,7 +301,7 @@ void SipSession::initializePJSIPStructs()
     PJSipSessionModInfo *session_mod_info(new PJSipSessionModInfo(inviteSession, this, sessionWork));
     inviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id] = (void*)session_mod_info;
     pjsip_dlg_add_usage(dialog, &mImplPriv->mManager->getSessionModule()->getModule(), NULL);
-    mImplPriv->mInviteSession = inviteSession;
+    setInviteSession(inviteSession);
 }
 
 /**
@@ -1027,6 +1029,20 @@ pjsip_dialog *SipSession::getDialog()
 void SipSession::setInviteSession(pjsip_inv_session *session)
 {
     mImplPriv->mInviteSession = session;
+
+    if (!mImplPriv->mSessionWork)
+    {
+        PJSipSessionModInfo *session_mod_info =
+            static_cast<PJSipSessionModInfo*>(
+              mImplPriv->mInviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id]);
+
+        if (!session_mod_info)
+        {
+            lg(Debug) << "No session any longer. Unable to retrieve work queue";
+        }
+
+        mImplPriv->mSessionWork = session_mod_info->getSessionWork();
+    }
 }
 
 /**
@@ -1113,19 +1129,14 @@ void SipSession::enqueueSessionWork(const SuspendableWorkPtr& task)
         lg(Debug) << "No invite session yet. Unable to queue operation";
         return;
     }
-    PJSipSessionModInfo *session_mod_info =
-        static_cast<PJSipSessionModInfo*>(
-                mImplPriv->mInviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id]);
 
-    if (!session_mod_info)
+    if (!mImplPriv->mSessionWork)
     {
-	lg(Debug) << "No session any longer. Unable to queue operation";
+	lg(Debug) << "No work queue any longer. Unable to queue operation";
 	return;
     }
 
-    SessionWorkPtr sessionWork = session_mod_info->getSessionWork();
-
-    sessionWork->enqueueWork(task);
+    mImplPriv->mSessionWork->enqueueWork(task);
 }
 }; // end SipSessionManager
 }; // end AsteriskSCF
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 678a3e8..44fcd59 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -648,6 +648,10 @@ void SipSessionManager::stop()
     // Remove our state listener
     deregisterFromStateReplicator();
 
+    //
+    // TODO: This is probably a mistake. Many things access the PJSipManager instance and will continue
+    // to do so until all of the threads have completed. It really should be reference counted.
+    //
     delete mPJSipManager;
     mCommunicator->destroy();
 }

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list