[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 Apr 27 11:30:19 CDT 2011


branch "master" has been updated
       via  5077625e83930a58b416ecac15e4a5a4faddf206 (commit)
      from  c7e5b4344e2f6745eeae14f1d77b6606a32475f7 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit 5077625e83930a58b416ecac15e4a5a4faddf206
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Apr 27 11:29:21 2011 -0500

    Fix problem where we are pointing to invalid data after an AMI callback.
    
    This idea was hinted at by Benny Prijorno in an e-mail conversation we
    had and it appears to work!

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 0d15243..868670a 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -84,8 +84,8 @@ typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
 class ConnectBridgedSessionsCallback : public IceUtil::Shared
 {
 public:
-    ConnectBridgedSessionsCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, const SipSessionPtr& session)
-        : mInvSession(inv_session), mRData(rdata), mSession(session) { }
+    ConnectBridgedSessionsCallback(pjsip_inv_session *inv_session, pjsip_tx_data *tdata, pjsip_transaction *tsx, const SipSessionPtr& session)
+        : mInvSession(inv_session), mTData(tdata), mTsx(tsx), mSession(session) { }
 
     void callback(const Ice::AsyncResultPtr &r)
     {
@@ -97,10 +97,11 @@ public:
         catch (const std::exception &e)
         {
             lg(Debug) << "ConnectBridgedSessionsCallback sending 400 due to exception:  " << e.what();
-            pjsip_dlg_respond(mInvSession->dlg, mRData, 400, NULL, NULL, NULL);
+            pjsip_dlg_modify_response(mInvSession->dlg, mTData, 400, NULL);
+            pjsip_dlg_send_response(mInvSession->dlg, mTsx, mTData);
             return;
         }
-        pjsip_dlg_respond(mInvSession->dlg, mRData, 200, NULL, NULL, NULL);
+        pjsip_dlg_send_response(mInvSession->dlg, mTsx, mTData);
         
         Ice::Current current;
         lg(Debug) << "ConnectBridgedSessionsCallback calling session->stop(). ";
@@ -108,7 +109,8 @@ public:
     }
 private:
     pjsip_inv_session *mInvSession;
-    pjsip_rx_data *mRData;
+    pjsip_tx_data *mTData;
+    pjsip_transaction *mTsx;
     SipSessionPtr mSession;
 };
 
@@ -117,9 +119,9 @@ typedef IceUtil::Handle<ConnectBridgedSessionsCallback> ConnectBridgedSessionsCa
 class ConnectBridgedSessionsWithDestinationCallback : public IceUtil::Shared
 {
 public:
-    ConnectBridgedSessionsWithDestinationCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata,
-            const SipSessionPtr& session, const std::string& target)
-        : mInvSession(inv_session), mRData(rdata), mSession(session), mTarget(target) { }
+    ConnectBridgedSessionsWithDestinationCallback(pjsip_inv_session *inv_session, pjsip_tx_data *tdata,
+            pjsip_transaction *tsx, const SipSessionPtr& session, const std::string& target)
+        : mInvSession(inv_session), mTData(tdata), mTsx(tsx), mSession(session), mTarget(target) { }
 
     void callback(const Ice::AsyncResultPtr &r)
     {
@@ -133,16 +135,18 @@ public:
             lg(Debug) << "ConnectBridgedSessionsWithDestination sending 404 due to destination not found for target: "
                       << mTarget;
 
-            pjsip_dlg_respond(mInvSession->dlg, mRData, 404, NULL, NULL, NULL);
+            pjsip_dlg_modify_response(mInvSession->dlg, mTData, 400, NULL);
+            pjsip_dlg_send_response(mInvSession->dlg, mTsx, mTData);
             return;
         }
         catch (const std::exception &e)
         {
             lg(Debug) << "ConnectBridgedSessionsWithDestination sending 400 due to exception:  " << e.what();
-            pjsip_dlg_respond(mInvSession->dlg, mRData, 400, NULL, NULL, NULL);
+            pjsip_dlg_modify_response(mInvSession->dlg, mTData, 400, NULL);
+            pjsip_dlg_send_response(mInvSession->dlg, mTsx, mTData);
             return;
         }
-        pjsip_dlg_respond(mInvSession->dlg, mRData, 200, NULL, NULL, NULL);
+        pjsip_dlg_send_response(mInvSession->dlg, mTsx, mTData);
         
         Ice::Current current;
         lg(Debug) << "ConnectBridgedSessionsWithDestination calling session->stop(). ";
@@ -150,7 +154,8 @@ public:
     }
 private:
     pjsip_inv_session *mInvSession;
-    pjsip_rx_data *mRData;
+    pjsip_tx_data *mTData;
+    pjsip_transaction *mTsx;
     SipSessionPtr mSession;
     std::string mTarget;
 };
@@ -731,7 +736,10 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
 
         try
         {
-            ConnectBridgedSessionsCallbackPtr cb(new ConnectBridgedSessionsCallback(inv, rdata, session));
+            pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
+            pjsip_tx_data *tdata;
+            pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata);
+            ConnectBridgedSessionsCallbackPtr cb(new ConnectBridgedSessionsCallback(inv, tdata, tsx, session));
             Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessions(). ";
@@ -755,8 +763,11 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
         {
             PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[mModule.id];
             SipSessionPtr session = session_mod_info->getSessionPtr();
+            pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
+            pjsip_tx_data *tdata;
+            pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata);
             ConnectBridgedSessionsWithDestinationCallbackPtr cb(
-                new ConnectBridgedSessionsWithDestinationCallback(inv, rdata, session, target));
+                new ConnectBridgedSessionsWithDestinationCallback(inv, tdata, tsx, session, target));
             Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsWithDestinationCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessionsWithDestination(). ";

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list