[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
Fri Oct 22 12:40:25 CDT 2010
branch "master" has been updated
via 9a49f7348d2092473fcbea2d5690159d21de0321 (commit)
from ac2d3f6a4edf0547b8e5a4189a0eb48558cd7c7d (commit)
Summary of changes:
src/SessionRouter.cpp | 120 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 99 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit 9a49f7348d2092473fcbea2d5690159d21de0321
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Oct 22 12:38:33 2010 -0500
Added retries to attempts access bridge for a session.
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index 4af366e..fc3a8a6 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -161,6 +161,8 @@ public:
sessionsToCall = mSessions;
}
+ lg(Debug) << "unregister() called with " << sessionsToCall.size() << " sessions to remove listener from." << std::endl ;
+
for(SessionSeq::iterator s=sessionsToCall.begin(); s != sessionsToCall.end(); ++s)
{
try
@@ -241,10 +243,13 @@ public:
// in proper order.
try
{
+ lg(Debug) << "About to unregister the listener..." << std::endl ;
+
mSessionListener->unregister();
}
- catch(...)
+ catch(const std::exception& e)
{
+ lg(Debug) << "Exception unregistering: " << e.what() << std::endl ;
}
try
@@ -254,8 +259,9 @@ public:
lg(Debug) << "Removing listener from object adapter." ;
mAdapter->remove(mSessionListener->getProxy()->ice_getIdentity());
}
- catch(...)
+ catch(const std::exception& e)
{
+ lg(Debug) << "Exception removing listener from Object Adatper " << e.what() << std::endl ;
}
}
@@ -448,13 +454,38 @@ void SessionRouter::connectBridgedSessionsWithDestination(const SessionPrx& sess
const Ice::Current& current)
{
BridgePrx bridge(0);
- try
- {
- bridge = sessionToReplace->getBridge();
- }
- catch(const NotBridged& e)
+
+ size_t count = 0;
+ bool done = false;
+ size_t sleepInterval = 500; // XXX Make configurable.
+ size_t numberOfRetries = 5;
+ while(!done && count < numberOfRetries)
{
- throw e; // rethrow
+ try
+ {
+ bridge = sessionToReplace->getBridge();
+ done = true;
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepInterval));
+ ++count;
+ if(count >= numberOfRetries)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): ConnectionLostException getting bridge, failed " << numberOfRetries << " retries." << std::endl;
+ throw;
+ }
+ }
+ catch(const NotBridged& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): sessionToReplace() is not bridged." << std::endl;
+ throw e; // rethrow
+ }
+ catch(const Ice::Exception& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): Ice exception getting bridge:" << e.what() << std::endl;
+ throw e; // rethrow
+ }
}
SessionSeq seq;
@@ -561,14 +592,38 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
// Get the bridge being merged into.
BridgePrx mergeBridge(0);
- try
- {
- mergeBridge = sessionToReplace->getBridge();
- }
- catch(const NotBridged& e)
+
+ size_t count = 0;
+ bool done = false;
+ size_t sleepInterval = 500; // XXX Make configurable.
+ size_t numberOfRetries = 5;
+ while(!done && count < numberOfRetries)
{
- lg(Error) << "connectBridgedSessions(): Unable to obtain bridge from sessionToReplace " << sessionToReplace->ice_toString() << " in connectBridgedSessions(). " ;
- throw e; // rethrow
+ try
+ {
+ mergeBridge = sessionToReplace->getBridge();
+ done = true;
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepInterval));
+ ++count;
+ if(count >= numberOfRetries)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): ConnectionLostException getting bridge for sessionToReplace, failed " << numberOfRetries << " retries." << std::endl;
+ throw;
+ }
+ }
+ catch(const NotBridged& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): sessionToReplace() is not bridged." << std::endl;
+ throw e; // rethrow
+ }
+ catch(const Ice::Exception& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): Ice exception getting bridge for sessionToReplace:" << e.what() << std::endl;
+ throw e; // rethrow
+ }
}
SessionSeq preserveSessions;
@@ -597,14 +652,37 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
SessionListenerAllocator listener(mImpl->mAdapter, preserveSessions);
// Get the bridge for the sessions being moved.
+
BridgePrx oldBridge(0);
- try
- {
- oldBridge = bridgedSession->getBridge();
- }
- catch(const NotBridged&)
+ count = 0;
+ done = false;
+ while(!done && count < numberOfRetries)
{
- lg(Warning) << "connectBridgedSessions(): Unable to get bridge for the bridgedSession in connectBridgedSessions(). " ;
+ try
+ {
+ oldBridge = bridgedSession->getBridge();
+ done = true;
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepInterval));
+ ++count;
+ if(count >= numberOfRetries)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): ConnectionLostException getting bridge for bridgedSession, failed " << numberOfRetries << " retries." << std::endl;
+ throw;
+ }
+ }
+ catch(const NotBridged& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): bridgedSession() is not bridged." << std::endl;
+ throw e; // rethrow
+ }
+ catch(const Ice::Exception& e)
+ {
+ lg(Error) << "connectBridgedSessionsWithDestination(): Ice exception getting bridge for bridgedSession:" << e.what() << std::endl;
+ throw e; // rethrow
+ }
}
SessionSeq migratingSessions;
-----------------------------------------------------------------------
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list