[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "bridge-replication-issue" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Jan 12 15:57:01 CST 2012


branch "bridge-replication-issue" has been created
        at  9b791bfd2fc76f659980a697512cc6b6b9ea6661 (commit)

- Log -----------------------------------------------------------------
commit 9b791bfd2fc76f659980a697512cc6b6b9ea6661
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jan 12 18:26:34 2012 -0330

    Hold on to some of the fixes (and the cruft I added)

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 5114a55..7538da7 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -1727,7 +1727,7 @@ void BridgeImpl::removeListener(const BridgeListenerPrx& listener, const Ice::Cu
     }
     if (mListeners->removeListener(listener))
     {
-        string key = mState->key + ".listener." +
+        string key = mState->bridgeId + ".listener." +
             mObjAdapter->getCommunicator()->identityToString(listener->ice_getIdentity());
         if (replicate())
         {
@@ -2086,7 +2086,7 @@ BridgeStateItemPtr BridgeImpl::createUpdate()
     //
     if (replicate())
     {
-        BridgeStateItemPtr result = new BridgeStateItem(*mState.get());
+        BridgeStateItemPtr result = BridgeStateItemPtr::dynamicCast(mState->ice_clone());
         return result;
     }
     return 0;
@@ -2151,7 +2151,7 @@ AsteriskSCF::BridgeService::BridgeServant::create(const Ice::ObjectAdapterPtr& o
     logger(Trace) << FUNLOG << ": creating replica for " << state->bridgeId;
     IceUtil::Handle<AsteriskSCF::BridgeService::BridgeServant> bridge(
         new BridgeImpl(state->bridgeId, objectAdapter, vector<BridgeListenerPrx>(),
-                    listenerMgr, replicator, state, logger));
+            listenerMgr, replicator, BridgeStateItemPtr::dynamicCast(state->ice_clone()), logger));
     
     return bridge;
 }
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 6c7f7df..a12c94c 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -46,6 +46,10 @@ namespace
 #ifndef _NDEBUG
 void dump(const Logger& logger, const BridgeCreationHookDataPtr& hookData)
 {
+    //
+    // TODO: this whole thing should not be run if running at the "Trace"
+    // log level.
+    //
     ostringstream os;
     os << "Hook data:";
     string indent = "   ";
@@ -67,7 +71,7 @@ void dump(const Logger& logger, const BridgeCreationHookDataPtr& hookData)
     {
         os << prefix << indent << indent << (*i);
     }
-    logger(Debug) << os.str();
+    logger(Trace) << os.str();
 }
 #else
 void dump(const Logger&, const BridgeCreationHookDataPtr&)
@@ -484,13 +488,7 @@ void BridgeManagerImpl::updateState(const BridgeManagerStateItemPtr& state)
 {
     mLogger(Trace) << FUNLOG;
     boost::unique_lock<boost::shared_mutex> lock(mLock);
-    //
-    // We perform a deep copy because there are no guarantees about the thread safety of the memory
-    // pointed to be "state" over time. We could "say" that the call acquires ownership, but its
-    // safer to take the added cost of the copy.
-    //
-    *mState = *state;
-
+    mState = BridgeManagerStateItemPtr::dynamicCast(state->ice_clone());
     mPartyIdExtensionPoint->replaceHooks(state->partyIdExtensionPointHooks);
 }
 
diff --git a/src/BridgeReplicatorStateListenerI.cpp b/src/BridgeReplicatorStateListenerI.cpp
index 7dae181..496f678 100644
--- a/src/BridgeReplicatorStateListenerI.cpp
+++ b/src/BridgeReplicatorStateListenerI.cpp
@@ -44,11 +44,16 @@ public:
     void removeBridgeItem(const string& bridgeKey, const string& item, const string& sliceType)
     {
         IceUtil::Mutex::Lock lock(mMutex);
-        mLogger(Trace) << " removing bridge item id " << item << " (" << sliceType << ") from bridge " << bridgeKey;
+        mLogger(Debug) << " removing bridge item id " << item << " (" << sliceType << ") from bridge " << bridgeKey;
         mBridgeItemMap[bridgeKey].erase(item);
         if (mBridgeItemMap[bridgeKey].empty())
         {
-            mManager->removeBridge(bridgeKey);
+            map<string, ReplicatedStateItemPtr>::iterator entry = mItems.find(bridgeKey);
+            if (entry == mItems.end())
+            {
+                mLogger(Debug) << "no items left, and the bridge itself is no longer in item dictionary, it is safe to remove the bridge";
+                mManager->removeBridge(bridgeKey);
+            }
         }
     }
 
@@ -68,7 +73,7 @@ public:
             }
             if (item)
             {
-                mLogger(Trace) << " received removal of " << (*k) << ": a " << item->ice_id();
+                mLogger(Debug) << " received removal of " << (*k) << ": a " << item->ice_id();
 
                 BridgedSessionPtr bridgedSessionItem = BridgedSessionPtr::dynamicCast(item);
                 if (bridgedSessionItem)
@@ -172,6 +177,7 @@ public:
                         continue;
                     }
                     existingItem = entry->second;
+                    entry->second = (*i);
                 }
                 else
                 {
@@ -213,9 +219,12 @@ public:
                     // We could break here if we could be sure that there were no other updates.
                     //
                 }
-              
 
-                if (!found)
+                //
+                // If a race condition occurs on state updates and a bridge and its replica objects are in the process of
+                // shutting down, we need to avoid attempting a recreation of a replica.
+                //
+                if (!found && (bridgeItem->runningState != ShuttingDown && bridgeItem->runningState != Destroyed))
                 {
                     if (existingItem)
                     {
@@ -232,8 +241,10 @@ public:
             {
                 vector<BridgeServantPtr> bridges = mManager->getBridges();
                 bool found = false;
+                string unique = IceUtil::generateUUID();
                 for (vector<BridgeServantPtr>::iterator b = bridges.begin(); b != bridges.end(); ++b)
                 {
+                    cerr << unique << " checking bridge id " << (*b)->id() << endl;
                     if ((*b) && (*b)->id() == bridgedSessionItem->bridgeId)
                     {
                         SessionCollectionPtr sessions = (*b)->getSessions();
@@ -250,7 +261,7 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received a " << bridgedSessionItem->ice_id() << " (id: " << bridgedSessionItem->key << ")"
+                    mLogger(Warning) << "received a " << bridgedSessionItem->ice_id() << " (id: " << bridgedSessionItem->key << ")"
                                    << " update for a session on a bridge that does not exist: " << bridgedSessionItem->bridgeId;
                 }
              
@@ -283,7 +294,7 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received a " << sessionPairing->ice_id() << " (id: " << sessionPairing->key << ")"
+                    mLogger(Warning) << "received a " << sessionPairing->ice_id() << " (id: " << sessionPairing->key << ")"
                                    << " update for a session on a bridge that does not exist: " << sessionPairing->bridgeKey;
                 }
              
@@ -301,6 +312,7 @@ public:
                     {
                         (*b)->addListener(bridgeListener);
                         mBridgeItemMap[bridgeListener->bridgeId][bridgeListener->key] = bridgeListener;
+                        found = true;
                     }
                     //
                     // We could break here if we could be sure that there were no other updates.
@@ -308,7 +320,7 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received a " << bridgeListener->ice_id() << " (id: " << bridgeListener->key << ")"
+                    mLogger(Warning) << "received a " << bridgeListener->ice_id() << " (id: " << bridgeListener->key << ")"
                                    << " update for a session on a bridge that does not exist: " << bridgeListener->bridgeId;
                 }
              
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 206210a..69410c3 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -335,6 +335,42 @@ typedef IceUtil::Handle<TestEnvironment> TestEnvironmentPtr;
 TestEnvironmentPtr globalTestEnvironment;
 
 //
+// Some tests leave cruft behind if they fail. This helper function cleans out any old bridge
+// objects that may be laying around so we can rely on a certain baseline.
+//
+void cleanupBridges(const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& mgr)
+{
+    BridgeSeq bridges = mgr->listBridges();
+    for (BridgeSeq::const_iterator iter = bridges.begin(); iter != bridges.end(); ++iter)
+    {
+        try
+        {
+            (*iter)->shutdown();
+        }
+        catch (const Ice::ObjectNotExistException&)
+        {
+            //
+            // Good!
+            //
+        }
+        catch (const exception& ex)
+        {
+            //
+            // Not great.
+            //
+            cerr << ex.what() << " thrown when cleaning up bridges";
+        }
+        catch (...)
+        {
+            //
+            // Even less great
+            //
+            cerr << "Unknown exception thrown when cleaning up bridges";
+        }
+    }
+}
+
+//
 // Simple helper for initializing Ice and ensuring proper cleanup in the context of a test case.
 //
 class IceEnvironment
@@ -489,6 +525,7 @@ public:
                 addServant(listenerPrx, testAdapter, servant, testEnv.strToIdent(IceUtil::generateUUID()));
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
 
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
@@ -532,6 +569,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -639,6 +677,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -736,6 +775,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -850,6 +890,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -906,6 +947,7 @@ public:
                 testAdapter->activate();
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
                 AsteriskSCF::SessionCommunications::V1::SessionPrx a = channel.getSession("111");
                 a->start();
@@ -990,6 +1032,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx2 = env()->standbyBridgeManager();
                 BOOST_CHECK(mgrPrx2);
                 
@@ -1021,39 +1064,6 @@ public:
                 BOOST_CHECK(servant->createCalls() == 2);
                 bridge->shutdown();
                 mgrPrx->removeListener(listenerPrx);
-
-                BridgeSeq bridges = mgrPrx->listBridges();
-
-                // Activate the secondary component so we can 
-                // query it. 
-                ReplicaPrx secondaryReplica = env()->secondaryReplicaControl();
-                ReplicaPrx primaryReplica = env()->primaryReplicaControl();
-                BOOST_CHECK(primaryReplica->isActive() == true);
-
-                primaryReplica->standby();
-                BOOST_CHECK(primaryReplica->isActive() == false);
-
-                secondaryReplica->activate();
-                BOOST_CHECK(secondaryReplica->isActive() == true);
-
-                BridgeSeq bridges2 = mgrPrx2->listBridges();
-                if (bridges.size() != bridges2.size())
-                {
-                    stringstream os;
-                    os << __FILE__ << ':' << __LINE__ << " Bridge count differs, primary: " << bridges.size() << " vs: "
-                        << bridges2.size();
-                    BOOST_MESSAGE(os.str());
-                }
-
-                BOOST_CHECK(bridges.size() == bridges2.size());
-
-                // Set the components back to original state.
-                secondaryReplica->standby();
-                primaryReplica->activate();
-
-                BOOST_CHECK(primaryReplica->isActive() == true);
-                BOOST_CHECK(secondaryReplica->isActive() == false);
-
             }
             catch (const Ice::Exception& ex)
             {
@@ -1094,6 +1104,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -1197,6 +1208,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -1304,6 +1316,7 @@ public:
 
                 AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
                 BOOST_CHECK(servant->stoppingCalls() == 0);
                 BOOST_CHECK(servant->stoppedCalls() == 0);
@@ -1409,6 +1422,7 @@ public:
 
                 BridgeManagerPrx mgrPrx = env()->primaryBridgeManager();
                 BOOST_CHECK(mgrPrx);
+                cleanupBridges(mgrPrx);
                 mgrPrx->addListener(listenerPrx);
 
                 SessionSeq sessions;
@@ -1513,12 +1527,12 @@ bool init_unit_test()
 {
     boost::shared_ptr<BridgeTester> bridgeTester(new BridgeTester(globalTestEnvironment));
     framework::master_test_suite().
-        add(BOOST_TEST_CASE(boost::bind(&BridgeTester::telephonyConnectTest, bridgeTester)));
-    framework::master_test_suite().
         add(BOOST_TEST_CASE(boost::bind(&BridgeTester::createEmptyBridge, bridgeTester)));
     framework::master_test_suite().
         add(BOOST_TEST_CASE(boost::bind(&BridgeTester::simpleBridgingTest, bridgeTester)));
     framework::master_test_suite().
+        add(BOOST_TEST_CASE(boost::bind(&BridgeTester::telephonyConnectTest, bridgeTester)));
+    framework::master_test_suite().
         add(BOOST_TEST_CASE(boost::bind(&BridgeTester::testAutoShutdown, bridgeTester)));
     framework::master_test_suite().
         add(BOOST_TEST_CASE(boost::bind(&BridgeTester::bridgeDefaultListenerTest, bridgeTester)));

commit 21220a3113fc7e984fc90b977e5e8a4c5e3c2770
Merge: b9ea1d2 30c83a1
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jan 12 14:07:18 2012 -0330

    Merge branch 'master' into bridge-replication-issue


commit b9ea1d24779b1620943a4e2a09557bb64601d558
Merge: c109620 934164a
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jan 12 14:07:00 2012 -0330

    Merge branch 'bridge-replication-issues' of ssh://git.asterisk.org/asterisk-scf/integration/bridging into bridge-replication-issue


commit 30c83a13fdf0bf4746ac55a96e1049c1e1823c0a
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jan 12 13:51:55 2012 -0330

    Fix test library names to match conventions and test driver configuration.

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 87f5b4b..34ceed8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -5,37 +5,37 @@ include_directories(../src)
 
 astscf_slice_include_collection(TEST_CHANNEL)
 
-astscf_component_init(bridge_component_test)
+astscf_component_init(BridgeComponentTest)
 astscf_slice_collection(LOCAL PATH "${CMAKE_CURRENT_SOURCE_DIR}")
-astscf_component_add_slices(bridge_component_test TEST_CHANNEL AsteriskSCF/TestChannel/CommandsIf.ice)
-astscf_component_add_slices(bridge_component_test LOCAL TestCookieIf.ice)
-astscf_component_add_files(bridge_component_test TestBridging.cpp)
-astscf_component_add_files(bridge_component_test BridgeListenerI.h)
-astscf_component_add_files(bridge_component_test BridgeListenerI.cpp)
-astscf_component_add_files(bridge_component_test BridgeManagerListenerI.h)
-astscf_component_add_files(bridge_component_test BridgeManagerListenerI.cpp)
-astscf_component_add_files(bridge_component_test TestCommandDriver.cpp)
-astscf_component_add_files(bridge_component_test TestCommandDriver.h)
-astscf_component_add_slices(bridge_component_test PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
-astscf_component_add_ice_libraries(bridge_component_test IceStorm)
-astscf_component_add_ice_libraries(bridge_component_test IceBox)
-astscf_component_add_boost_libraries(bridge_component_test unit_test_framework thread)
-astscf_component_add_slice_collection_libraries(bridge_component_test ASTSCF TEST_CHANNEL)
-astscf_component_build_icebox(bridge_component_test)
-target_link_libraries(bridge_component_test LoggingClient)
-astscf_test_icebox(bridge_component_test config/test_bridging.conf)
+astscf_component_add_slices(BridgeComponentTest TEST_CHANNEL AsteriskSCF/TestChannel/CommandsIf.ice)
+astscf_component_add_slices(BridgeComponentTest LOCAL TestCookieIf.ice)
+astscf_component_add_files(BridgeComponentTest TestBridging.cpp)
+astscf_component_add_files(BridgeComponentTest BridgeListenerI.h)
+astscf_component_add_files(BridgeComponentTest BridgeListenerI.cpp)
+astscf_component_add_files(BridgeComponentTest BridgeManagerListenerI.h)
+astscf_component_add_files(BridgeComponentTest BridgeManagerListenerI.cpp)
+astscf_component_add_files(BridgeComponentTest TestCommandDriver.cpp)
+astscf_component_add_files(BridgeComponentTest TestCommandDriver.h)
+astscf_component_add_slices(BridgeComponentTest PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
+astscf_component_add_ice_libraries(BridgeComponentTest IceStorm)
+astscf_component_add_ice_libraries(BridgeComponentTest IceBox)
+astscf_component_add_boost_libraries(BridgeComponentTest unit_test_framework thread)
+astscf_component_add_slice_collection_libraries(BridgeComponentTest ASTSCF TEST_CHANNEL)
+astscf_component_build_icebox(BridgeComponentTest)
+target_link_libraries(BridgeComponentTest LoggingClient)
+astscf_test_icebox(BridgeComponentTest config/test_bridging.conf)
 
-astscf_component_init(bridge_unit_tests)
-astscf_component_add_files(bridge_unit_tests ../src/SessionCollection.cpp)
-astscf_component_add_files(bridge_unit_tests ../src/SessionOperations.cpp)
-astscf_component_add_files(bridge_unit_tests ../src/SessionWrapper.cpp)
-astscf_component_add_files(bridge_unit_tests ../src/MediaSplicer.cpp)
-astscf_component_add_files(bridge_unit_tests ../src/MediaMixer.cpp)
-astscf_component_add_slices(bridge_unit_tests PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
-astscf_component_add_files(bridge_unit_tests UnitTests.cpp)
-astscf_component_add_ice_libraries(bridge_unit_tests Ice)
-astscf_component_add_boost_libraries(bridge_unit_tests unit_test_framework thread)
-astscf_component_add_slice_collection_libraries(bridge_unit_tests ASTSCF)
-astscf_component_build_standalone(bridge_unit_tests)
-target_link_libraries(bridge_unit_tests LoggingClient)
-astscf_test_boost(bridge_unit_tests)
+astscf_component_init(BridgeUnitTests)
+astscf_component_add_files(BridgeUnitTests ../src/SessionCollection.cpp)
+astscf_component_add_files(BridgeUnitTests ../src/SessionOperations.cpp)
+astscf_component_add_files(BridgeUnitTests ../src/SessionWrapper.cpp)
+astscf_component_add_files(BridgeUnitTests ../src/MediaSplicer.cpp)
+astscf_component_add_files(BridgeUnitTests ../src/MediaMixer.cpp)
+astscf_component_add_slices(BridgeUnitTests PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
+astscf_component_add_files(BridgeUnitTests UnitTests.cpp)
+astscf_component_add_ice_libraries(BridgeUnitTests Ice)
+astscf_component_add_boost_libraries(BridgeUnitTests unit_test_framework thread)
+astscf_component_add_slice_collection_libraries(BridgeUnitTests ASTSCF)
+astscf_component_build_standalone(BridgeUnitTests)
+target_link_libraries(BridgeUnitTests LoggingClient)
+astscf_test_boost(BridgeUnitTests)

commit c1096206e872e497212594a0978e60e085c2bd10
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Jan 9 16:45:26 2012 -0330

    Fix build issue for compilers that do not support initializer syntax for
    structs.

diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index f2110ab..75d3f23 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -930,7 +930,10 @@ public:
                 IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(2));
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo t;
+                t.sessionProxy = b;
+                t.info = b->getInfo();
+                sessionInfos.push_back(t);
 
                 bridge->replaceSession(a, sessionInfos);
                 log.clear();
@@ -1458,7 +1461,10 @@ public:
                 TelephonyEventSinkSeq cSinks = tc->getSinks();
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { c, c->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo r;
+                r.sessionProxy = c;
+                r.info = c->getInfo();
+                sessionInfos.push_back(r);
 
                 bridge->replaceSession(b, sessionInfos);
 

commit d9ab0dfb914985f157385625343ea3ce59e56d28
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jan 3 14:55:00 2012 -0600

    Use different syntax for initializing structs.
    
    Old versions of GCC did not like what I was doing. Neither did VS2010.

diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 6fe199a..f2110ab 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -556,8 +556,11 @@ public:
                 BOOST_CHECK(!find(log, "start"));
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { a, a->getInfo() } );
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoA = { a, a->getInfo() };
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoB = { b, b->getInfo() };
+                
+                sessionInfos.push_back(sessionInfoA);
+                sessionInfos.push_back(sessionInfoB);
 
                 bridge->addSessions(sessionInfos);
                 //
@@ -660,8 +663,10 @@ public:
                 BOOST_CHECK(!find(log, "start"));
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { a, a->getInfo() } );
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoA = { a, a->getInfo() };
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoB = { b, b->getInfo() };
+                sessionInfos.push_back(sessionInfoA);
+                sessionInfos.push_back(sessionInfoB);
 
                 bridge->addSessions(sessionInfos);
                 //
@@ -762,8 +767,10 @@ public:
                 BOOST_CHECK(!find(log, "start"));
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { a, a->getInfo() } );
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoA = { a, a->getInfo() };
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoB = { b, b->getInfo() };
+                sessionInfos.push_back(sessionInfoA);
+                sessionInfos.push_back(sessionInfoB);
 
                 bridge->addSessions(sessionInfos);
                 //
@@ -1116,8 +1123,11 @@ public:
                 AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { a, a->getInfo() } );
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoA = { a, a->getInfo() };
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoB = { b, b->getInfo() };
+
+                sessionInfos.push_back(sessionInfoA);
+                sessionInfos.push_back(sessionInfoB);
 
                 bridge->addSessions(sessionInfos);
                 BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));
@@ -1216,8 +1226,11 @@ public:
                 AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
 
                 AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfoSeq sessionInfos;
-                sessionInfos.push_back( { a, a->getInfo() } );
-                sessionInfos.push_back( { b, b->getInfo() } );
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoA = { a, a->getInfo() };
+                AsteriskSCF::SessionCommunications::V1::SessionWithSessionInfo sessionInfoB = { b, b->getInfo() };
+
+                sessionInfos.push_back(sessionInfoA);
+                sessionInfos.push_back(sessionInfoB);
 
                 bridge->addSessions(sessionInfos);
                 BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));

commit 141dd3fdd338e19af21791c8306d952cf4a8d8b2
Merge: 79f6e79 12a3f46
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jan 3 14:42:17 2012 -0600

    Merge branch 'master' of git.asterisk.org:asterisk-scf/release/bridging


commit 79f6e79fddbadb510ea1ebfd7bc875ab2d1b5990
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jan 3 14:37:38 2012 -0600

    Adjust component library names and update test config files

diff --git a/config/test_bridging.conf b/config/test_bridging.conf
index 5ec14f2..3b9e504 100644
--- a/config/test_bridging.conf
+++ b/config/test_bridging.conf
@@ -51,13 +51,13 @@ AsteriskSCF.LoggingClient.ThreadPool.Size=4
 #
 # The IceBox entries for loading the services.
 #
-IceBox.Service.Logger=logging-service:createLoggingService
+IceBox.Service.Logger=LoggingService:createLoggingService
 IceBox.Service.Replicator=BridgeReplicator:create
-IceBox.Service.TestBridge=bridgeservice:create
-IceBox.Service.TestBridge2=bridgeservice:create
-IceBox.Service.ServiceDiscovery=service_locator:create
-IceBox.Service.TestChannel=test_channel:create
-IceBox.Service.TestDriver=bridge_component_test:create
+IceBox.Service.TestBridge=BridgeService:create
+IceBox.Service.TestBridge2=BridgeService:create
+IceBox.Service.ServiceDiscovery=ServiceLocator:create
+IceBox.Service.TestChannel=TestChannel:create
+IceBox.Service.TestDriver=BridgeComponentTest:create
 
 #
 # The bridging service uses the test channel`s Endpoint
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1bee51e..09eb772 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,48 +1,48 @@
 include_directories(${logger_dir}/include)
 include_directories(${astscf-ice-util-cpp_dir}/include)
 
-astscf_component_init(bridgeservice)
-astscf_component_add_files(bridgeservice Component.cpp)
-astscf_component_add_files(bridgeservice BridgeImpl.h)
-astscf_component_add_files(bridgeservice BridgeImpl.cpp)
-astscf_component_add_files(bridgeservice BridgeListenerMgr.h)
-astscf_component_add_files(bridgeservice BridgeListenerMgr.cpp)
-astscf_component_add_files(bridgeservice BridgeManagerListenerMgr.h)
-astscf_component_add_files(bridgeservice BridgeManagerListenerMgr.cpp)
-astscf_component_add_files(bridgeservice BridgeReplicationContext.h)
-astscf_component_add_files(bridgeservice BridgeReplicatorStateListenerI.h)
-astscf_component_add_files(bridgeservice BridgeReplicatorStateListenerI.cpp)
-astscf_component_add_files(bridgeservice BridgeManagerImpl.h)
-astscf_component_add_files(bridgeservice BridgeManagerImpl.cpp)
-astscf_component_add_files(bridgeservice SessionListener.cpp)
-astscf_component_add_files(bridgeservice SessionListener.h)
-astscf_component_add_files(bridgeservice SessionWrapper.cpp)
-astscf_component_add_files(bridgeservice SessionWrapper.h)
-astscf_component_add_files(bridgeservice SessionCollection.cpp)
-astscf_component_add_files(bridgeservice SessionCollection.h)
-astscf_component_add_files(bridgeservice SessionOperations.cpp)
-astscf_component_add_files(bridgeservice SessionOperations.h)
-astscf_component_add_files(bridgeservice BridgeCreationExtensionPointImpl.cpp) 
-astscf_component_add_files(bridgeservice BridgeCreationExtensionPointImpl.h) 
-astscf_component_add_files(bridgeservice BridgePartyIdExtensionPoint.cpp)
-astscf_component_add_files(bridgeservice BridgePartyIdExtensionPoint.h)
-astscf_component_add_files(bridgeservice ServiceUtil.h)
-astscf_component_add_files(bridgeservice DebugUtil.h)
-astscf_component_add_files(bridgeservice MediaSplicer.h)
-astscf_component_add_files(bridgeservice MediaSplicer.cpp)
-astscf_component_add_files(bridgeservice MediaMixer.h)
-astscf_component_add_files(bridgeservice MediaMixer.cpp)
-astscf_component_add_files(bridgeservice Tasks.h)
-astscf_component_add_files(bridgeservice InternalExceptions.h)
-astscf_component_add_files(bridgeservice BridgeServiceConfig.h)
-astscf_component_add_files(bridgeservice ListenerManager.h)
-astscf_component_add_slices(bridgeservice PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
-astscf_component_add_ice_libraries(bridgeservice IceStorm)
-astscf_component_add_boost_libraries(bridgeservice thread date_time)
-astscf_component_add_slice_collection_libraries(bridgeservice ASTSCF)
-astscf_component_build_icebox(bridgeservice)
-target_link_libraries(bridgeservice ASTSCFIceUtilCpp LoggingClient)
-astscf_component_install(bridgeservice)
+astscf_component_init(BridgeService)
+astscf_component_add_files(BridgeService Component.cpp)
+astscf_component_add_files(BridgeService BridgeImpl.h)
+astscf_component_add_files(BridgeService BridgeImpl.cpp)
+astscf_component_add_files(BridgeService BridgeListenerMgr.h)
+astscf_component_add_files(BridgeService BridgeListenerMgr.cpp)
+astscf_component_add_files(BridgeService BridgeManagerListenerMgr.h)
+astscf_component_add_files(BridgeService BridgeManagerListenerMgr.cpp)
+astscf_component_add_files(BridgeService BridgeReplicationContext.h)
+astscf_component_add_files(BridgeService BridgeReplicatorStateListenerI.h)
+astscf_component_add_files(BridgeService BridgeReplicatorStateListenerI.cpp)
+astscf_component_add_files(BridgeService BridgeManagerImpl.h)
+astscf_component_add_files(BridgeService BridgeManagerImpl.cpp)
+astscf_component_add_files(BridgeService SessionListener.cpp)
+astscf_component_add_files(BridgeService SessionListener.h)
+astscf_component_add_files(BridgeService SessionWrapper.cpp)
+astscf_component_add_files(BridgeService SessionWrapper.h)
+astscf_component_add_files(BridgeService SessionCollection.cpp)
+astscf_component_add_files(BridgeService SessionCollection.h)
+astscf_component_add_files(BridgeService SessionOperations.cpp)
+astscf_component_add_files(BridgeService SessionOperations.h)
+astscf_component_add_files(BridgeService BridgeCreationExtensionPointImpl.cpp) 
+astscf_component_add_files(BridgeService BridgeCreationExtensionPointImpl.h) 
+astscf_component_add_files(BridgeService BridgePartyIdExtensionPoint.cpp)
+astscf_component_add_files(BridgeService BridgePartyIdExtensionPoint.h)
+astscf_component_add_files(BridgeService ServiceUtil.h)
+astscf_component_add_files(BridgeService DebugUtil.h)
+astscf_component_add_files(BridgeService MediaSplicer.h)
+astscf_component_add_files(BridgeService MediaSplicer.cpp)
+astscf_component_add_files(BridgeService MediaMixer.h)
+astscf_component_add_files(BridgeService MediaMixer.cpp)
+astscf_component_add_files(BridgeService Tasks.h)
+astscf_component_add_files(BridgeService InternalExceptions.h)
+astscf_component_add_files(BridgeService BridgeServiceConfig.h)
+astscf_component_add_files(BridgeService ListenerManager.h)
+astscf_component_add_slices(BridgeService PROJECT AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice)
+astscf_component_add_ice_libraries(BridgeService IceStorm)
+astscf_component_add_boost_libraries(BridgeService thread date_time)
+astscf_component_add_slice_collection_libraries(BridgeService ASTSCF)
+astscf_component_build_icebox(BridgeService)
+target_link_libraries(BridgeService ASTSCFIceUtilCpp LoggingClient)
+astscf_component_install(BridgeService)
 
 astscf_component_init(BridgeReplicator)
 astscf_component_add_files(BridgeReplicator BridgeReplicatorService.cpp)

commit 12a3f463f48eb9d269b32c2b8dc1b669ca04b859
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Jan 3 12:46:56 2012 -0400

    Remove the session controller from sessions that are removed from a bridge.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index ef58a1f..1a88527 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -908,6 +908,52 @@ private:
     Logger mLogger;
 };
 
+class RemoveSessionControllerTask : public QueuedTask
+{
+public:
+    RemoveSessionControllerTask(const Ice::ObjectAdapterPtr& adapter,
+	const SessionsTrackerPtr& sessions,
+	const Logger& logger):
+        QueuedTask("RemoveSessionControllerTask"),
+        mAdapter(adapter),
+        mSessions(sessions),
+        mLogger(logger)
+    {
+    }
+
+protected:
+    bool executeImpl()
+    {
+        SessionSeq sessions = mSessions->getSessions();
+        for (SessionSeq::iterator i = sessions.begin(); i != sessions.end(); ++i)
+        {
+	    std::string identity = (*i)->ice_getIdentity().name;
+            identity += ".bridgecontroller";
+
+            // Remove session controller from ASM
+            try
+            {
+                mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(identity));
+            }
+            catch (...)
+            {
+                // The only time this would happen is if the session controller does not exist already
+            }
+
+            // Remove the session controller from the session itself
+            SessionControllerPrx controller = SessionControllerPrx::uncheckedCast(mAdapter->createProxy(
+                                                                                      mAdapter->getCommunicator()->stringToIdentity(identity)));
+            (*i)->removeSessionController(controller);
+        }
+        return true;
+    }
+
+private:
+    Ice::ObjectAdapterPtr mAdapter;
+    SessionsTrackerPtr mSessions;
+    Logger mLogger;
+};
+
 class UnplugMedia : public QueuedTask
 {
 public:
@@ -1441,6 +1487,7 @@ void BridgeImpl::removeSessions_async(const AMD_Bridge_removeSessionsPtr& callba
             cookies = getCookies();
         }
         tasks.push_back(new RemoveSessionsNotify(mListeners, removed, cookies));
+        tasks.push_back(new RemoveSessionControllerTask(mObjAdapter, removed, mLogger));
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_removeSessionsPtr>(callback, removed));
         tasks.push_back(new DisconnectTelephonyEventsTask(this, sessions, mLogger));
         tasks.push_back(new CheckShutdown(this, mPrx));
@@ -1654,6 +1701,7 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
         removedSessions.push_back(sessionToReplace);
 
         tasks.push_back(new RemoveSessionsNotify(mListeners, removeTracker, cookies));
+        tasks.push_back(new RemoveSessionControllerTask(mObjAdapter, removeTracker, mLogger));
         tasks.push_back(new UnplugMedia(this));
         tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, newSessions, tracker));
         tasks.push_back(new AddToListeners(mListeners, tracker, cookies));

commit 116b1453ed53d06a71e0f96ab553f11bb4f264a5
Merge: c473f37 e517807
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Dec 30 14:53:37 2011 -0600

    Merge branch 'master' of git.asterisk.org:asterisk-scf/release/bridging


commit 934164aaf68112a21e589db5df578eecaee8483c
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Dec 22 12:54:00 2011 -0330

    - Fix up some logging messages.
    
    - Null handle checks in some of the tasks (exceptions were showing up in
      the test suite.
    
    - Quick hack for setting log level by confiugration.. the component's
      logger isn't being used, instead the file scoped copy is.. .wrong! Still,
      didn't change that.. enough unrelated changes made in this commit already.
    
    - A lot of stuff was not calling removeState when it was going away.
    
    - The test suite doesn't really do replication correctly.. which might be
      part of the problem.

diff --git a/config/test_bridging.conf b/config/test_bridging.conf
index 5ec14f2..8e7ead3 100644
--- a/config/test_bridging.conf
+++ b/config/test_bridging.conf
@@ -82,6 +82,7 @@ TestBridge.ServiceAdapter.ThreadPool.Size=2
 TestBridge.BackplaneAdapter.Endpoints=default -h 127.0.0.1 -p 57001
 TestBridge.BackplaneAdapter.ThreadPool.Size=2
 TestBridge.Standby=false
+TestBridge.LogLevel=0
 
 TestBridge2.InstanceName=TestBridge2
 TestBridge2.BridgeManagerObjectId=TestBridgeManager2
@@ -90,6 +91,9 @@ TestBridge2.ServiceAdapter.Endpoints=default -h 127.0.0.1 -p 57010
 TestBridge2.ServiceAdapter.ThreadPool.Size=4
 TestBridge2.BackplaneAdapter.Endpoints=default -h 127.0.0.1 -p 57011
 TestBridge2.BackplaneAdapter.ThreadPool.Size=4
+TestBridge2.LogLevel=0
+#Ice.Trace.Network=1
+#Ice.Trace.Protocol=1
 
 #
 # Configuration for the bridge state replicator.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 5f2c03a..1d10928 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -304,22 +304,34 @@ public:
 protected:
     bool executeImpl()
     {
+        mLogger(Trace) << FUNLOG;
+        if (!mSourceSession)
+        {
+            mLogger(Trace) << FUNLOG <<  " Source session is nil, returning early with true";
+            return true;
+        }
         try
         {
-            mLogger(Trace) << FUNLOG;
 
             // Forward the ConnectedLine to each bridged session.
             SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
             for(SessionSeq::iterator i = sessions.begin();
                 i != sessions.end(); ++i)
             {
-                if ((*i)->ice_getIdentity() == mSourceSession->ice_getIdentity())
+                if (!(*i) || (*i)->ice_getIdentity() == mSourceSession->ice_getIdentity())
                 {
                     continue;
                 }
 
                 SessionWrapperPtr destSessionWrapper = mBridge->getSessions()->getSession(*i);
-                forward(destSessionWrapper, mRedirections);
+                if (destSessionWrapper)
+                {
+                    forward(destSessionWrapper, mRedirections);
+                }
+                else
+                {
+                    mLogger(Debug) << " Destination wrapper for session does not exist, continuing";
+                }
             }
 
         }
@@ -339,31 +351,37 @@ protected:
         RedirectionsPtr destSpecificRedirections = redirections;
 
         PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
-
-        // Allow the ForwardingRedirectionsPartyId hooks to alter the Redirections record. 
-        for(vector<ForwardingRedirectionsPartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingRedirectionsHooks.begin();
-            i != partyIdHooks->forwardingRedirectionsHooks.end(); ++i)
+        if (partyIdHooks)
         {
-            try
+            // Allow the ForwardingRedirectionsPartyId hooks to alter the Redirections record. 
+            for(vector<ForwardingRedirectionsPartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingRedirectionsHooks.begin();
+                i != partyIdHooks->forwardingRedirectionsHooks.end(); ++i)
             {
-                // Apply this hook. 
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingRedirections(mSourceSession,
-                    destinationSession->getSession(),
-                    currentRedirections, destSpecificRedirections);
-
-                if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                try
                 {
-                    currentRedirections = destSpecificRedirections;
+                    // Apply this hook. 
+                    AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingRedirections(mSourceSession,
+                        destinationSession->getSession(),
+                        currentRedirections, destSpecificRedirections);
+
+                    if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                    {
+                        currentRedirections = destSpecificRedirections;
+                    }
+                }
+                catch(const std::exception& e)
+                {
+                    mLogger(Warning) << FUNLOG << " : " << e.what();
                 }
-            }
-            catch(const std::exception& e)
-            {
-                mLogger(Warning) << FUNLOG << " : " << e.what();
             }
         }
 
-        // Forward the info via the SessionController for this session.
-        destinationSession->getSessionController()->updateRedirections(currentRedirections);
+        SessionControllerPrx sessionController = destinationSession->getSessionController();
+        if (sessionController)
+        {
+            // Forward the info via the SessionController for this session.
+            destinationSession->getSessionController()->updateRedirections(currentRedirections);
+        }
     }
 
 private:
@@ -401,10 +419,14 @@ public:
 protected:
     bool executeImpl()
     {
+        mLogger(Trace) << FUNLOG;
+        if (!mSourceSession)
+        {
+            mLogger(Trace) << FUNLOG <<  " Source session is nil, returning early with true";
+            return true;
+        }
         try
         {
-            mLogger(Trace) << FUNLOG;
-
             ConnectedLinePtr currentConnectedLine;
             SessionWrapperPtr sourceWrapper = mBridge->getSessions()->getSession(mSourceSession);
             bool isSet = sourceWrapper->getConnectedLine(currentConnectedLine);
@@ -420,13 +442,20 @@ protected:
             for(SessionSeq::iterator i = sessions.begin();
                 i != sessions.end(); ++i)
             {
-                if ((*i)->ice_getIdentity() == mSourceSession->ice_getIdentity())
+                if (!(*i) || (*i)->ice_getIdentity() == mSourceSession->ice_getIdentity())
                 {
                     continue;
                 }
 
                 SessionWrapperPtr destSessionWrapper = mBridge->getSessions()->getSession(*i);
-                forward(destSessionWrapper, currentConnectedLine);
+                if (destSessionWrapper)
+                {
+                    forward(destSessionWrapper, currentConnectedLine);
+                }
+                else
+                {
+                    mLogger(Debug) << " Destination wrapper for session does not exist, continuing";
+                }
             }
 
         }
@@ -447,30 +476,37 @@ protected:
 
         PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
 
-        // Allow the ForwardingConnectedLinePartyId hooks to alter the ConnectedLine record. 
-        for(vector<ForwardingConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingConnectedLineHooks.begin();
-            i != partyIdHooks->forwardingConnectedLineHooks.end(); ++i)
+        if (partyIdHooks)
         {
-            try
+            // Allow the ForwardingConnectedLinePartyId hooks to alter the ConnectedLine record. 
+            for(vector<ForwardingConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingConnectedLineHooks.begin();
+                i != partyIdHooks->forwardingConnectedLineHooks.end(); ++i)
             {
-                // Apply a hook
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingConnectedLine(mSourceSession,
-                    destinationSession->getSession(),
-                    currentConnectedLine, destSpecificConnectedLine);
-
-                if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                try
                 {
-                    currentConnectedLine = destSpecificConnectedLine;
+                    // Apply a hook
+                    AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingConnectedLine(mSourceSession,
+                        destinationSession->getSession(),
+                        currentConnectedLine, destSpecificConnectedLine);
+
+                    if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                    {
+                        currentConnectedLine = destSpecificConnectedLine;
+                    }
+                }
+                catch (const std::exception& e)
+                {
+                    mLogger(Debug) << FUNLOG << " : " << e.what();
                 }
-            }
-            catch (const std::exception& e)
-            {
-                mLogger(Debug) << FUNLOG << " : " << e.what();
             }
         }
 
-        // Forward the info via the SessionController for this session.
-        destinationSession->getSessionController()->updateConnectedLine(currentConnectedLine);
+        SessionControllerPrx sessionController = destinationSession->getSessionController();
+        if (sessionController)
+        {
+            // Forward the info via the SessionController for this session.
+            destinationSession->getSessionController()->updateConnectedLine(currentConnectedLine);
+        }
     }
 
 private:
@@ -497,22 +533,35 @@ public:
 protected:
     bool executeImpl()
     {
+        mLogger(Trace) << FUNLOG;
+        if (!mSource)
+        {
+            mLogger(Trace) << FUNLOG <<  " Source session is nil, returning early with true";
+            return true;
+        }
+
         try
         {
-            mLogger(Trace) << FUNLOG;
 
             // Forward the Caller to each bridged session.
             SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
             for(SessionSeq::iterator i = sessions.begin();
                 i != sessions.end(); ++i)
             {
-                if ((*i)->ice_getIdentity() == mSource->ice_getIdentity())
+                if (!(*i) || (*i)->ice_getIdentity() == mSource->ice_getIdentity())
                 {
                     continue;
                 }
 
                 SessionWrapperPtr destSessionWrapper = mBridge->getSessions()->getSession(*i);
-                forward(destSessionWrapper, mCallerID);
+                if (destSessionWrapper)
+                {
+                    forward(destSessionWrapper, mCallerID);
+                }
+                else
+                {
+                    mLogger(Debug) << " Destination wrapper for session does not exist, continuing";
+                }
             }
 
         }
@@ -524,7 +573,7 @@ protected:
         return true;
     }
            
-    void forward(const SessionWrapperPtr destinationSession, const CallerPtr& callerID)
+    void forward(const SessionWrapperPtr& destinationSession, const CallerPtr& callerID)
     {
         mLogger(Trace) << FUNLOG;
 
@@ -533,30 +582,38 @@ protected:
 
         PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
 
-        // Allow the ForwardingConnectedLinePartyId hooks to alter the ConnectedLine record. 
-        for(vector<ForwardingCallerPartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingCallerHooks.begin();
-            i != partyIdHooks->forwardingCallerHooks.end(); ++i)
+        if (partyIdHooks)
         {
-            try
+            // Allow the ForwardingConnectedLinePartyId hooks to alter the ConnectedLine record. 
+            for(vector<ForwardingCallerPartyIdHookPrx>::const_iterator i = partyIdHooks->forwardingCallerHooks.begin();
+                i != partyIdHooks->forwardingCallerHooks.end(); ++i)
             {
-                // Apply a hook
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingCaller(mSource,
-                    destinationSession->getSession(),
-                    currentCallerID, destSpecificCallerID);
-
-                if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                try
                 {
-                    currentCallerID = destSpecificCallerID;
+                    // Apply a hook
+                    AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingCaller(mSource,
+                        destinationSession->getSession(),
+                        currentCallerID, destSpecificCallerID);
+
+                    if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                    {
+                        currentCallerID = destSpecificCallerID;
+                    }
+                }
+                catch (const std::exception& e)
+                {
+                    mLogger(Debug) << FUNLOG << " : " << e.what();
                 }
-            }
-            catch (const std::exception& e)
-            {
-                mLogger(Debug) << FUNLOG << " : " << e.what();
             }
         }
-
+        //
         // Forward the info via the SessionController for this session.
-        destinationSession->getSessionController()->updateCallerID(currentCallerID);
+        //
+        SessionControllerPrx sessionController =  destinationSession->getSessionController();
+        if (sessionController)
+        {
+            sessionController->updateCallerID(currentCallerID);
+        }
     }
 
 private:
@@ -589,31 +646,43 @@ protected:
     bool executeImpl()
     {
         mLogger(Trace) << FUNLOG;
+        if (!mSourceSession)
+        {
+            mLogger(Trace) << FUNLOG << "Source session is nil, returning early with true.";
+            return true;
+        }
 
         ConnectedLinePtr currentConnectedLine = mConnectedLine;
         ConnectedLinePtr updatedConnectedLine = mConnectedLine;
         SessionWrapperPtr wrapper = mBridge->getSessions()->getSession(mSourceSession);
 
-        PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
+        if (!wrapper)
+        {
+            mLogger(Debug) << "Unable to find matching session for, returning early with true.";
+        }
 
-        // Allow the ReceivedConnectedLinePartyId hooks to alter the ConnectedLine record. 
-        for(vector<ReceivedConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->receivedConnectedLineHooks.begin();
-            i != partyIdHooks->receivedConnectedLineHooks.end(); ++i)
+        PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
+        if (partyIdHooks)
         {
-            try
+            // Allow the ReceivedConnectedLinePartyId hooks to alter the ConnectedLine record. 
+            for(vector<ReceivedConnectedLinePartyIdHookPrx>::const_iterator i = partyIdHooks->receivedConnectedLineHooks.begin();
+                i != partyIdHooks->receivedConnectedLineHooks.end(); ++i)
             {
-                // Apply this hook. 
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyReceivedConnectedLine(mSourceSession,
-                    currentConnectedLine, updatedConnectedLine);
-
-                if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                try
                 {
-                    currentConnectedLine = updatedConnectedLine;
+                    // Apply this hook. 
+                    AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyReceivedConnectedLine(mSourceSession,
+                        currentConnectedLine, updatedConnectedLine);
+
+                    if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
+                    {
+                        currentConnectedLine = updatedConnectedLine;
+                    }
+                }
+                catch (const std::exception& e)
+                {
+                    mLogger(Debug) << FUNLOG << " : " << e.what();
                 }
-            }
-            catch (const std::exception& e)
-            {
-                mLogger(Debug) << FUNLOG << " : " << e.what();
             }
         }
 
@@ -1497,7 +1566,6 @@ void BridgeImpl::shutdown(const Ice::Current& current)
         update = createUpdate();
     }
     pushUpdate(update);
-    update = 0;
     {
         //
         // Currently the slice defines the response "Normal Clearing" as the default
@@ -1513,12 +1581,24 @@ void BridgeImpl::shutdown(const Ice::Current& current)
         //
         // Remove references to the session listener implementation.
         //
-        update = createUpdate();
         mObjAdapter->remove(mSessionListenerPrx->ice_getIdentity());
         mSessionListener = 0;
     }
+    
+    try
+    {
+        if (replicate())
+        {
+            Ice::StringSeq keys;
+            keys.push_back(mState->key);
+            mReplicator->removeState(keys);
+        }
+    }
+    catch (const Ice::Exception&)
+    {
+    }
+
     mSessions = 0;
-    pushUpdate(update);
 }
 
 void BridgeImpl::destroy(const Ice::Current& current)
@@ -1549,6 +1629,19 @@ void BridgeImpl::destroy(const Ice::Current& current)
     // Remove references to the session listener implementation.
     //
     mObjAdapter->remove(mSessionListenerPrx->ice_getIdentity());
+
+    try
+    {
+        if (replicate())
+        {
+            Ice::StringSeq keys;
+            keys.push_back(mState->key);
+            mReplicator->removeState(keys);
+        }
+    }
+    catch (const Ice::Exception&)
+    {
+    }
 }
 
 void BridgeImpl::addListener(const BridgeListenerPrx& listener, const Ice::Current& current)
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 18fd3da..a317d0c 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -124,7 +124,7 @@ public:
 
     void createBridgeReplica(const BridgeStateItemPtr& bridgeState);
 
-    void removeBridge(const BridgeStateItemPtr& bridgeState);
+    void removeBridge(const string& bridgeState);
 
 private:
 
@@ -561,13 +561,13 @@ void BridgeManagerImpl::createBridgeReplica(const BridgeStateItemPtr& state)
     mBridges.push_back(info);
 }
 
-void BridgeManagerImpl::removeBridge(const BridgeStateItemPtr& state)
+void BridgeManagerImpl::removeBridge(const string& bridgeId)
 {
     mLogger(Trace) << FUNLOG;
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     for (vector<BridgeInfo>::iterator i = mBridges.begin(); i != mBridges.end(); ++i)
     {
-        if (i->servant->id() == state->bridgeId)
+        if (i->servant->id() == bridgeId)
         {
             i->servant->destroyImpl();
             mBridges.erase(i);
diff --git a/src/BridgeManagerImpl.h b/src/BridgeManagerImpl.h
index b1c4cc9..e9a8b7e 100644
--- a/src/BridgeManagerImpl.h
+++ b/src/BridgeManagerImpl.h
@@ -56,7 +56,7 @@ public:
 
     virtual void createBridgeReplica(const AsteriskSCF::Replication::BridgeService::V1::BridgeStateItemPtr& bridgeState) = 0;
 
-    virtual void removeBridge(const AsteriskSCF::Replication::BridgeService::V1::BridgeStateItemPtr& bridgeState) = 0;
+    virtual void removeBridge(const std::string& bridgeId) = 0;
 };
 
 typedef IceUtil::Handle<BridgeManagerServant> BridgeManagerServantPtr;
diff --git a/src/BridgeReplicatorStateListenerI.cpp b/src/BridgeReplicatorStateListenerI.cpp
index fcbd5bf..7dae181 100644
--- a/src/BridgeReplicatorStateListenerI.cpp
+++ b/src/BridgeReplicatorStateListenerI.cpp
@@ -41,18 +41,35 @@ public:
     {
     }
 
+    void removeBridgeItem(const string& bridgeKey, const string& item, const string& sliceType)
+    {
+        IceUtil::Mutex::Lock lock(mMutex);
+        mLogger(Trace) << " removing bridge item id " << item << " (" << sliceType << ") from bridge " << bridgeKey;
+        mBridgeItemMap[bridgeKey].erase(item);
+        if (mBridgeItemMap[bridgeKey].empty())
+        {
+            mManager->removeBridge(bridgeKey);
+        }
+    }
+
     void stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current& current)
     {
         for (Ice::StringSeq::const_iterator k = itemKeys.begin(); k != itemKeys.end(); ++k)
         {
-
-            map<string, ReplicatedStateItemPtr>::iterator entry =  mItems.find((*k));
-            if (entry != mItems.end())
+            ReplicatedStateItemPtr item;
+            {
+                IceUtil::Mutex::Lock lock(mMutex);
+                map<string, ReplicatedStateItemPtr>::iterator entry = mItems.find((*k));
+                if (entry != mItems.end())
+                {
+                    item = entry->second;
+                    mItems.erase(entry);
+                }
+            }
+            if (item)
             {
-                ReplicatedStateItemPtr item = entry->second;
                 mLogger(Trace) << " received removal of " << (*k) << ": a " << item->ice_id();
 
-                mItems.erase(entry);
                 BridgedSessionPtr bridgedSessionItem = BridgedSessionPtr::dynamicCast(item);
                 if (bridgedSessionItem)
                 {
@@ -68,6 +85,7 @@ public:
                             // Keep the session list clean.
                             //
                             found = true;
+                            removeBridgeItem(bridgedSessionItem->bridgeId, bridgedSessionItem->key, item->ice_id());
                         }
                         //
                         // We could break here if we could be sure that there were no other updates.
@@ -85,6 +103,7 @@ public:
                         if ((*b) && (*b)->id() == bridgeListener->bridgeId)
                         {
                             (*b)->removeListener(bridgeListener);
+                            removeBridgeItem(bridgeListener->bridgeId, bridgeListener->key, item->ice_id());
                         }
                         //
                         // We could break here if we could be sure that there were no other updates.
@@ -100,13 +119,23 @@ public:
                     {
                         dumpState(cerr, bridgeItem, current.adapter->getCommunicator());
                     }
-                    mManager->removeBridge(bridgeItem);
+                    if (mBridgeItemMap[bridgeItem->bridgeId].empty())
+                    {
+                        mManager->removeBridge(bridgeItem->bridgeId);
+                    }
                     continue;
                 }
 
                 //
                 // Session pairings are cleaned up by way of sessions going away.
                 //
+                SessionPairingPtr pairing = SessionPairingPtr::dynamicCast(item);
+                if (pairing)
+                {
+                    removeBridgeItem(pairing->bridgeKey, pairing->key, item->ice_id());
+                    continue;
+                }
+
 
                 ///
                 // The bridge manager isn't really removable.
@@ -121,30 +150,33 @@ public:
         {
             mLogger(Trace) << " received update " << (*i)->serial << " for " << (*i)->key << " (a " <<
                 (*i)->ice_id() << ")";
-            map<string, ReplicatedStateItemPtr>::iterator entry =  mItems.find((*i)->key);
             ReplicatedStateItemPtr existingItem;
-            if (entry != mItems.end())
             {
-                //
-                // Note: Another serial number situation to consider is two updates of the same key with
-                // the same serial number.
-                //
+                IceUtil::Mutex::Lock lock(mMutex);
+                map<string, ReplicatedStateItemPtr>::iterator entry =  mItems.find((*i)->key);
+                if (entry != mItems.end())
+                {
+                    //
+                    // Note: Another serial number situation to consider is two updates of the same key with
+                    // the same serial number.
+                    //
 
-                //
-                // Look at serial numbers and indicate an out of sequence update. We should
-                // ignore out of sequence updates.
-                //
-                if ((entry->second->serial > (*i)->serial) && (*i)->serial > SerialCounterStart)
+                    //
+                    // Look at serial numbers and indicate an out of sequence update. We should
+                    // ignore out of sequence updates.
+                    //
+                    if ((entry->second->serial > (*i)->serial) && (*i)->serial > SerialCounterStart)
+                    {
+                        mLogger(Error) << "Update serial number for " << (*i)->key << " out of sequence! " << 
+                            (*i)->serial << " updating " << entry->second->serial;
+                        continue;
+                    }
+                    existingItem = entry->second;
+                }
+                else
                 {
-                    mLogger(Error) << "Update serial number for " << (*i)->key << " out of sequence! " << 
-                        (*i)->serial << " updating " << entry->second->serial;
-                    continue;
+                    mItems[(*i)->key] = *i;
                 }
-                existingItem = entry->second;
-            }
-            else
-            {
-                mItems[(*i)->key] = *i;
             }
 
             BridgeManagerStateItemPtr managerItem = BridgeManagerStateItemPtr::dynamicCast((*i));
@@ -187,7 +219,7 @@ public:
                 {
                     if (existingItem)
                     {
-                        mLogger(Error) << "Replica listener has a bridge object that the bridge manager "
+                        mLogger(Warning) << "Replica listener has a bridge object that the bridge manager "
                             "does not know about. This likely indicates an error and should be investigated.";
                     }
                     mManager->createBridgeReplica(bridgeItem);
@@ -210,6 +242,7 @@ public:
                         // Keep the session list clean.
                         //
                         found = true;
+                        mBridgeItemMap[bridgedSessionItem->bridgeId][bridgedSessionItem->key] = bridgedSessionItem;
                     }
                     //
                     // We could break here if we could be sure that there were no other updates.
@@ -217,7 +250,8 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received an update for a session on a bridge that does not exist!";
+                    mLogger(Error) << "received a " << bridgedSessionItem->ice_id() << " (id: " << bridgedSessionItem->key << ")"
+                                   << " update for a session on a bridge that does not exist: " << bridgedSessionItem->bridgeId;
                 }
              
                 continue;
@@ -241,6 +275,7 @@ public:
                         // Keep the session list clean.
                         //
                         found = true;
+                        mBridgeItemMap[sessionPairing->bridgeKey][sessionPairing->key] = sessionPairing;
                     }
                     //
                     // We could break here if we could be sure that there were no other updates.
@@ -248,7 +283,8 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received an update for a session on a bridge that does not exist!";
+                    mLogger(Error) << "received a " << sessionPairing->ice_id() << " (id: " << sessionPairing->key << ")"
+                                   << " update for a session on a bridge that does not exist: " << sessionPairing->bridgeKey;
                 }
              
                 continue;
@@ -264,6 +300,7 @@ public:
                     if ((*b) && (*b)->id() == bridgeListener->bridgeId)
                     {
                         (*b)->addListener(bridgeListener);
+                        mBridgeItemMap[bridgeListener->bridgeId][bridgeListener->key] = bridgeListener;
                     }
                     //
                     // We could break here if we could be sure that there were no other updates.
@@ -271,21 +308,23 @@ public:
                 }
                 if (!found)
                 {
-                    mLogger(Error) << "received an update for a session on a bridge that does not exist!";
+                    mLogger(Error) << "received a " << bridgeListener->ice_id() << " (id: " << bridgeListener->key << ")"
+                                   << " update for a session on a bridge that does not exist: " << bridgeListener->bridgeId;
                 }
              
                 continue;
             }
 
-            mLogger(Info) << "Bridge replicator service received an unrecognized replication item.";
+            mLogger(Error) << "Bridge replicator service received an unrecognized replication item: " << (*i)->ice_id();
         }
     }
 
 private:
-
+    IceUtil::Mutex mMutex;
     map<string, ReplicatedStateItemPtr> mItems;
     Logger mLogger;
     BridgeManagerServantPtr mManager;
+    map<string, map<string, ReplicatedStateItemPtr> > mBridgeItemMap;
 };
 
 }
diff --git a/src/Component.cpp b/src/Component.cpp
index 331e6af..2557694 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -57,7 +57,9 @@ public:
     Component() : 
         AsteriskSCF::Component::Component(lg, 
                                           "BridgeService"),
-        mListeningToReplicator(false)   {}
+        mListeningToReplicator(false)
+    {
+    }
 
 private:
     // Optional base Component notification overrides. 
@@ -120,6 +122,16 @@ void Component::onActivated()
 void Component::onPreInitialize()
 {
     lg(Debug) << "Launching AsteriskSCF Session-Oriented Bridging Service " << getName();
+    Ice::Int logLevel = getCommunicator()->getProperties()->getPropertyAsIntWithDefault(getName() + ".LogLevel", static_cast<Ice::Int>(Debug));
+    if (logLevel >= 0  && logLevel <= static_cast<Ice::Int>(AsteriskSCF::System::Logging::Off))
+    {
+        lg.setLevel(static_cast<AsteriskSCF::System::Logging::Level>(logLevel));
+        mLogger.setLevel(static_cast<AsteriskSCF::System::Logging::Level>(logLevel));
+    }
+    else
+    {
+        mLogger(Error) << "Configuration attempted to set log level to an invalid value.";
+    }
 }
 
 /** 
diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index f1a39aa..81dfbad 100755
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -233,7 +233,6 @@ public:
     //
     void destroy()
     {
-        SessionPairingPtr newState;
 	vector<OutgoingPairing> outgoing;
 	vector<IncomingPairing> incoming;
         {
@@ -243,9 +242,14 @@ public:
 	    incoming = mIncoming;
             mIncoming.clear();
             mConnected = false;
-            newState = createUpdate();
         }
-        pushUpdate(newState);
+        if (mReplicator)
+        {
+            vector<string> keys;
+            keys.push_back(mKey);
+            mReplicator->removeState(keys);
+            mReplicator = AsteriskSCF::BridgeService::ReplicatorSmartPrx();
+        }
         mLogger(Trace) << FUNLOG << ": unplugging sinks and sources";
 
         //
diff --git a/src/SessionCollection.cpp b/src/SessionCollection.cpp
index bd3f1ff..9b6c815 100644
--- a/src/SessionCollection.cpp
+++ b/src/SessionCollection.cpp
@@ -202,8 +202,11 @@ void SessionCollection::replicaUpdate(const BridgedSessionPtr& session)
 
 void SessionCollection::removeSession(const BridgedSessionPtr& session)
 {
+    SessionWrapperPtr removedSession;
+    {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     SessionMap::iterator i = mMap.find(session->key);
+    removedSession = i->second;
     if (i != mMap.end())
     {
         mMap.erase(i);
@@ -214,4 +217,23 @@ void SessionCollection::removeSession(const BridgedSessionPtr& session)
     {
 	mSplicer->disableMixing();
     }
+    }
+    if (removedSession)
+    {
+        removedSession->destroy();
+    }
+}
+
+void SessionCollection::destroy()
+{
+    SessionMap copy;
+    {
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        copy = mMap;
+        mMap.clear();
+    }
+    for (SessionMap::iterator i = copy.begin(); i != copy.end();)
+    {
+        i->second->destroy();
+    }
 }
diff --git a/src/SessionCollection.h b/src/SessionCollection.h
index d758e85..92460a5 100644
--- a/src/SessionCollection.h
+++ b/src/SessionCollection.h
@@ -132,6 +132,8 @@ public:
     void replicaUpdate(const AsteriskSCF::Replication::BridgeService::V1::BridgedSessionPtr& bridgedSession);
 
     void removeSession(const AsteriskSCF::Replication::BridgeService::V1::BridgedSessionPtr& bridgedSession);
+
+    void destroy();
     
 private:
 
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index c6571e3..21778b2 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -217,6 +217,12 @@ public:
                         mBridgePrx->shutdown();
                     }
                 }
+                catch (const Ice::ObjectNotExistException&)
+                {
+                    //
+                    // The bridge has already gone away... this is okay.
+                    //
+                }
                 catch (const Ice::Exception& ex)
                 {
                     mLogger(Error) << "Unexpected exception when initiating auto shutdown: " << ex.what();
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index 11b59b8..f8dc5df 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -491,6 +491,8 @@ void SessionWrapper::setupMedia()
     // basic method.  If we need to prevent this from recurring, then it needs
     // to be in the caller's logic, not here.
     //
+    // TODO: State check
+    //
     mConnector = 0;
     mSplicer->connect(this, mSession->session);
 }
@@ -500,6 +502,9 @@ void SessionWrapper::setConnector(const MediaConnectorPtr& connector)
     mLogger(Trace) << FUNLOG << " for " << mId;
     {
         boost::unique_lock<boost::shared_mutex> lock(mLock);
+        //
+        // TODO: state check?
+        //
         mConnector = connector;
     }
 }
@@ -509,6 +514,9 @@ void SessionWrapper::updateMedia(const SessionPairingPtr& pairings)
     mLogger(Trace) << FUNLOG << " for " << mId;
     boost::unique_lock<boost::shared_mutex> lock(mLock);
 
+    //
+    // TODO: shouldn't the state be checked here?
+    //
     mSplicer->update(pairings);
 
     if (mConnector)
@@ -567,10 +575,15 @@ void SessionWrapper::destroy()
             //
             unplugMedia();
             mSession->currentState = Done;
-            newState = createUpdate();
         }
     }
-    pushUpdate(newState);
+    if (mReplicator)
+    {
+        vector<string> keys;
+        keys.push_back(mSession->key);
+        mReplicator->removeState(keys);
+        mReplicator = AsteriskSCF::BridgeService::ReplicatorSmartPrx();
+    }
 }
 
 bool SessionWrapper::isDestroyed()
@@ -644,7 +657,6 @@ bool SessionWrapper::getConnectedLine(ConnectedLinePtr& connectedLine)
     return true;
 }
 
-
 AsteriskSCF::Replication::BridgeService::V1::BridgedSessionState SessionWrapper::setState(const AsteriskSCF::Replication::BridgeService::V1::BridgedSessionState newState)
 {
     mLogger(Trace) << FUNLOG << ": updating state " << mId;
diff --git a/src/SessionWrapper.h b/src/SessionWrapper.h
index a03d78b..8bec9f1 100644
--- a/src/SessionWrapper.h
+++ b/src/SessionWrapper.h
@@ -158,7 +158,7 @@ public:
      * @return true if the connectedLine parameter was set. 
      */
     bool getConnectedLine(AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr& connectedLine);
-    
+
 private:
 
     mutable boost::shared_mutex mLock;
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 6fe199a..68d6199 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -1474,6 +1474,10 @@ public:
                 BOOST_FAIL("Unexpected exception");
             }
         }
+        catch (const Ice::Exception& ex)
+        {
+            BOOST_FAIL(ex.what());
+        }
         catch (...)
         {
             BOOST_FAIL("Unexpected exception");

commit e5178070c8f1620af13bf68f4f3939de20ed9ab1
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Dec 21 12:18:32 2011 -0330

    * Moved some logging to Trace level to clean up test output.
    
    * Fixed some catch() blocks in BridgeImpl.cpp that were catching
      std::exception by value which slices the exception and removes the actual
      exception info. Test output currently indicates that a null handle
      exception is being thrown.. which is a little disconcerting.

diff --git a/src/BridgeCreationExtensionPointImpl.cpp b/src/BridgeCreationExtensionPointImpl.cpp
index 6a4ab31..172321f 100755
--- a/src/BridgeCreationExtensionPointImpl.cpp
+++ b/src/BridgeCreationExtensionPointImpl.cpp
@@ -41,7 +41,7 @@ namespace
                 find_if(mHooks.begin(), mHooks.end(), IdentityComparePredicate<BridgeCreationHookPrx>(newHook));
             if (i != mHooks.end())
             {
-                mLogger(Debug) << "refreshing creation hook " << newHook << " on " 
+                mLogger(Trace) << "refreshing creation hook " << newHook << " on " 
                     << objectIdFromCurrent(current);
                 //
                 // Refresh the proxy if it is already in the vector.
@@ -50,7 +50,7 @@ namespace
             }
             else
             {
-                mLogger(Debug) << "adding creation hook " << newHook << " on " 
+                mLogger(Trace) << "adding creation hook " << newHook << " on " 
                     << objectIdFromCurrent(current);
                 mHooks.push_back(newHook);
             }
@@ -59,7 +59,7 @@ namespace
         void removeHook(const BridgeCreationHookPrx& hookToRemove, const Ice::Current& current)
         {
             UniqueLock lock(mLock);
-            mLogger(Debug) << "removing creation hook " << hookToRemove << " on " 
+            mLogger(Trace) << "removing creation hook " << hookToRemove << " on " 
                 << objectIdFromCurrent(current);
             mHooks.erase(remove_if(mHooks.begin(), mHooks.end(), 
                     IdentityComparePredicate<BridgeCreationHookPrx>(hookToRemove)), mHooks.end());
@@ -68,13 +68,13 @@ namespace
         void clearHooks(const Ice::Current& current)
         {
             UniqueLock lock(mLock);
-            mLogger(Debug) << "clearing hooks from " << objectIdFromCurrent(current);
+            mLogger(Trace) << "clearing hooks from " << objectIdFromCurrent(current);
             mHooks.clear();
         }
 
         BridgeCreationHookDataPtr runHooks(const BridgeCreationHookDataPtr& originalData)
         {
-            mLogger(Debug) << "executing hooks";
+            mLogger(Trace) << "executing hooks";
             BridgeCreationHookSeq hooks = getHooks();
             BridgeCreationHookSeq deadHooks;
             BridgeCreationHookDataPtr tokenData = BridgeCreationHookDataPtr::dynamicCast(originalData->ice_clone());
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 3dd19e4..5f2c03a 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -306,7 +306,7 @@ protected:
     {
         try
         {
-            mLogger(Debug) << FUNLOG;
+            mLogger(Trace) << FUNLOG;
 
             // Forward the ConnectedLine to each bridged session.
             SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
@@ -323,7 +323,7 @@ protected:
             }
 
         }
-        catch (const std::exception e)
+        catch (const std::exception& e)
         {
             mLogger(Debug) << FUNLOG << " : " << e.what();
         }
@@ -333,7 +333,7 @@ protected:
            
     void forward(const SessionWrapperPtr destinationSession, const RedirectionsPtr& redirections)
     {
-        mLogger(Debug) << FUNLOG;
+        mLogger(Trace) << FUNLOG;
 
         RedirectionsPtr currentRedirections = redirections;
         RedirectionsPtr destSpecificRedirections = redirections;
@@ -403,7 +403,7 @@ protected:
     {
         try
         {
-            mLogger(Debug) << FUNLOG;
+            mLogger(Trace) << FUNLOG;
 
             ConnectedLinePtr currentConnectedLine;
             SessionWrapperPtr sourceWrapper = mBridge->getSessions()->getSession(mSourceSession);
@@ -430,7 +430,7 @@ protected:
             }
 
         }
-        catch (const std::exception e)
+        catch (const std::exception& e)
         {
             mLogger(Debug) << FUNLOG << " : " << e.what();
         }
@@ -440,7 +440,7 @@ protected:
            
     void forward(const SessionWrapperPtr destinationSession, const ConnectedLinePtr& connectedLine)
     {
-        mLogger(Debug) << FUNLOG;
+        mLogger(Trace) << FUNLOG;
 
         ConnectedLinePtr currentConnectedLine = connectedLine;
         ConnectedLinePtr destSpecificConnectedLine = connectedLine;
@@ -463,7 +463,7 @@ protected:
                     currentConnectedLine = destSpecificConnectedLine;
                 }
             }
-            catch (const std::exception e)
+            catch (const std::exception& e)
             {
                 mLogger(Debug) << FUNLOG << " : " << e.what();
             }
@@ -499,7 +499,7 @@ protected:
     {
         try
         {
-            mLogger(Debug) << FUNLOG;
+            mLogger(Trace) << FUNLOG;
 
             // Forward the Caller to each bridged session.
             SessionSeq sessions = mBridge->getSessions()->getSessionSeq();
@@ -516,7 +516,7 @@ protected:
             }
 
         }
-        catch (const std::exception e)
+        catch (const std::exception& e)
         {
             mLogger(Debug) << FUNLOG << " : " << e.what();
         }
@@ -526,7 +526,7 @@ protected:
            
     void forward(const SessionWrapperPtr destinationSession, const CallerPtr& callerID)
     {
-        mLogger(Debug) << FUNLOG;
+        mLogger(Trace) << FUNLOG;
 
         CallerPtr currentCallerID = callerID;
         CallerPtr destSpecificCallerID = callerID;
@@ -549,7 +549,7 @@ protected:
                     currentCallerID = destSpecificCallerID;
                 }
             }
-            catch (const std::exception e)
+            catch (const std::exception& e)
             {
                 mLogger(Debug) << FUNLOG << " : " << e.what();
             }
@@ -588,7 +588,7 @@ public:
 protected:
     bool executeImpl()
     {
-        mLogger(Debug) << FUNLOG;
+        mLogger(Trace) << FUNLOG;
 
         ConnectedLinePtr currentConnectedLine = mConnectedLine;
         ConnectedLinePtr updatedConnectedLine = mConnectedLine;
@@ -611,7 +611,7 @@ protected:
                     currentConnectedLine = updatedConnectedLine;
                 }
             }
-            catch (const std::exception e)
+            catch (const std::exception& e)
             {
                 mLogger(Debug) << FUNLOG << " : " << e.what();
             }
@@ -1300,7 +1300,7 @@ void BridgeImpl::updateConnectedLine(const SessionWrapperPtr& sourceSession, con
         ExecutorPtr runner(new Executor(tasks, mLogger));
         runner->start();
     }
-    catch (const std::exception e)
+    catch (const std::exception& e)
     {
         mLogger(Debug) << FUNLOG << " : " << e.what();
     }
@@ -1321,7 +1321,7 @@ void BridgeImpl::updateRedirections(const SessionWrapperPtr& sourceSession, cons
         ExecutorPtr runner(new Executor(tasks, mLogger));
         runner->start();
     }
-    catch (const std::exception e)
+    catch (const std::exception& e)
     {
         mLogger(Debug) << FUNLOG << " : " << e.what();
     }
@@ -1816,7 +1816,7 @@ void BridgeImpl::activate(const BridgePrx& proxy, const std::string& bridgeId)
     mState->key = bridgeId;
     mState->bridgeId = bridgeId;
     string listenerId = bridgeId + ".sessionListener"; 
-    mLogger(Debug) << FUNLOG << " : activating session listener with " << listenerId;
+    mLogger(Trace) << FUNLOG << " : activating session listener with " << listenerId;
     mActivated = true;
     mSessionListenerPrx =
         SessionListenerPrx::uncheckedCast(
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 4ec541d..18fd3da 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -267,7 +267,10 @@ void BridgeManagerImpl::createBridge_async(const AMD_BridgeManager_createBridgeP
             listeners = hookData->listeners;
             initialSessions = hookData->initialSessions;
             info.decoratingPrx = hookData->bridge;
-            dump(mLogger, hookData);
+            if (mLogger.isEnabledFor(Trace))
+            {
+                dump(mLogger, hookData);
+            }
         }
         
         //
diff --git a/src/BridgeReplicatorStateListenerI.cpp b/src/BridgeReplicatorStateListenerI.cpp
index ecdbf20..fcbd5bf 100644
--- a/src/BridgeReplicatorStateListenerI.cpp
+++ b/src/BridgeReplicatorStateListenerI.cpp
@@ -50,7 +50,7 @@ public:
             if (entry != mItems.end())
             {
                 ReplicatedStateItemPtr item = entry->second;
-                mLogger(Debug) << " received removal of " << (*k) << ": a " << item->ice_id();
+                mLogger(Trace) << " received removal of " << (*k) << ": a " << item->ice_id();
 
                 mItems.erase(entry);
                 BridgedSessionPtr bridgedSessionItem = BridgedSessionPtr::dynamicCast(item);
@@ -96,7 +96,10 @@ public:
                 BridgeStateItemPtr bridgeItem = BridgeStateItemPtr::dynamicCast(item);
                 if (bridgeItem)
                 {
-                    dumpState(cerr, bridgeItem, current.adapter->getCommunicator());
+                    if (mLogger.isEnabledFor(Trace))
+                    {
+                        dumpState(cerr, bridgeItem, current.adapter->getCommunicator());
+                    }
                     mManager->removeBridge(bridgeItem);
                     continue;
                 }
@@ -161,7 +164,10 @@ public:
             BridgeStateItemPtr bridgeItem = BridgeStateItemPtr::dynamicCast((*i));
             if (bridgeItem)
             {
-                dumpState(cerr, bridgeItem, current.adapter->getCommunicator());
+                if (mLogger.isEnabledFor(Trace))
+                {
+                    dumpState(cerr, bridgeItem, current.adapter->getCommunicator());
+                }
                 vector<BridgeServantPtr> bridges = mManager->getBridges();
                 bool found = false;
                 for (vector<BridgeServantPtr>::iterator b = bridges.begin(); b != bridges.end(); ++b)
diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index 27411cc..f1a39aa 100755
--- a/src/MediaSplicer.cpp
... 41 lines suppressed ...


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list