[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
Thu Aug 26 13:07:04 CDT 2010


branch "master" has been updated
       via  43ae7858aeb86628f5c848960ffe012ab7f99fb2 (commit)
      from  d46ccb8786c3a461318fbec73918b9b06b144f08 (commit)

Summary of changes:
 src/BridgeImpl.cpp |   78 ++++++++++++++++++++++++++++++---------------------
 src/BridgeImpl.h   |    4 ++-
 2 files changed, 49 insertions(+), 33 deletions(-)


- Log -----------------------------------------------------------------
commit 43ae7858aeb86628f5c848960ffe012ab7f99fb2
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Aug 26 15:31:42 2010 -0230

    Fix up confusion between terminate/terminated.
    
    removeEndpoint now calls terminate on the endpoint being removed (for the
      moment).  Really, removeEndpoint should either provide an option to skip the
    terminate or not call terminate at all and have  a second method to pull the
    endpoint out of the bridge without calling terminate on its session command
    proxy (think call transfer).

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index bdf03e4..1205029 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -224,7 +224,10 @@ namespace BridgeService
 
         void terminated(const Core::Endpoint::V1::EndpointIdPtr& p, const Session::V1::ResponseCodePtr& r, const Ice::Current& current)
         {
-            mBridge->endpointTerminated(p, r, current);
+            if(mBridge->endpointTerminated(p, r, current) == 1)
+            {
+                mBridge->shutdown(current);
+            }
         }
 
         void busy(const Core::Endpoint::V1::EndpointIdPtr& p, const Ice::Current&)
@@ -399,10 +402,12 @@ void Hydra::BridgeService::BridgeImpl::removeEndpoint(const Hydra::Core::Endpoin
         bool result =  mMonitor->onRemoveEndpoint(i->endpoint);
         mLogger.getDebugStream() << __FUNCTION__ << "onRemoveEndpoint() returned " << result << std::endl;
     }
+
     mEvents->endpointRemoved(i->endpoint);
-    //
-    // XXX: Exceptions?
-    //
+    if(i->endpoint->command)
+    {
+        i->endpoint->command->terminate(mBridgeId);
+    }
     i->connector->unplug();
     mEndpoints.erase(i);
 
@@ -537,46 +542,43 @@ void Hydra::BridgeService::BridgeImpl::endpointConnected(const Hydra::Core::Endp
     }
 }
 
-void Hydra::BridgeService::BridgeImpl::endpointTerminated(const Hydra::Core::Endpoint::V1::EndpointIdPtr& id, 
+size_t Hydra::BridgeService::BridgeImpl::endpointTerminated(const Hydra::Core::Endpoint::V1::EndpointIdPtr& id, 
   const Hydra::Session::V1::ResponseCodePtr& response,
   const Ice::Current& current)
 {
     mLogger.getDebugStream() << __FUNCTION__ << ": endpoint terminated from " << endpointIdToString(id) << std::endl;
+    size_t endpointCount(0);
+
+    //
+    // Find out if we have an endpoint we need to "unplug"
+    //
+    std::auto_ptr<BridgeEndpoint> ep;
     {
-        //
-        // Check list of endpoints first.
-        //
         boost::unique_lock<boost::shared_mutex> lock(mLock);
-        std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator i = find(id);
-        if(i != mEndpoints.end())
+        ep = removeEndpointImpl(id);
+        endpointCount = mEndpoints.size();
+        if(ep.get() == 0)
         {
-            i->endpoint->callback->terminated(id, response);
-            try
-            {
-                removeEndpoint(id, current);
-            }
-            catch(const Hydra::System::Component::V1::ShuttingDown&)
-            {
-            }
-            catch(const Ice::ObjectNotExistException&)
+            if(mAdminEndpoint.get() != 0)
             {
+                if(id->endpointManagerId == mAdminEndpoint->endpoint->id->endpointManagerId && id->destinationId == mAdminEndpoint->endpoint->id->destinationId)
+                {
+                    ep = mAdminEndpoint;
+                    mAdminEndpoint.reset(0);
+                }
+                else
+                {
+                    ++endpointCount;
+                }
             }
-            return;
         }
     }
-    if(mAdminEndpoint.get() != 0)
+
+    if(ep.get() != 0 && ep->connector)
     {
-        if(id->endpointManagerId == mAdminEndpoint->endpoint->id->endpointManagerId && id->destinationId == mAdminEndpoint->endpoint->id->destinationId)
-        {
-            //
-            // Default behavior will be for the bridge to shutdown when the admin endpoint leaves.
-            //
-            shutdown(current);
-        }
-        else
-        {
-        }
+        ep->connector->unplug();
     }
+    return endpointCount;
 }
 
 void Hydra::BridgeService::BridgeImpl::endpointRinging(const Hydra::Core::Endpoint::V1::EndpointIdPtr& id)
@@ -626,7 +628,7 @@ void Hydra::BridgeService::BridgeImpl::statePreCheck()
     }
 }
 
-std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator Hydra::BridgeService::BridgeImpl::find(const Core::Endpoint::V1::EndpointIdPtr& e)
+std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator Hydra::BridgeService::BridgeImpl::find(const Hydra::Core::Endpoint::V1::EndpointIdPtr& e)
 {
     mLogger.getDebugStream() << __FUNCTION__ << ": searching endpoints for " << e->endpointManagerId << ":" << e->destinationId << "." << std::endl;
     for(std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator i = mEndpoints.begin(); i != mEndpoints.end(); ++i)
@@ -639,3 +641,15 @@ std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator Hydra::B
     mLogger.getDebugStream() << __FUNCTION__ << ": endpoint " << e->endpointManagerId << ":" << e->destinationId << " not found." << std::endl;
     return mEndpoints.end();
 }
+
+std::auto_ptr<Hydra::BridgeService::BridgeImpl::BridgeEndpoint> Hydra::BridgeService::BridgeImpl::removeEndpointImpl(const Hydra::Core::Endpoint::V1::EndpointIdPtr& e)
+{
+    std::vector<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>::iterator i = find(e);
+    if(i != mEndpoints.end())
+    {
+        std::auto_ptr<Hydra::BridgeService::BridgeImpl::BridgeEndpoint> result(new BridgeEndpoint(*i));
+        mEndpoints.erase(i);
+        return result;
+    }
+    return std::auto_ptr<Hydra::BridgeService::BridgeImpl::BridgeEndpoint>(0);
+}
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 27e28e8..3d544b0 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -63,7 +63,7 @@ namespace BridgeService
       bool destroyed();
 
       void endpointConnected(const Core::Endpoint::V1::EndpointIdPtr& id);
-      void endpointTerminated(const Core::Endpoint::V1::EndpointIdPtr& id, const Session::V1::ResponseCodePtr& response, const Ice::Current&);
+      size_t endpointTerminated(const Core::Endpoint::V1::EndpointIdPtr& id, const Session::V1::ResponseCodePtr& response, const Ice::Current&);
       void endpointRinging(const Core::Endpoint::V1::EndpointIdPtr& id);
       void endpointBusy(const Core::Endpoint::V1::EndpointIdPtr& id);
 
@@ -103,6 +103,8 @@ namespace BridgeService
 
       void statePreCheck();
       std::vector<BridgeEndpoint>::iterator find(const Core::Endpoint::V1::EndpointIdPtr& e);
+
+      std::auto_ptr<BridgeEndpoint> removeEndpointImpl(const Core::Endpoint::V1::EndpointIdPtr& e);
    };
 
    typedef IceUtil::Handle<BridgeImpl> BridgeImplPtr;

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list