[asterisk-scf-commits] asterisk-scf/release/bridging.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Jun 22 09:29:33 CDT 2012
branch "master" has been updated
via 9075e0355ec2f660b4764127f5cf67762bb94634 (commit)
from 856621e33c3aa7d12db76324a83e42be6628c0d9 (commit)
Summary of changes:
src/BridgeImpl.cpp | 18 +++++++++++-
src/SessionListener.cpp | 31 ++++++++++++++++++----
src/SessionOperations.cpp | 6 +++-
src/SessionOperations.h | 3 ++
src/SessionWrapper.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++-
src/SessionWrapper.h | 1 +
6 files changed, 110 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit 9075e0355ec2f660b4764127f5cf67762bb94634
Author: Brent Eagles <beagles at digium.com>
Date: Fri Jun 22 11:57:45 2012 -0230
Added an operation to session shutdown to remove any session controller
servants from the OA's AOM for bridged sessions. This resolves a per-session
memory servant for each session added to a bridge.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 83e0015..fd8624e 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -1927,7 +1927,7 @@ void BridgeImpl::shutdown(const AsteriskSCF::System::V1::OperationContextPtr& op
// value so we shouldn't need to set anything here.
//
ResponseCodePtr responseCode = new ResponseCode;
- ShutdownSessionOperation shutdownOp(operationContext, mSessionListenerPrx, responseCode, mLogger);
+ ShutdownSessionOperation shutdownOp(operationContext, mObjAdapter, mSessionListenerPrx, responseCode, mLogger);
mSessions->visitSessions(shutdownOp);
boost::unique_lock<boost::shared_mutex> lock(mLock);
mListeners->stopped(getCookies());
@@ -1960,6 +1960,13 @@ void BridgeImpl::shutdown(const AsteriskSCF::System::V1::OperationContextPtr& op
}
mSessions = 0;
+ try
+ {
+ mObjAdapter->remove(mObjAdapter->getCommunicator()->stringToIdentity(mState->bridgeId));
+ }
+ catch (...)
+ {
+ }
data->getMonitor()->setCompleted();
}
catch (const Ice::ObjectNotExistException& ex)
@@ -2019,6 +2026,13 @@ void BridgeImpl::destroy(const AsteriskSCF::System::V1::OperationContextPtr& con
// Remove references to the session listener implementation.
//
mObjAdapter->remove(mSessionListenerPrx->ice_getIdentity());
+ try
+ {
+ mObjAdapter->remove(mObjAdapter->getCommunicator()->stringToIdentity(mState->bridgeId));
+ }
+ catch (...)
+ {
+ }
mListeners->stop();
try
@@ -2190,7 +2204,7 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
//
SessionsTrackerPtr removeTracker(new SessionsTracker);
removeTracker->add(session->getSession());
- session->shutdown(context, mSessionListenerPrx, new ResponseCode);
+ session->shutdown(context, mObjAdapter, mSessionListenerPrx, new ResponseCode);
//
// Since the shutdown of the session is inherently asynchronous, the
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 23666f4..70ef8a6 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -137,7 +137,7 @@ public:
void indicated(const AsteriskSCF::System::V1::OperationContextPtr& context,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication,
- const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&)
+ const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current& current)
{
ContextDataPtr data(checkAndThrow(mContextCache, context));
@@ -183,7 +183,7 @@ public:
//
// IMPLNOTE: The AMI approach.
// Stack some operations in a callback. In this case it will be:
-
+
// 1. getSession()
// 2. removeBridge()
// 3. disconnect() or destroy()
@@ -204,14 +204,14 @@ public:
if (!session)
{
mLogger(Info) << "Attempt to respond to stopped notification for session with proxy "
- << proxyString << " that does not match known sessions. Possible out of order operations.";
+ << proxyString << " that does not match known sessions. Possible out of order operations.";
return;
}
//
// This returns only the active sessions.
//
-
+
//
// Shutdown is handled asynchronously, so there
// won't be any exceptions that need to be caught
@@ -219,10 +219,29 @@ public:
// prevent the stop indication from being sent
// back to this session.
//
- session->shutdown(context, mListenerPrx, ResponseCodePtr());
+ session->shutdown(context, current.adapter, mListenerPrx, ResponseCodePtr());
mSessions->removeSession(context, session->getBridgedSession());
//
+ // this is all about cleaning up a servant that may have been created as a session controller
+ // for a given session.
+ //
+ try
+ {
+ if (current.adapter)
+ {
+ std::string sessionControllerIdentity =
+ current.adapter->getCommunicator()->identityToString(source->ice_getIdentity());
+ sessionControllerIdentity += ".bridgecontroller";
+ current.adapter->remove(
+ current.adapter->getCommunicator()->stringToIdentity(sessionControllerIdentity));
+ }
+ }
+ catch (...)
+ {
+ }
+
+ //
// It's a good idea to reap at this time to avoid
// having processes that might be disconnected
// from being considered in the visitSessions()
@@ -233,7 +252,7 @@ public:
//
mSessions->reap();
- ShutdownSessionOperation shutdownOp(context, session->getSession(), mListenerPrx, stopped->response,
+ ShutdownSessionOperation shutdownOp(context, current.adapter, session->getSession(), mListenerPrx, stopped->response,
mLogger);
mSessions->visitSessions(shutdownOp);
diff --git a/src/SessionOperations.cpp b/src/SessionOperations.cpp
index d93a13e..3c9cdaa 100644
--- a/src/SessionOperations.cpp
+++ b/src/SessionOperations.cpp
@@ -67,10 +67,12 @@ void ConnectSessionOperation::operator()(const SessionWrapperPtr& s)
ShutdownSessionOperation::ShutdownSessionOperation(
const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const Ice::ObjectAdapterPtr& adapter,
const SessionPrx& exclude, const SessionListenerPrx& listener,
const ResponseCodePtr& response,
const Logger& logger) :
mRootContext(context),
+ mObjectAdapter(adapter),
mExclude(exclude->ice_getIdentity()),
mListener(listener),
mResponse(response),
@@ -81,10 +83,12 @@ ShutdownSessionOperation::ShutdownSessionOperation(
ShutdownSessionOperation::ShutdownSessionOperation(
const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const Ice::ObjectAdapterPtr& adapter,
const SessionListenerPrx& listener,
const ResponseCodePtr& response,
const Logger& logger) :
mRootContext(context),
+ mObjectAdapter(adapter),
mListener(listener),
mResponse(response),
mLogger(logger),
@@ -96,7 +100,7 @@ void ShutdownSessionOperation::operator()(const SessionWrapperPtr& wrapper)
{
if (mSkipExclude || wrapper->getSession()->ice_getIdentity() != mExclude)
{
- wrapper->shutdown(calculateOperationContext(mRootContext, wrapper->id()), mListener, mResponse);
+ wrapper->shutdown(calculateOperationContext(mRootContext, wrapper->id()), mObjectAdapter, mListener, mResponse);
}
}
diff --git a/src/SessionOperations.h b/src/SessionOperations.h
index b74b505..96ff3db 100644
--- a/src/SessionOperations.h
+++ b/src/SessionOperations.h
@@ -89,6 +89,7 @@ class ShutdownSessionOperation : public std::unary_function<SessionWrapperPtr, v
public:
ShutdownSessionOperation(
const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const Ice::ObjectAdapterPtr& adapter,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude,
const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response,
@@ -96,6 +97,7 @@ public:
ShutdownSessionOperation(
const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const Ice::ObjectAdapterPtr& adapter,
const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response,
const AsteriskSCF::System::Logging::Logger& logger);
@@ -103,6 +105,7 @@ public:
void operator()(const SessionWrapperPtr& wrapper);
private:
AsteriskSCF::System::V1::OperationContextPtr mRootContext;
+ Ice::ObjectAdapterPtr mObjectAdapter;
Ice::Identity mExclude;
AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListener;
AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index f0d4449..4357fb2 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -352,12 +352,68 @@ private:
SessionWrapperPtr mSession;
};
+class RemoveSessionControllerServant : public QueuedTask
+{
+public:
+ RemoveSessionControllerServant(const Ice::ObjectAdapterPtr& adapter,
+ const SessionWrapperPtr& session):
+ QueuedTask("RemoveSessionControllerServant"),
+ mAdapter(adapter),
+ mSession(session)
+ {
+ }
+
+ bool executeImpl()
+ {
+ if (mAdapter && mSession)
+ {
+ AsteriskSCF::Replication::BridgeService::V1::BridgedSessionPtr s = mSession->getBridgedSession();
+ if (s && !s->bridgeId.empty())
+ {
+
+ //
+ // XXX- this is a huge problem to have the calculated id in
+ // multiple places, this needs to be properly dealt with by refactoring how that controller
+ // is managed.
+ //
+ string controllerId = mAdapter->getCommunicator()->identityToString(s->session->ice_getIdentity());
+ controllerId += ".bridgecontroller";
+ try
+ {
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(controllerId));
+ }
+ catch (...)
+ {
+ //
+ // might not be there.
+ //
+ }
+ }
+ }
+ return true;
+ }
+
+ void done()
+ {
+ mListener->succeeded();
+ }
+
+ void failed(const Ice::Exception&)
+ {
+ mListener->failed();
+ }
+private:
+ Ice::ObjectAdapterPtr mAdapter;
+ SessionWrapperPtr mSession;
+
+};
+
/**
* Simple internal helper to setup a lists of tasks to be performed when
* removing a session from a bridge.
*/
static QueuedTasks createShutdownTasks(const AsteriskSCF::System::V1::OperationContextPtr& rootContext,
- const SessionWrapperPtr& session, const SessionListenerPrx& listener,
+ const SessionWrapperPtr& session, const Ice::ObjectAdapterPtr& adapter, const SessionListenerPrx& listener,
const ResponseCodePtr& responseCode, const Logger& logger)
{
//
@@ -371,6 +427,7 @@ static QueuedTasks createShutdownTasks(const AsteriskSCF::System::V1::OperationC
QueuedTasks tasks;
tasks.push_back(new SetStateFromTask(session, ::AsteriskSCF::Replication::BridgeService::V1::Disconnected,
statesToContinueOn));
+ tasks.push_back(new RemoveSessionControllerServant(adapter, session));
if (responseCode)
{
tasks.push_back(new RemoveBridgeTask(rootContext, session, listener, true));
@@ -641,11 +698,12 @@ void SessionWrapper::setup(const AsteriskSCF::System::V1::OperationContextPtr& c
}
void SessionWrapper::shutdown(const AsteriskSCF::System::V1::OperationContextPtr& rootContext,
+ const Ice::ObjectAdapterPtr& adapter,
const SessionListenerPrx& listener, const ResponseCodePtr& code)
{
mLogger(Trace) << FUNLOG << ": beginning shutdown of " << mId;
QueuedTaskPtr shutdownRunner(new QueueableExecutor(
- createShutdownTasks(rootContext, this, listener, code, mLogger), mLogger));
+ createShutdownTasks(rootContext, this, adapter, listener, code, mLogger), mLogger));
if (!code)
{
//
diff --git a/src/SessionWrapper.h b/src/SessionWrapper.h
index 29f68a1..58fd720 100644
--- a/src/SessionWrapper.h
+++ b/src/SessionWrapper.h
@@ -152,6 +152,7 @@ public:
void setup(const AsteriskSCF::System::V1::OperationContextPtr& context);
void shutdown(const AsteriskSCF::System::V1::OperationContextPtr& rootContext,
+ const Ice::ObjectAdapterPtr& adapter,
const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& code);
-----------------------------------------------------------------------
--
asterisk-scf/release/bridging.git
More information about the asterisk-scf-commits
mailing list