[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 19 06:05:17 CDT 2010


branch "master" has been updated
       via  c8b6b79fbdccbbbbb6e1315d2d52842af12f65e6 (commit)
      from  fc5dec3e7064a11b236c85779f00a25689f47ecb (commit)

Summary of changes:
 src/EndpointRegistry.cpp             |    5 ++-
 src/RoutingServiceEventPublisher.cpp |   54 ++++++++++++++++++++++++++++++----
 src/SessionRouter.cpp                |   28 ++++++++++++++----
 test/TestRouting.cpp                 |   19 ++++++++++++
 4 files changed, 92 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit c8b6b79fbdccbbbbb6e1315d2d52842af12f65e6
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Oct 19 05:35:32 2010 -0500

    Added additional try/catch guards.

diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index 0af39ab..97842d8 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -57,8 +57,9 @@ public:
 /**
  * Provides the private implementation of the EndpointRegistry. 
  */
-struct EndpointRegistryPriv
+class EndpointRegistryPriv
 {
+public:
     EndpointRegistryPriv(ScriptProcessor* scriptProcessor, const RoutingEventsPtr& eventPublisher) : 
         mScriptProcessor(scriptProcessor), mEventPublisher(eventPublisher) 
     {
@@ -212,7 +213,7 @@ AsteriskSCF::Core::Endpoint::V1::EndpointSeq EndpointRegistry::lookup(const std:
                 }
                 catch (const IceUtil::Exception& e)
                 {
-                    lg(Error) << "Exception calling registered EndpointLocator: " << e.what();
+                    lg(Error) << "Exception calling registered EndpointLocator for " << entry->first << " Details: " << e.what();
                 }
                 break;
             }
diff --git a/src/RoutingServiceEventPublisher.cpp b/src/RoutingServiceEventPublisher.cpp
index 0830e03..334d316 100644
--- a/src/RoutingServiceEventPublisher.cpp
+++ b/src/RoutingServiceEventPublisher.cpp
@@ -134,7 +134,14 @@ void RoutingServiceEventPublisher::lookupEvent(const std::string& destination,
         return;
     }
 
-    mImpl->mEventTopic->lookupEvent(destination, result);
+    try
+    {
+        mImpl->mEventTopic->lookupEvent(destination, result);
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 
@@ -150,7 +157,14 @@ void RoutingServiceEventPublisher::addEndpointLocatorEvent(const std::string& lo
         return;
     }
 
-    mImpl->mEventTopic->addEndpointLocatorEvent(locatorId, regexList, result);
+    try
+    {
+        mImpl->mEventTopic->addEndpointLocatorEvent(locatorId, regexList, result);
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 /**
@@ -164,7 +178,14 @@ void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const std::string&
         return;
     }
 
-    mImpl->mEventTopic->removeEndpointLocatorEvent(locatorId, result);
+    try
+    {
+        mImpl->mEventTopic->removeEndpointLocatorEvent(locatorId, result);
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 /**
@@ -179,7 +200,14 @@ void RoutingServiceEventPublisher::setEndpointLocatorDestinationIdsEvent(const s
         return;
     }
 
-    mImpl->mEventTopic->setEndpointLocatorDestinationIdsEvent(locatorId, regexList, result);
+    try
+    {
+        mImpl->mEventTopic->setEndpointLocatorDestinationIdsEvent(locatorId, regexList, result);
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 /**
@@ -192,7 +220,14 @@ void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const Ice::Current
         return;
     }
 
-    mImpl->mEventTopic->clearEndpointLocatorsEvent();
+    try
+    {
+        mImpl->mEventTopic->clearEndpointLocatorsEvent();
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 /**
@@ -205,7 +240,14 @@ void RoutingServiceEventPublisher::setPolicyEvent(const std::string& policy, con
         return;
     }
 
-    mImpl->mEventTopic->setPolicyEvent(policy);
+    try
+    {
+        mImpl->mEventTopic->setPolicyEvent(policy);
+    }
+    catch(const Ice::Exception &e)
+    {
+        lg(Error) << e.what();
+    }
 }
 
 } // end BasicRoutingService
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index ae344ba..0bb619d 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -88,11 +88,19 @@ public:
         // Forward the stop message to all sessions other than the one that originally sent it.
         for(SessionSeq::iterator s = mSessions.begin(); s != mSessions.end(); ++s)
         {
-            if (session->ice_getIdentity() != (*s)->ice_getIdentity())
+            try
+            {
+                if (session->ice_getIdentity() != (*s)->ice_getIdentity())
+                {
+                    (*s)->stop(responseCode);
+                }
+            }
+            catch(const Ice::Exception &e)
             {
-                (*s)->stop(responseCode);
+                lg(Error) << "Session Listener unable to forward stop to session " << (*s) << " due to " << e.what() << std::endl;
             }
         }
+
     }
 
     void unheld(const SessionPrx& session, const Ice::Current&)
@@ -123,8 +131,9 @@ public:
                 lg(Debug) << "Adding listener to session." ;
                 session->addListener(mListenerPrx);
             }
-            catch(...)
+            catch(const Ice::Exception &e)
             {
+                lg(Error) << "Exception adding listener to session " << session << ". Details: " << e.what() << std::endl;
             }
         }
     }
@@ -145,8 +154,15 @@ public:
     {
         for(SessionSeq::iterator s=mSessions.begin(); s != mSessions.end(); ++s)
         {
-            lg(Debug) << "Removing listener from session." ;
-            (*s)->removeListener(mListenerPrx);
+            try
+            {
+                lg(Debug) << "Removing listener from session " << (*s) << std::endl ;
+                (*s)->removeListener(mListenerPrx);
+            }
+            catch(const Ice::Exception &e)
+            {
+                lg(Error) << "Exception removing listener from session " << (*s) << ". Details: " << e.what() << std::endl;
+            }
         }
 
         // Since we're through listening to them, we should just drop our references to them.
@@ -279,7 +295,7 @@ public:
             }
             catch (const Ice::Exception &e)
             {
-                lg(Error) << "Unable to forward the start() operation to Session. " << e.what();
+                lg(Error) << "Unable to forward the start() operation to session " << (*s) << " Details: " << e.what() << std::endl;
                 // TBD... probably other bridge cleanup needs to be done.
                 throw;
             }
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 8546272..fc58180 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -405,6 +405,25 @@ BOOST_FIXTURE_TEST_CASE(RouteSession, PerTestFixture)
         SharedTestData::instance.sessionRouter->routeSession(session, "102");
  
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
+
+        BridgePrx bridge = session->getBridge();
+        BOOST_CHECK(bridge != 0);
+
+        SessionSeq sessions = bridge->listSessions();
+        BOOST_CHECK(sessions.size() == 2);
+        
+        for(SessionSeq::iterator s = sessions.begin(); s != sessions.end(); ++s)
+        {
+            SessionInfoPtr sessionInfo = (*s)->getInfo();
+
+            // For testing we put the leg id in the role field. 
+            BOOST_CHECK(sessionInfo->role == "101" || sessionInfo->role == "102");
+
+            // For testing, we put the number of listeners in the connectedTime field.
+            // Only the bridge should still be listening.
+            BOOST_CHECK(sessionInfo->connectedTime == 1);
+        }
+
     }
     catch(const IceUtil::Exception &ie)
     {

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list