[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
Fri Jun 15 15:41:47 CDT 2012


branch "master" has been updated
       via  bc607a12fbd4420f10835a6fb0d5dcaef57faebd (commit)
      from  cab9a8e0b2f81f913f2c263226475737d93b53fb (commit)

Summary of changes:
 src/PJSIPSessionModule.cpp         |    9 +++++++--
 src/PJSIPSessionModule.h           |    2 +-
 src/SIPSession.cpp                 |   31 ++++++++++++++++++-------------
 src/SIPSession.h                   |    3 ++-
 src/SIPStateReplicatorListener.cpp |    2 +-
 5 files changed, 29 insertions(+), 18 deletions(-)


- Log -----------------------------------------------------------------
commit bc607a12fbd4420f10835a6fb0d5dcaef57faebd
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Jun 15 18:09:38 2012 -0230

    On the odd chance that the mechanism we use for getting the
    PJSIPSessionModInfo structure is not being held on until we get to the
    destroy step, we'll pass the pointer through to the destroy. That memory at
    least is allocated on the heap, so pjsip won't be messing with it.

diff --git a/src/PJSIPSessionModule.cpp b/src/PJSIPSessionModule.cpp
index 93593a6..1fae5f7 100644
--- a/src/PJSIPSessionModule.cpp
+++ b/src/PJSIPSessionModule.cpp
@@ -203,7 +203,10 @@ void PJSIPSessionModInfo::destroy()
     }
     if (t)
     {
-        t->destroy();
+        //
+        // The actual deletion of this object will occur from another thread.
+        //
+        t->destroy(this);
     }
 }
 
@@ -1784,7 +1787,8 @@ protected:
         if (mInvState == PJSIP_INV_STATE_DISCONNECTED)
         {
             PJSIPSessionModInfo *session_mod_info = (PJSIPSessionModInfo*)mInv->mod_data[mSessionModule->getModule().id];
-            if (session_mod_info == 0)
+            mInv->mod_data[mSessionModule->getModule().id] = 0;
+            if (session_mod_info == 0 || session_mod_info->mNeedsRemoval)
             {
                 return Complete;
             }
@@ -1894,6 +1898,7 @@ protected:
             lg(Debug) << "Replicating state on DISCONNECTED inv_state.";
             mSessionModule->replicateState(dlg_mod_info, NULL, session_mod_info);
             session_mod_info->destroy();
+
             if (dlg_mod_info)
             {
                 dlg->mod_data[mSessionModule->getModule().id] = 0;
diff --git a/src/PJSIPSessionModule.h b/src/PJSIPSessionModule.h
index bddb492..d08b475 100644
--- a/src/PJSIPSessionModule.h
+++ b/src/PJSIPSessionModule.h
@@ -326,7 +326,7 @@ public:
 
 typedef IceUtil::Handle<SIPQueueableOperation> SIPQueueableOperationPtr;
 
-class SIPAMICallbackOperation : public AsteriskSCF::System::WorkQueue::V1::SuspendableWork
+class SIPAMICallbackOperation : virtual public AsteriskSCF::System::WorkQueue::V1::SuspendableWork
 {
 public:
     SIPAMICallbackOperation(const Ice::AsyncResultPtr& r, const SIPQueueableOperationPtr& operation)
diff --git a/src/SIPSession.cpp b/src/SIPSession.cpp
index 1a86101..7931776 100755
--- a/src/SIPSession.cpp
+++ b/src/SIPSession.cpp
@@ -197,8 +197,11 @@ public:
         if (mInviteSession)
         {
             PJSIPSessionModInfo *session_mod_info = static_cast<PJSIPSessionModInfo*>(mInviteSession->mod_data[mManager->getSessionModule()->getModule().id]);
-            session_mod_info->updateSessionState(mInviteSession);
-            mManager->getSessionModule()->replicateState(NULL, NULL, session_mod_info);
+            if (session_mod_info)
+            {
+                session_mod_info->updateSessionState(mInviteSession);
+                mManager->getSessionModule()->replicateState(NULL, NULL, session_mod_info);
+            }
         }
     }
 
@@ -2926,7 +2929,10 @@ void SIPSession::setCookies(const AsteriskSCF::SessionCommunications::V1::Sessio
    if (mImplPriv->mInviteSession)
    {
        PJSIPSessionModInfo *session_mod_info = static_cast<PJSIPSessionModInfo*>(mImplPriv->mInviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id]);
-       session_mod_info->updateSessionState(mImplPriv->mInviteSession);
+       if (session_mod_info)
+       {
+           session_mod_info->updateSessionState(mImplPriv->mInviteSession);
+       }
        mImplPriv->mManager->getSessionModule()->replicateState(NULL, NULL, session_mod_info);
    }
 }
@@ -3273,8 +3279,9 @@ class DestroyOperation : public SuspendableWork
 {
 public:
 
-    DestroyOperation(const SIPSessionPtr& session, const boost::shared_ptr<SIPSessionPriv>& sessionPriv)
-        : mSession(session), mSessionPriv(sessionPriv) { }
+    DestroyOperation(const SIPSessionPtr& session, const boost::shared_ptr<SIPSessionPriv>& sessionPriv, 
+        PJSIPSessionModInfo* info)
+        : mSession(session), mSessionPriv(sessionPriv), mInfo(info){ }
 
     SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
     {
@@ -3331,13 +3338,10 @@ public:
         // and the pending operations in the session object. The only other way to do it would've been to have
         // cancelled and replaced all the pending operations... a bigger deal by far.
         //
-        if (mSessionPriv->mInviteSession)
+        if (mInfo)
         {
-            PJSIPSessionModInfo *session_mod_info =
-                static_cast<PJSIPSessionModInfo*>(
-                    mSessionPriv->mInviteSession->mod_data[mSessionPriv->mManager->getSessionModule()->getModule().id]);
-            mSessionPriv->mInviteSession->mod_data[mSessionPriv->mManager->getSessionModule()->getModule().id] = 0;
-            delete session_mod_info;
+            delete mInfo;
+            mInfo = 0;
         }
 
         return Complete;
@@ -3346,15 +3350,16 @@ public:
 private:
     SIPSessionPtr mSession;
     boost::shared_ptr<SIPSessionPriv> mSessionPriv;
+    PJSIPSessionModInfo* mInfo;
 };
 
 /**
  * Internal function called to destroy an endpoint. This is controlled by signaling.
  */
-void SIPSession::destroy()
+void SIPSession::destroy(PJSIPSessionModInfo* info)
 {
     lg(Debug) << "queuing a destroy operation";
-    enqueueSessionWork(new DestroyOperation(this, mImplPriv));
+    enqueueSessionWork(new DestroyOperation(this, mImplPriv, info));
 }
 
 void SIPSession::addKeys(const SIPEndpointMediaSRTPConfig& config, pjmedia_sdp_media* mediaSDP)
diff --git a/src/SIPSession.h b/src/SIPSession.h
index cc1d5d3..e4aa05a 100644
--- a/src/SIPSession.h
+++ b/src/SIPSession.h
@@ -58,6 +58,7 @@ struct NATEndpointOptions;
 
 class SIPEndpointSessionConfig;
 class SIPEndpointMediaSRTPConfig;
+class PJSIPSessionModInfo;
 
 /*
  * Private implementation class for SIPSession.
@@ -309,7 +310,7 @@ public:
      * Implementation specific functions.
      */
 
-    void destroy();
+    void destroy(PJSIPSessionModInfo* info);
 
     void addNATAttributes(const SIPEndpointSessionConfig& config, 
         const AsteriskSCF::System::NAT::V1::InteractiveConnectionAgentPrx& iceAgent,
diff --git a/src/SIPStateReplicatorListener.cpp b/src/SIPStateReplicatorListener.cpp
index 3c48ac2..0148319 100644
--- a/src/SIPStateReplicatorListener.cpp
+++ b/src/SIPStateReplicatorListener.cpp
@@ -49,7 +49,7 @@ public:
         pjsip_inv_terminate(mSession->getInviteSession(), 500, PJ_FALSE);
 
         // Now that pjsip is taken care of we can drop the session itself and consider life good
-        mSession->destroy();
+        mSession->destroy(0);
     }
 
     // Helper function which sets the session on this replicator item

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list