[asterisk-scf-commits] asterisk-scf/integration/file_session_gateway.git branch "first_crack_for_review" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Jan 5 09:16:18 CST 2012


branch "first_crack_for_review" has been updated
       via  4f1b50f403608d399009b81160fb61719c16d0d9 (commit)
      from  6cb018ac22293cd48c76bc5f49e681e5b876bd80 (commit)

Summary of changes:
 src/Configuration.cpp       |    2 +-
 src/EndpointLocator.cpp     |    7 -----
 src/ReplicationListener.cpp |   35 ++++++++------------------
 src/Session.cpp             |   57 ++++++++++++++++++++++---------------------
 4 files changed, 41 insertions(+), 60 deletions(-)


- Log -----------------------------------------------------------------
commit 4f1b50f403608d399009b81160fb61719c16d0d9
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jan 5 11:45:28 2012 -0330

    Incorporating some review feedback.

diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index bceb74f..7d19a97 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -62,7 +62,7 @@ EndpointSpecificationPtr createSpecificationFromGroup(const EndpointGroupPtr& gr
     newSpec->id = group->name;
     newSpec->name = group->name;
 
-    ConfigurationItemDict::iterator propertyIter = group->configurationItems.find(EndpointDestinationItem);
+    ConfigurationItemDict::const_iterator propertyIter = group->configurationItems.find(EndpointDestinationItem);
     if (propertyIter != group->configurationItems.end())
     {
         EndpointDestinationNamePtr destination = EndpointDestinationNamePtr::dynamicCast(propertyIter->second);
diff --git a/src/EndpointLocator.cpp b/src/EndpointLocator.cpp
index 2b7ebbd..cb1eb59 100644
--- a/src/EndpointLocator.cpp
+++ b/src/EndpointLocator.cpp
@@ -41,13 +41,6 @@ namespace FileSessionGtw
 {
 
 //
-// TODO/BUG: Okay, so there is a bug where the locator registry isn't
-// getting updated properly.  While AMI would work for most situations, we
-// may as well reuse the RegisterEndpointLocator thread implementation
-// since it is robust in ConnectionLostException situations.
-//
-
-//
 // TODO: thread pool
 //
 class RegisterEndpointLocator : public IceUtil::Thread
diff --git a/src/ReplicationListener.cpp b/src/ReplicationListener.cpp
index 6842afc..d2c8079 100644
--- a/src/ReplicationListener.cpp
+++ b/src/ReplicationListener.cpp
@@ -84,27 +84,16 @@ public:
             SessionStatePtr sessionState = SessionStatePtr::dynamicCast(*iter);
             if (sessionState)
             {
-                ReplicationAdapterPtr obj;
+                boost::mutex::scoped_lock lock(mLock);
+                ReplicatedObjectAdapterMap::iterator findIter = mObjectMap.find((*iter)->key);
+                if (findIter != mObjectMap.end())
                 {
-                    boost::mutex::scoped_lock lock(mLock);
-                    ReplicatedObjectAdapterMap::iterator findIter = mObjectMap.find((*iter)->key);
-                    if (findIter != mObjectMap.end())
+                    ReplicationAdapterPtr obj = findIter->second;
+                    if (obj)
                     {
-                        obj = findIter->second;
+                        obj->update(*iter);
                     }
                 }
-                //
-                // You may notice that there is a potential race condition here. The lock on the map
-                // is released before update is called. This could result in out of order updates, or even
-                // destroy being called before we get here. That is really outside of the scope
-                // of what the listener can do, so the adapter or the related object will have to take
-                // care fo the implications of same. Such is the world of replicated state without
-                // an actual queue.
-                //
-                if (obj)
-                {
-                    obj->update(*iter);
-                }
                 else
                 {
                     //
@@ -112,7 +101,6 @@ public:
                     //
                     mLogger(Error) << "Received a session update for a non-existent session.";
                 }
-
             }
             else
             {
@@ -120,20 +108,19 @@ public:
                 // If it is not a session replication item, assume it to be and endpoint related
                 // item.
                 //
-                ReplicationAdapterPtr obj;
 
                 {
                     boost::mutex::scoped_lock lock(mLock);
                     ReplicatedObjectAdapterMap::iterator findIter = mObjectMap.find((*iter)->key);
                     if (findIter != mObjectMap.end())
                     {
-                        obj = findIter->second;
+                        ReplicationAdapterPtr obj = findIter->second;
+                        if (obj)
+                        {
+                            obj->update(*iter);
+                        }
                     }
                 }
-                if (obj)
-                {
-                    obj->update(*iter);
-                }
             }
         }
     }
diff --git a/src/Session.cpp b/src/Session.cpp
index cc29766..7041de7 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -185,42 +185,43 @@ public:
             stateCheck();
             {
                 ConnectIndicationPtr connect = ConnectIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Connect indication received by " << mId;
-
-                //
-                // Start playback/recording if not already started.
-                //
-                start(current);
-            }
-            {
-                FlashIndicationPtr flash = FlashIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Flash indication received by " << mId << ", ignored";
-            
+                if (connect)
+                {
+                    mLogger(Trace) << "Connect indication received by " << mId;
+
+                    //
+                    // Start playback/recording if not already started.
+                    //
+                    start(current);
+                    cb->ice_response();
+                    return;
+                }
             }
             {
                 HoldIndicationPtr hold = HoldIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Hold indication received by " << mId;
-                //
-                // Pause playback/recording if started.
-                //
-            }
-            {
-                ProgressIndicationPtr progress = ProgressIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Progress indication received by " << mId;
-            }
-            {
-                RingIndicationPtr ring = RingIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Ring indication received by " << mId << ", ignored";
-            
+                if (hold)
+                {
+                    mLogger(Trace) << "Hold indication received by " << mId;
+                    //
+                    // TODO: pause playback or recording.
+                    //
+                    cb->ice_response();
+                    return;
+                }
             }
             {
                 UnholdIndicationPtr unhold = UnholdIndicationPtr::dynamicCast(indication);
-                mLogger(Trace) << "Unhold indication received by " << mId;
-                //
-                // Resume playback/recording if "on hold".
-                //
+                if (unhold)
+                {
+                    mLogger(Trace) << "Unhold indication received by " << mId;
+                    //
+                    // TODO: resume playback or recording.
+                    //
+                    cb->ice_response();
+                    return;
+                }
             }
-        
+            mLogger(Trace) << "Indication " << indication->ice_id() << " received, ignoring";
             cb->ice_response();
         }
         catch (const Ice::Exception& ex)

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


-- 
asterisk-scf/integration/file_session_gateway.git



More information about the asterisk-scf-commits mailing list