[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "transfer" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 12 08:03:04 CDT 2010


branch "transfer" has been updated
       via  66de9f491d83a52480a5e723e4d226494af14451 (commit)
      from  5698574a7baaaecd4c3c64dcb3c0ca31b4b69272 (commit)

Summary of changes:
 slice              |    2 +-
 src/BridgeImpl.cpp |   73 +++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 59 insertions(+), 16 deletions(-)


- Log -----------------------------------------------------------------
commit 66de9f491d83a52480a5e723e4d226494af14451
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Oct 12 10:30:47 2010 -0230

    Enable transfer support.

diff --git a/slice b/slice
index dd9f77f..7e63131 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit dd9f77f76241bdb6b7800b84722444421cddaf85
+Subproject commit 7e63131ea251461c0f4a4d751841601b107452bd
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index dcf253c..4302799 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -16,6 +16,17 @@
 
 using namespace AsteriskSCF::System::Logging;
 
+/** 
+ *
+ * NOTE: Code must be reviewed/refactored for exception safety/consistency.
+ * Operations involving establishing media connections may or may not be
+ * catastrophic. An example of a non-catastrophic situation might be a media
+ * allocation operation that might immediately fail for transient reasons but
+ * can be initialized in the background in a relatively timely fashion (of
+ * course this would depend on the context). 
+ *
+ */ 
+
 namespace
 {
 Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
@@ -437,34 +448,66 @@ void AsteriskSCF::BridgeService::BridgeImpl::removeListener(const AsteriskSCF::S
 void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& newSession, 
   const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession, const Ice::Current&)
 {
+    //
+    // TODO:Need to find a way to make this as exception safe as possible!
+    //
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     statePreCheck();
     std::vector<BridgeSession>::iterator i = find_if(mSessions.begin(), mSessions.end(), AsteriskSCF::BridgeService::FindImpl(oldSession));
+    //
+    // If it's found, disconnect the media and remove association between bridge and session.
+    //
     if(i != mSessions.end())
     {
-#if 0
-        i->session->removeBridge(mPrx, mSessionListenerPrx);
         i->connector->unplug();
-        AsteriskSCF::SessionCommunications::V1::SessionInfoPtr info = newSession->addBridge(mPrx, mSessionListenerPrx);
-        i->session = newSession;
-        if(info->currentState == "ready")
+        try
         {
-            i->connector = 0;
+            i->session->removeBridge(mSessionListenerPrx);
         }
-        else
+        catch(const AsteriskSCF::SessionCommunications::V1::NotBridged&)
         {
-            i->connector = mSplicer.connect(newSession);
+            //
+            // Log but do not stop. It may be a race condition.
+            //
         }
-        AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
-        sessions.push_back(newSessions);
-        mListeners->sessionsAdded(sessions);
+    }
+   
+
+    AsteriskSCF::SessionCommunications::V1::SessionInfoPtr info = newSession->setBridge(mPrx, mSessionListenerPrx);
+
+    //
+    // TODO: if setBridge() fails, should the old session/bridge association remain? 
+    //
+
+    //
+    // If the old session wasn't found then we need to add a new one. If we simply insert the new one at the
+    // end and update the iterator "i", we minimize the special case code.
+    //
+    if(i == mSession.end())
+    {
+        BridgeSession t;
+        i = mSessions.insert(i, t);
+    }
+
+    i->session = newSession;
+    if(info->currentState == "ready")
+    {
+        i->connector = 0;
+    }
+    else
+    {
+        i->connector = mSplicer.connect(newSession);
+    }
+
+    AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+    sessions.push_back(newSession);
+    mListeners->sessionsAdded(sessions);
+
+    if(i != mSessions.end())
+    {
         sessions.clear();
         sessions.push_back(oldSession);
         mListeners->sessionsRemoved(sessions);
-#endif
-        //
-        // TODO:Need to find a way to make this as exception safe as possible!
-        //
     }
 }
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list