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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 25 14:47:08 CDT 2011


branch "master" has been updated
       via  59387df4b80bb1ccc1b84c13a130979698a2dc1f (commit)
      from  9f78b40761e71cccf0e0e85e0f89235a2f77583f (commit)

Summary of changes:
 src/SessionListener.cpp   |    2 +-
 src/SessionOperations.cpp |   19 +++++++++++++++++--
 src/SessionOperations.h   |   11 +++++++++--
 src/SessionWrapper.cpp    |   16 ++++++++++------
 src/Tasks.h               |   23 +++++++++++++++++------
 5 files changed, 54 insertions(+), 17 deletions(-)


- Log -----------------------------------------------------------------
commit 59387df4b80bb1ccc1b84c13a130979698a2dc1f
Author: Brent Eagles <beagles at digium.com>
Date:   Wed May 25 17:15:13 2011 -0230

    Fix some more session/setup teardown issues and added some logging so its
    possible to track which queues are being failed, destroyed or executing.
    
    Also added an exclusionary form of SessionShutdownOperation to allow
    us to skip a session that has indicated that it is stopped. It would
    work without it, but it saves some extra calls.

diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 7aee4df..5fffe12 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -184,7 +184,7 @@ public:
 	    //
 	    session->shutdown(mListenerPrx, ResponseCodePtr());
 
-            ShutdownSessionOperation shutdownOp(mListenerPrx, stopped->response, mLogger);
+            ShutdownSessionOperation shutdownOp(session->getSession(), mListenerPrx, stopped->response, mLogger);
             mSessions->visitSessions(shutdownOp);
 
             //
diff --git a/src/SessionOperations.cpp b/src/SessionOperations.cpp
index 0ef489a..d8ab630 100644
--- a/src/SessionOperations.cpp
+++ b/src/SessionOperations.cpp
@@ -40,18 +40,33 @@ void ConnectSessionOperation::operator()(const SessionWrapperPtr& s)
     }
 }
 
+ShutdownSessionOperation::ShutdownSessionOperation(const SessionPrx& exclude, const SessionListenerPrx& listener,
+        const ResponseCodePtr& response,
+        const Logger& logger) :
+    mExclude(exclude->ice_getIdentity()),
+    mListener(listener),
+    mResponse(response),
+    mLogger(logger),
+    mSkipExclude(false)
+{
+}
+
 ShutdownSessionOperation::ShutdownSessionOperation(const SessionListenerPrx& listener,
         const ResponseCodePtr& response,
         const Logger& logger) :
     mListener(listener),
     mResponse(response),
-    mLogger(logger)
+    mLogger(logger),
+    mSkipExclude(true)
 {
 }
 
 void ShutdownSessionOperation::operator()(const SessionWrapperPtr& wrapper)
 {
-    wrapper->shutdown(mListener, mResponse);
+    if (mSkipExclude || wrapper->getSession()->ice_getIdentity() != mExclude)
+    {
+        wrapper->shutdown(mListener, mResponse);
+    }
 }
 
 RelayIndication::RelayIndication(const SessionPrx& exclude, const Logger& logger, const IndicationPtr& indication, bool includeConnected) :
diff --git a/src/SessionOperations.h b/src/SessionOperations.h
index cdf4b82..89e6c8b 100644
--- a/src/SessionOperations.h
+++ b/src/SessionOperations.h
@@ -42,15 +42,22 @@ private:
 class ShutdownSessionOperation : public std::unary_function<SessionWrapperPtr, void>
 {
 public:
+    ShutdownSessionOperation(const AsteriskSCF::SessionCommunications::V1::SessionPrx& exclude, 
+          const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
+          const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response,
+          const AsteriskSCF::System::Logging::Logger& logger);
+
     ShutdownSessionOperation(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
-            const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response,
-            const AsteriskSCF::System::Logging::Logger& logger);
+          const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr& response,
+          const AsteriskSCF::System::Logging::Logger& logger);
 
     void operator()(const SessionWrapperPtr& wrapper);
 private:
+    Ice::Identity mExclude;
     AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListener;
     AsteriskSCF::SessionCommunications::V1::ResponseCodePtr mResponse;
     AsteriskSCF::System::Logging::Logger mLogger;
+    bool mSkipExclude;
 };
 
 class RelayIndication : public std::unary_function<SessionWrapperPtr, void>
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index 883c614..cf7404f 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -261,9 +261,8 @@ protected:
     {
         BridgedSessionState oldState = mSession->setState(mState);
         if (mStartStates.find(oldState) == mStartStates.end())
-        {
+        { 
             mListener->failed();
-            return false;
         }
         return true;
     }
@@ -340,9 +339,9 @@ QueuedTasks createShutdownTasks(const SessionWrapperPtr& session, const SessionL
 
     QueuedTasks tasks;
     tasks.push_back(new SetStateFromTask(session, ::AsteriskSCF::Bridge::V1::Disconnected, statesToContinueOn));
-    tasks.push_back(new RemoveBridgeTask(session, listener));
     if (code)
     {
+        tasks.push_back(new RemoveBridgeTask(session, listener));
         tasks.push_back(new ShutdownMediaTask(session));
         tasks.push_back(new SessionStopTask(session, code));
     }
@@ -549,9 +548,14 @@ void SessionWrapper::shutdown(const SessionListenerPrx& listener, const Response
 {
     mLogger(Debug) << FUNLOG << ": beginning shutdown of " << mId;
     QueuedTaskPtr shutdownRunner(new QueueableExecutor(createShutdownTasks(this, listener, code), mLogger));
-    //
-    // TODO: determine if the pending activites should be shutdown first.
-    //
+    if (!code)
+    {
+        //
+        // This only happens if the session itself indicates that it is done, so we should
+        // make every attempt to not do any more.
+        //
+        mActivities->destroy();
+    }
     mActivities->append(shutdownRunner);
     //
     // If shutdown is going to preempt stuff we need to uncomment this.
diff --git a/src/Tasks.h b/src/Tasks.h
index 57898b3..0b13188 100644
--- a/src/Tasks.h
+++ b/src/Tasks.h
@@ -16,6 +16,7 @@
 #pragma once
 
 #include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
 #include <boost/thread/locks.hpp>
 #include <list>
 #include <AsteriskSCF/logger.h>
@@ -95,6 +96,7 @@ public:
         catch(...)
         {
             mListener->failed();
+            return false;
         }
         return true;
     }
@@ -159,7 +161,7 @@ protected:
     std::string mName;
 
     QueuedTask() :
-        mName("<unnamed>")
+        mName("QueuedTask")
     {
     }
 
@@ -205,14 +207,16 @@ class Executor : virtual public TaskListener
 public:
     Executor(const AsteriskSCF::System::Logging::Logger& logger) :
         mLogger(logger),
-        mStopped(true)
+        mStopped(true),
+        mName(IceUtil::generateUUID())
     {
     }
     
     Executor(const QueuedTasks& tasks, const AsteriskSCF::System::Logging::Logger& logger) :
         mTasks(tasks),
         mLogger(logger),
-        mStopped(true)
+        mStopped(true),
+        mName(IceUtil::generateUUID())
     {
         //
         // As indicated above, the tasks are associated with this "executor" instance 
@@ -231,6 +235,7 @@ public:
      **/
     void start()
     {
+        mLogger(AsteriskSCF::System::Logging::Debug) << mName << ": starting running";
         {
             boost::unique_lock<boost::shared_mutex> lock(mLock);
             if (!mStopped)
@@ -253,6 +258,7 @@ public:
      **/
     void stop()
     {
+        mLogger(AsteriskSCF::System::Logging::Debug) << mName << ": setting stop";
         boost::unique_lock<boost::shared_mutex> lock(mLock);
         mStopped = true;
     }
@@ -280,7 +286,7 @@ public:
         QueuedTaskPtr current = popNextTask();
         while (current)
         {
-            mLogger(AsteriskSCF::System::Logging::Debug) << ": executing " << current->name();
+            mLogger(AsteriskSCF::System::Logging::Debug) << ": " << mName << " executing " << current->name();
       
             //
             // Properly implemented tasks will return true if the next task should
@@ -307,10 +313,11 @@ public:
      **/ 
     void failed()
     {
+        mLogger(AsteriskSCF::System::Logging::Debug) << ": " << mName << " entering failed state";
         QueuedTaskPtr current = popNextTask();
         while (current)
         {
-            mLogger(AsteriskSCF::System::Logging::Debug) << ": failing " << current->name();
+            mLogger(AsteriskSCF::System::Logging::Debug) << ": " << mName << " failing " << current->name();
             current->fail();
             current = popNextTask();
         }
@@ -327,13 +334,14 @@ public:
      **/
     void destroy()
     {
+        mLogger(AsteriskSCF::System::Logging::Debug) << ": " << mName << " entering destroyed state";
         //
         // NOTE: a request that is in progress will not be destroyed.
         //
         QueuedTaskPtr current = popNextTask();
         while (current)
         {
-            mLogger(AsteriskSCF::System::Logging::Debug) << ": destroying " << current->name();
+            mLogger(AsteriskSCF::System::Logging::Debug) << ": " << mName << " destroying " << current->name();
             current->destroy();
             current = popNextTask();
         }
@@ -359,6 +367,7 @@ public:
      **/
     void append(const QueuedTaskPtr& newTask)
     {
+        mLogger(AsteriskSCF::System::Logging::Debug) << " " << mName << " Appending new task " << newTask->name();
         bool restart = false;
         {
             newTask->setListener(this);
@@ -397,6 +406,7 @@ protected:
     QueuedTasks mTasks;
     AsteriskSCF::System::Logging::Logger mLogger;
     bool mStopped;
+    std::string mName;
 };
 typedef IceUtil::Handle<Executor> ExecutorPtr;
 
@@ -434,6 +444,7 @@ public:
     void failed()
     {
         mListener->failed();
+        Executor::failed();
     }
 
 protected:

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


-- 
asterisk-scf/release/bridging.git



More information about the asterisk-scf-commits mailing list