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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Aug 30 09:21:55 CDT 2010


branch "master" has been updated
       via  3fe7fe83bee6f4527f34333703419d103650943c (commit)
      from  0046e8c1667cfb82d308433b5d872ed29274eb19 (commit)

Summary of changes:
 src/BridgeImpl.cpp |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)


- Log -----------------------------------------------------------------
commit 3fe7fe83bee6f4527f34333703419d103650943c
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Aug 30 11:49:15 2010 -0230

    Fixed an issue where the admin endpoint's terminate command would not get
    called when the bridge is shutdown.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index eb4afb3..fe66533 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -90,9 +90,8 @@ namespace BridgeService
     class BridgeShutdownFunctor : public std::unary_function<BridgeImpl::BridgeEndpoint, void>
     {
     public:
-        BridgeShutdownFunctor(const Core::Endpoint::V1::EndpointIdPtr& id, const Session::V1::ResponseCodePtr& responseCode) : 
-            mId(id),
-            mResponseCode(responseCode)
+        BridgeShutdownFunctor(const Core::Endpoint::V1::EndpointIdPtr& id) :
+            mId(id)
         {
         }
 
@@ -114,7 +113,6 @@ namespace BridgeService
         }
     private:
         Core::Endpoint::V1::EndpointIdPtr mId;
-        Session::V1::ResponseCodePtr mResponseCode;
     };
 
     //
@@ -442,6 +440,13 @@ Hydra::Core::Endpoint::V1::EndpointSeq Hydra::BridgeService::BridgeImpl::listEnd
 
 void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
 {
+    //
+    // When shutting down, the bridge makes a copy of its current state and unlocks, proceeding with
+    // no other internal locks. 
+    //
+    std::vector<BridgeEndpoint> copyOfEndpoints;
+    Hydra::Session::V1::SignalCommandsPrx adminCmd;
+
     mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
     {
         boost::unique_lock<boost::shared_mutex> lock(mLock);
@@ -456,6 +461,11 @@ void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
             throw Ice::ObjectNotExistException(__FILE__, __LINE__);
         }
         mState = ShuttingDown;
+        std::swap(copyOfEndpoints, mEndpoints);
+        if(mAdminEndpoint.get() != 0 && mAdminEndpoint->endpoint->command)
+        {
+            adminCmd = mAdminEndpoint->endpoint->command;
+        }
     }
     if(mMonitor)
     {
@@ -465,19 +475,24 @@ void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
     mEvents->shuttingDown();
 
     //
-    // TODO: Source ids for bridge generated operations should come from configuration, etc.
+    // TODO: Response code for termination messages for bridges shutting down should come from configuration
     //
-    Hydra::Core::Endpoint::V1::EndpointIdPtr sourceId;
-    if(mAdminEndpoint.get() != 0 )
+    std::for_each(copyOfEndpoints.begin(), copyOfEndpoints.end(), Hydra::BridgeService::BridgeShutdownFunctor(mBridgeId));
+    try
+    {
+        adminCmd->terminate(mBridgeId);
+    }
+    catch(const Ice::Exception&)
     {
-        sourceId = mAdminEndpoint->endpoint->id;
+        //
+        // Swallow this. The admin endpoint going away might be the cause for the shutdown, in which case an exception from a terminate request would
+        // be expected.
+        //
     }
+
     //
-    // TODO: Response code for termination messages for bridges shutting down should come from configuration
+    // Now call terminate on the bridge endpoint.
     //
-    Hydra::Session::V1::ResponseCodePtr response(new Hydra::Session::V1::ResponseCode(0));
-
-    std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::BridgeShutdownFunctor(mBridgeId, response));
 
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is shutdown." << std::endl;
     mEvents->stopped();
@@ -560,10 +575,12 @@ size_t Hydra::BridgeService::BridgeImpl::endpointTerminated(const Hydra::Core::E
         endpointCount = mEndpoints.size();
         if(ep.get() == 0)
         {
+            mLogger.getDebugStream() << __FUNCTION__ << ": unable to locate terminated endpoint in list of known endpoints! Checking for match on admin endpoint" << std::endl;
             if(mAdminEndpoint.get() != 0)
             {
                 if(id->endpointManagerId == mAdminEndpoint->endpoint->id->endpointManagerId && id->destinationId == mAdminEndpoint->endpoint->id->destinationId)
                 {
+                    mLogger.getDebugStream() << __FUNCTION__ << ": terminated endpoint is the admin endpoint. Resetting admin endpoint!" << std::endl;
                     ep = mAdminEndpoint;
                     mAdminEndpoint.reset(0);
                 }

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list