[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
Sun Oct 17 20:48:36 CDT 2010
branch "master" has been updated
via 3987f8eb28c21e48dc72c423ac31c48c18e66eb7 (commit)
from f11625f623f1f1b2cbdf817f59a2ae14fc01a333 (commit)
Summary of changes:
src/SessionRouter.cpp | 80 +++++++++++++++++++++++++++++++++----------------
test/MockSession.cpp | 8 +++--
2 files changed, 59 insertions(+), 29 deletions(-)
- Log -----------------------------------------------------------------
commit 3987f8eb28c21e48dc72c423ac31c48c18e66eb7
Author: Ken Hunt <ken.hunt at digium.com>
Date: Sun Oct 17 20:46:57 2010 -0500
Removed a case of adding our listener redundantly to a session. Added
additional debug logging output.
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index 16601ef..ae344ba 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -42,7 +42,7 @@ public:
Ice::ObjectPrx prx = adapter->addWithUUID(this);
mListenerPrx = SessionListenerPrx::checkedCast(prx);
- addSession(session);
+ addSessionAndListen(session);
}
SessionListenerImpl(Ice::ObjectAdapterPtr adapter, SessionSeq& sessionSequence) :
@@ -53,7 +53,7 @@ public:
for(SessionSeq::iterator s = sessionSequence.begin(); s != sessionSequence.end(); ++s)
{
- addSession(*s);
+ addSessionAndListen(*s);
}
}
@@ -99,14 +99,28 @@ public:
{
}
+ /**
+ * Adds a session to be tracked by the listener. This operation doesn't actually call addListener on the Session.
+ * When we ask an endpoint to create a session, we pass our listener in to the creation process.
+ * So the listener has been attached to the session, but we just need to keep track of it in this object.
+ */
void addSession(SessionPrx session)
{
mSessions.push_back(session);
+ }
+
+ /**
+ * Add a session to be tracked by this listener, and attach this listener to the session.
+ */
+ void addSessionAndListen(SessionPrx session)
+ {
+ mSessions.push_back(session);
if (mListenerPrx != 0)
{
try
{
+ lg(Debug) << "Adding listener to session." ;
session->addListener(mListenerPrx);
}
catch(...)
@@ -114,7 +128,6 @@ public:
}
}
}
-
const SessionSeq& getSessions()
{
return mSessions;
@@ -132,6 +145,7 @@ public:
{
for(SessionSeq::iterator s=mSessions.begin(); s != mSessions.end(); ++s)
{
+ lg(Debug) << "Removing listener from session." ;
(*s)->removeListener(mListenerPrx);
}
@@ -189,6 +203,7 @@ public:
{
// Only the adapter holds a smart pointer for this servant, so this will
// cause it to be delted.
+ lg(Debug) << "Removing listener from object adapter." ;
mAdapter->remove(mSessionListener->getProxy()->ice_getIdentity());
}
catch(...)
@@ -307,6 +322,7 @@ void SessionRouter::routeSession(const AsteriskSCF::SessionCommunications::V1::S
SessionListenerAllocator listener(mImpl->mAdapter, source);
// Route the destination
+ lg(Debug) << "routeSession(): Routing destination " << destination;
EndpointSeq endpoints = mImpl->lookupEndpoints(destination, current);
// Add a session
@@ -318,6 +334,7 @@ void SessionRouter::routeSession(const AsteriskSCF::SessionCommunications::V1::S
SessionEndpointPrx sessionEndpoint = SessionEndpointPrx::checkedCast(*e);
// Create a session on the destination.
+ lg(Debug) << "routeSession(): Creating a session at destination " << destination;
SessionPrx destSession = sessionEndpoint->createSession(destination, listener->getProxy());
listener->addSession(destSession);
newSessions.push_back(destSession);
@@ -352,6 +369,7 @@ void SessionRouter::routeSession(const AsteriskSCF::SessionCommunications::V1::S
bridgedSessions.reserve(bridgedSessions.size() + newSessions.size());
bridgedSessions.insert(bridgedSessions.end(), newSessions.begin(), newSessions.end());
+ lg(Debug) << "routeSession(): Creating bridge.";
bridge = mImpl->mBridgeManagerAccessor->getBridgeManager()->createBridge(bridgedSessions, 0);
}
catch (const Ice::Exception &)
@@ -363,6 +381,7 @@ void SessionRouter::routeSession(const AsteriskSCF::SessionCommunications::V1::S
// Forward the start to all the destinations routed to.
+ lg(Debug) << "routeSession(): Sending start() to newly routed destination.";
mImpl->forwardStart(newSessions);
} // SessionRouter::routeSession(...)
@@ -410,9 +429,11 @@ void SessionRouter::connectBridgedSessionsWithDestination(const SessionPrx& sess
// Create a listener for the sessions not being replaced to handle early termination.
// The wrapper we're using will remove the listener and free it when
// this method is left.
+ lg(Debug) << "connectBridgedSessionsWithDestination(): Attaching listener";
SessionListenerAllocator listener(mImpl->mAdapter, remainingSessions);
// Route the destination
+ lg(Debug) << "connectBridgedSessionsWithDestination(): Routing destination " << destination;
EndpointSeq endpoints = mImpl->lookupEndpoints(destination, current);
// Add a session
@@ -427,40 +448,44 @@ void SessionRouter::connectBridgedSessionsWithDestination(const SessionPrx& sess
SessionPrx destSession = sessionEndpoint->createSession(destination, listener->getProxy());
listener->addSession(destSession);
newSessions.push_back(destSession);
+
+ lg(Debug) << "connectBridgedSessionsWithDestination(): Created session for routed destination " << destination;
}
catch(const Ice::Exception &exception)
{
- lg(Error) << "Unable to create sessionEndpoint for " << destination << ". " << exception.what();
+ lg(Error) << "connectBridgedSessionsWithDestination(): Unable to create sessionEndpoint for " << destination << ". " << exception.what();
// We may be able to reach SOME of the endpoints.
}
}
if (listener->getSessions().size() < 2)
{
- lg(Error) << "Unable to create a new session for destination " << destination << " in connectBridgedSessionsWithDestination(). " ;
+ lg(Error) << "connectBridgedSessionsWithDestination(): Unable to create a new session for destination " << destination << " in connectBridgedSessionsWithDestination(). " ;
throw SessionCreationException(destination);
}
if (listener->isTerminated())
{
- lg(Notice) << "Source ended session before transfer in connectBridgedSessionsWithDestination(). " ;
+ lg(Notice) << "connectBridgedSessionsWithDestination(): Source ended session before transfer in connectBridgedSessionsWithDestination(). " ;
throw SourceTerminatedPreBridgingException(remainingSessions[0]->getEndpoint()->getId());
}
- // We're through listeninga, and we will probably interfere with the Bridge's functionality if
+ // We're through listening, and we will probably interfere with the Bridge's functionality if
// we keep listening.
listener->unregister();
// Modify the bridge
try
{
+ lg(Debug) << "connectBridgedSessionsWithDestination(): Replacing session with newly routed destination " << destination;
bridge->replaceSession(sessionToReplace, newSessions);
}
catch (const Ice::Exception &e)
{
- lg(Error) << "Exception replacing the session in connectBridgedSessionsWithDestination. " << e.what() ;
+ lg(Error) << "connectBridgedSessionsWithDestination(): Exception replacing the session in connectBridgedSessionsWithDestination. " << e.what() ;
throw BridgingException(remainingSessions[0]->getEndpoint()->getId(), destination);
}
+ lg(Debug) << "connectBridgedSessionsWithDestination(): Forwarding start() to new session.";
mImpl->forwardStart(newSessions);
} // SessionRouter::connectBridgedSessionsWithDestination(...)
@@ -491,8 +516,8 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
}
catch(const NotBridged& e)
{
- lg(Error) << "Unable to obtain bridge from sessionToReplace in connectBridgedSessions(). " ;
- throw e; // rethrow
+ lg(Error) << "connectBridgedSessions(): Unable to obtain bridge from sessionToReplace in connectBridgedSessions(). " ;
+ throw e; // rethrow
}
SessionSeq preserveSessions;
@@ -509,7 +534,7 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
}
catch(const Ice::Exception &e)
{
- lg(Error) << "Unable to get list of sesssions for bridge in connectBridgedSessions(). " ;
+ lg(Error) << "connectBridgedSessions(): Unable to get list of sesssions for bridge in connectBridgedSessions(). " ;
throw e; // rethrow
}
@@ -517,6 +542,7 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
// Create a listener for the sessions not being replaced to handle early termination.
// The wrapper we're using will remove the listener and free it when
// this method is left.
+ lg(Debug) << "connectBridgedSessions(): Adding listener to " << preserveSessions.size() << " session(s)." ;
SessionListenerAllocator listener(mImpl->mAdapter, preserveSessions);
// Get the bridge for the sessions being moved.
@@ -527,19 +553,9 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
}
catch(const NotBridged&)
{
- lg(Warning) << "Unable to get bridge for the bridgedSession in connectBridgedSessions(). " ;
+ lg(Warning) << "connectBridgedSessions(): Unable to get bridge for the bridgedSession in connectBridgedSessions(). " ;
}
- // Check for early termination by the source.
- if (listener->isTerminated())
- {
- lg(Notice) << "Source ended session before transfer in connectBridgedSessions(). " ;
- throw SourceTerminatedPreBridgingException(preserveSessions[0]->getEndpoint()->getId());
- }
- // We're through listening, and we will probably interfere with the Bridge's functionality if
- // we keep listening.
- listener->unregister();
-
SessionSeq migratingSessions;
if (oldBridge != 0)
{
@@ -554,25 +570,37 @@ void SessionRouter::connectBridgedSessions(const SessionPrx& sessionToReplace,
migratingSessions.push_back(*s);
}
}
+
+ lg(Debug) << "connectBridgedSessions(): Removing migrating sessions from bridge." ;
oldBridge->removeSessions(migratingSessions);
}
catch(const Ice::Exception&)
{
- lg(Warning) << "Unable to remove sessions in connectBridgedSessions(). " ;
+ lg(Warning) << "connectBridgedSessions(): Unable to remove sessions in connectBridgedSessions(). " ;
// We won't give up because of this.
}
}
+ // Check for early termination by the source.
+ if (listener->isTerminated())
+ {
+ lg(Notice) << "connectBridgedSessions(): Source ended session before transfer in connectBridgedSessions(). " ;
+ throw SourceTerminatedPreBridgingException(preserveSessions[0]->getEndpoint()->getId());
+ }
+ // We're through listening, and we will probably interfere with the Bridge's functionality if
+ // we keep listening.
+ lg(Debug) << "connectBridgedSessions(): Removing listener. " ;
+ listener->unregister();
+
// Now replace the sessions.
- // TBD... make order of newSession and sessionToBeReplaced consistent
- // between bridge and this operation.
try
{
+ lg(Debug) << "connectBridgedSessions(): Asking bridge to replace sessions." ;
mergeBridge->replaceSession(sessionToReplace, migratingSessions);
}
catch(const Ice::Exception& e)
{
- lg(Error) << "Unable to replace session for bridge in connectBridgedSessions(). " ;
+ lg(Error) << "connectBridgedSessions(): Unable to replace session for bridge in connectBridgedSessions(). " ;
throw e; // rethrow
}
diff --git a/test/MockSession.cpp b/test/MockSession.cpp
index 822aa00..fc7df4c 100644
--- a/test/MockSession.cpp
+++ b/test/MockSession.cpp
@@ -159,21 +159,23 @@ BridgePrx MockSession::getBridge(const Ice::Current &)
SessionInfoPtr MockSession::setBridge(const BridgePrx& bridge,
const SessionListenerPrx& listener,
- const Ice::Current &)
+ const Ice::Current ¤t)
{
mBridgePrx = bridge;
mBridgeSet = true;
- mListeners.push_back(listener);
+ addListener(listener, current);
return mSessionInfo;
}
void MockSession::removeBridge(const SessionListenerPrx& listener,
- const Ice::Current &)
+ const Ice::Current ¤t)
{
mBridgePrx = 0;
mBridgeSet = false;
+
+ removeListener(listener, current);
}
}; // RoutingTest
-----------------------------------------------------------------------
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list