[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
Wed Oct 13 11:29:41 CDT 2010


branch "transfer" has been updated
       via  b5d1c9aa263ce7b70b6d2a7bfc97257c833faf59 (commit)
      from  7f8142c68520f3bb0786f7faec38f0c017a7eae7 (commit)

Summary of changes:
 src/BridgeImpl.cpp |  183 ++++++++++++++++++++++++++++++++++++++++++++++------
 src/BridgeImpl.h   |   11 +++-
 2 files changed, 174 insertions(+), 20 deletions(-)


- Log -----------------------------------------------------------------
commit b5d1c9aa263ce7b70b6d2a7bfc97257c833faf59
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Oct 13 13:58:04 2010 -0230

    Bridge catches object not exist and groundwork has been added to have the bridge remove sessions that have had
    operations called that result in object not exist.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 033a501..6495f29 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -79,13 +79,29 @@ namespace BridgeService
 
         void operator()(const BridgeImpl::BridgeSessionPtr& b) 
         {
-            b->getSession()->removeBridge(mListener);
-            b->getSession()->stop(mResponse);
-            b->disconnect();
+            try
+            {
+                b->getSession()->removeBridge(mListener);
+                b->getSession()->stop(mResponse);
+                b->disconnect();
+            }
+            catch(const Ice::ObjectNotExistException&)
+            {
+                mNonExistent.push_back(b);
+            }
+            catch(const Ice::Exception&)
+            {
+            }
+        }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
         }
     private:
         AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListener;
         AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
     
     class ProgressingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
@@ -98,10 +114,27 @@ namespace BridgeService
 
         void operator()(const BridgeImpl::BridgeSessionPtr& b) 
         {
-            b->getSession()->progress(mResponse);
+            try
+            {
+                b->getSession()->progress(mResponse);
+            }
+            catch(const Ice::ObjectNotExistException&)
+            {
+                mNonExistent.push_back(b);
+            }
+            catch(const Ice::Exception&)
+            {
+            }
+        }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
         }
+
     private:
         AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
 
     class RingImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
@@ -116,35 +149,106 @@ namespace BridgeService
         {
             if(b->getSession() != mExclude)
             {
-                b->getSession()->ring();
+                try
+                {
+                    b->getSession()->ring();
+                }
+                catch(const Ice::ObjectNotExistException&)
+                {
+                    mNonExistent.push_back(b);
+                }
+                catch(const Ice::Exception&)
+                {
+                }
             }
         }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
+        }
+
     private:
         AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
 
-    struct FlashImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+    class FlashImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
     {
+    public:
         void operator()(const BridgeImpl::BridgeSessionPtr& b) 
         {
-            b->getSession()->flash();
+            try
+            {
+                b->getSession()->flash();
+            }
+            catch(const Ice::ObjectNotExistException&)
+            {
+                mNonExistent.push_back(b);
+            }
+            catch(const Ice::Exception&)
+            {
+            }
         }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
+        }
+    private:
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
     
-    struct HoldImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+    class HoldImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
     {
+    public:
         void operator()(const BridgeImpl::BridgeSessionPtr& b) 
         {
-            b->getSession()->hold();
+            try
+            {
+                b->getSession()->hold();
+            }
+            catch(const Ice::ObjectNotExistException&)
+            {
+                mNonExistent.push_back(b);
+            }
+            catch(const Ice::Exception&)
+            {
+            }
         }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
+        }
+    private:
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
     
-    struct UnholdImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
+    class UnholdImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
     {
+    public:
         void operator()(const BridgeImpl::BridgeSessionPtr& b) 
         {
-            b->getSession()->unhold();
+            try
+            {
+                b->getSession()->unhold();
+            }
+            catch(const Ice::ObjectNotExistException&)
+            {
+                mNonExistent.push_back(b);
+            }
+            catch(const Ice::Exception&)
+            {
+            }
+        }
+
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
         }
+    private:
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
 
     class ConnectImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, void>
@@ -159,12 +263,28 @@ namespace BridgeService
         {
             if(b->getSession() != mExclude) 
             {
-                b->connect();
+                try
+                {
+                    b->connect();
+                }
+                catch(const Ice::ObjectNotExistException&)
+                {
+                    mNonExistent.push_back(b);
+                }
+                catch(const Ice::Exception&)
+                {
+                }
             }
         }
 
+        const std::vector<BridgeImpl::BridgeSessionPtr>& nonExistentObjects()
+        {
+            return mNonExistent;
+        }
+
     private:
         AsteriskSCF::SessionCommunications::V1::SessionPrx mExclude;
+        std::vector<BridgeImpl::BridgeSessionPtr> mNonExistent;
     };
 
     class FindImpl : public std::unary_function<BridgeImpl::BridgeSessionPtr, bool>
@@ -347,7 +467,14 @@ void AsteriskSCF::BridgeService::BridgeImpl::removeSessions(const AsteriskSCF::S
             std::vector<BridgeSessionPtr>::iterator j = std::find_if(mSessions.begin(), mSessions.end(), AsteriskSCF::BridgeService::FindImpl(*i));
             if(j != mSessions.end())
             {
-                (*j)->getSession()->removeBridge(mSessionListenerPrx);
+                try
+                {
+                    (*j)->getSession()->removeBridge(mSessionListenerPrx);
+                }
+                catch(const Ice::Exception& ex)
+                {
+                    lg(Info) << __FUNCTION__ << ": removingthe bridge from " << (*j)->getSession() << " threw " << ex.what(); 
+                }
                 (*j)->disconnect();
                 mSessions.erase(j);
                 removedSessions.push_back(*i);
@@ -476,7 +603,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
             infoSeq.push_back((*i)->setBridge(mPrx, mSessionListenerPrx));
             newMembers.push_back(new BridgeSession(*i, 0, false));
         }
-        catch(const Ice::Exception&)
+        catch(const Ice::Exception& ex)
         {
             //
             // We need to continue if setBridge fails for some reason. Rolling
@@ -485,6 +612,7 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
             // really be required if things like replaceSessions() were to be
             // atomic.
             //
+            lg(Info) << __FUNCTION__ << ": setting the bridge on " << *i << " threw " << ex.what(); 
         }
     }
     assert(infoSeq.size() == newMembers.size());
@@ -499,9 +627,24 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
         {
             mSessions.push_back(*i);
             assert(currentInfo != infoSeq.end());
-            if((*currentInfo)->currentState != "ready")
+            try
             {
-                (*i)->setConnector(mSplicer.connect((*i)->getSession()));
+                if((*currentInfo)->currentState != "ready")
+                {
+                    (*i)->setConnector(mSplicer.connect((*i)->getSession()));
+                }
+            }
+            catch(const Ice::Exception& ex)
+            {
+                //
+                // This should be logged and addressed, but otherwise ignored.
+                // As far as the session is concerned, it is now part of the
+                // bridge so this operation should continue. The proper remedy
+                // would be along the lines of retrying the media session
+                // establishment or getting a fair guarantee that it would
+                // succeed beforehand.
+                //
+                lg(Info) << __FUNCTION__ << ": connecting media for " << (*i)->getSession() << " threw " << ex.what(); 
             }
         }
     }
@@ -518,9 +661,11 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
         }
         catch(const AsteriskSCF::SessionCommunications::V1::NotBridged&)
         {
-            //
-            // Log but do not stop. It may be a race condition.
-            //
+            lg(Info) << __FUNCTION__ << ": removeBridge on session being replaced threw a `NotBridged' exception"; 
+        }
+        catch(const Ice::Exception& ex)
+        {
+            lg(Info) << __FUNCTION__ << ": removeBridge resulted in : " <<  ex.what();
         }
     }
 
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 76aae01..bc61969 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -72,7 +72,16 @@ namespace BridgeService
                 IceUtil::Mutex::Lock lock(mMutex);
                 if(mConnector)
                 {
-                    mConnector->unplug();
+                    try
+                    {
+                        mConnector->unplug();
+                    }
+                    catch(const Ice::Exception&)
+                    {
+                        //
+                        // There are several valid reasons why this might occur, so we'll ignore it and move on.
+                        //
+                    }
                 }
             }
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list