[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "srtp-support" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Jul 18 12:27:56 CDT 2011


branch "srtp-support" has been created
        at  0294568c6f24d0a3aeadee673d660f3e3ebe62ef (commit)

- Log -----------------------------------------------------------------
commit 0294568c6f24d0a3aeadee673d660f3e3ebe62ef
Merge: 45b6a7e ace9d4b
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Jul 18 14:57:21 2011 -0230

    Merge branch 'nat-support' into srtp-support


commit 45b6a7edcee777a7d078f52a269e6ff469f1408d
Merge: 7b7c71e 81d6eb6
Author: Brent Eagles <beagles at digium.com>
Date:   Sun Jul 17 15:13:01 2011 -0230

    Merge remote-tracking branch 'origin/master' into srtp-support


commit 81d6eb6688d12416f6761ac9eef9d488f5001622
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 6 16:11:19 2011 -0500

    Fix race condition in work queue test.

diff --git a/test/WorkQueue/TestWorkQueue.cpp b/test/WorkQueue/TestWorkQueue.cpp
index 4bab4fa..099445f 100644
--- a/test/WorkQueue/TestWorkQueue.cpp
+++ b/test/WorkQueue/TestWorkQueue.cpp
@@ -82,15 +82,21 @@ public:
         : mStarted(false), mStopped(false) { }
     void start()
     {
+        boost::unique_lock<boost::mutex> lock(mLock);
         mStarted = true;
+        mCond.notify_one();
     }
     void stop()
     {
+        boost::unique_lock<boost::mutex> lock(mLock);
         mStopped = true;
+        mCond.notify_one();
     }
 
     bool mStarted;
     bool mStopped;
+    boost::mutex mLock;
+    boost::condition_variable mCond;
 };
 
 typedef IceUtil::Handle<ThreadHook> ThreadHookPtr;
@@ -447,6 +453,13 @@ BOOST_AUTO_TEST_CASE(defaultListener)
     NotifyTaskPtr work4(new NotifyTask);
     WorkSeq works;
 
+    {
+        boost::unique_lock<boost::mutex> lock(tHook->mLock);
+        while (!tHook->mStarted)
+        {
+            tHook->mCond.wait(lock);
+        }
+    }
     BOOST_CHECK(tHook->mStarted == true);
     BOOST_CHECK(tHook->mStopped == false);
 
@@ -478,6 +491,13 @@ BOOST_AUTO_TEST_CASE(defaultListener)
 
     queue->shutdown();
 
+    {
+        boost::unique_lock<boost::mutex> lock(tHook->mLock);
+        while (!tHook->mStopped)
+        {
+            tHook->mCond.wait(lock);
+        }
+    }
     BOOST_CHECK(tHook->mStopped == true);
 }
 

commit 0de3a6da08326394ca81228ee1c0ae770f78dbcb
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 6 15:25:26 2011 -0500

    Add threadhook testing to the DefaultQueueListener test as suggested in CR-ASTSCF-117

diff --git a/test/WorkQueue/TestWorkQueue.cpp b/test/WorkQueue/TestWorkQueue.cpp
index a2b6bb3..4bab4fa 100644
--- a/test/WorkQueue/TestWorkQueue.cpp
+++ b/test/WorkQueue/TestWorkQueue.cpp
@@ -75,6 +75,26 @@ public:
 
 typedef IceUtil::Handle<Task> TaskPtr;
 
+class ThreadHook : public Ice::ThreadNotification
+{
+public:
+    ThreadHook()
+        : mStarted(false), mStopped(false) { }
+    void start()
+    {
+        mStarted = true;
+    }
+    void stop()
+    {
+        mStopped = true;
+    }
+
+    bool mStarted;
+    bool mStopped;
+};
+
+typedef IceUtil::Handle<ThreadHook> ThreadHookPtr;
+
 /**
  * Like a Task, but it has the capability
  * of notifying a waiting thread when the
@@ -419,13 +439,17 @@ void waitForTaskCompletion(NotifyTaskPtr& task)
 BOOST_AUTO_TEST_CASE(defaultListener)
 {
     QueuePtr queue(new WorkQueue());
-    DefaultQueueListenerPtr listener(new DefaultQueueListener(queue, 0));
+    ThreadHookPtr tHook(new ThreadHook());
+    DefaultQueueListenerPtr listener(new DefaultQueueListener(queue, tHook));
     NotifyTaskPtr work1(new NotifyTask);
     NotifyTaskPtr work2(new NotifyTask);
     NotifyTaskPtr work3(new NotifyTask);
     NotifyTaskPtr work4(new NotifyTask);
     WorkSeq works;
 
+    BOOST_CHECK(tHook->mStarted == true);
+    BOOST_CHECK(tHook->mStopped == false);
+
     queue->setListener(listener);
 
     works.push_back(work1);
@@ -451,6 +475,10 @@ BOOST_AUTO_TEST_CASE(defaultListener)
     waitForTaskCompletion(work5);
 
     BOOST_CHECK(work5->taskExecuted == true);
+
+    queue->shutdown();
+
+    BOOST_CHECK(tHook->mStopped == true);
 }
 
 BOOST_AUTO_TEST_SUITE_END()

commit 46735aa3466327f819e9da924274338894a6d75c
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jul 5 11:05:14 2011 -0500

    Add a thread hook to the default queue listener.
    
    This was necessary due to its usage in the SIP component, plus it may
    be a useful thing to have other places.

diff --git a/include/AsteriskSCF/WorkQueue/DefaultQueueListener.h b/include/AsteriskSCF/WorkQueue/DefaultQueueListener.h
index 06cc601..37df9ea 100644
--- a/include/AsteriskSCF/WorkQueue/DefaultQueueListener.h
+++ b/include/AsteriskSCF/WorkQueue/DefaultQueueListener.h
@@ -15,6 +15,8 @@
  */
 #pragma once
 
+#include <Ice/Ice.h>
+
 #include <boost/shared_ptr.hpp>
 #include <AsteriskSCF/System/WorkQueue/WorkQueueIf.h>
 
@@ -43,7 +45,7 @@ class DefaultQueueListenerPriv;
 class ASTSCF_DLL_EXPORT DefaultQueueListener : public AsteriskSCF::System::WorkQueue::V1::QueueListener
 {
 public:
-    DefaultQueueListener(const AsteriskSCF::System::WorkQueue::V1::QueueBasePtr& queue);
+    DefaultQueueListener(const AsteriskSCF::System::WorkQueue::V1::QueueBasePtr& queue, const Ice::ThreadNotificationPtr& threadHook);
     ~DefaultQueueListener();
     
     void workAdded(const AsteriskSCF::System::WorkQueue::V1::QueueBasePtr&, Ice::Long numNewWork, bool wasEmpty);
diff --git a/src/ThreadPool/ThreadPool.cpp b/src/ThreadPool/ThreadPool.cpp
index 6791084..44ce0df 100644
--- a/src/ThreadPool/ThreadPool.cpp
+++ b/src/ThreadPool/ThreadPool.cpp
@@ -41,7 +41,7 @@ public:
     ThreadPool(const PoolListenerPtr& listener, const QueuePtr& queue)
         : mControlQueue(new AsteriskSCF::WorkQueue::WorkQueue), mListener(listener), mQueue(queue), mShuttingDown(false)
     {
-        mControlQueue->setListener(new AsteriskSCF::WorkQueue::DefaultQueueListener(mControlQueue));
+        mControlQueue->setListener(new AsteriskSCF::WorkQueue::DefaultQueueListener(mControlQueue, 0));
         ThreadQueueListenerPtr tqListener;
         ThreadQueueListenerFactory factory;
         tqListener = factory.createThreadQueueListener(this);
diff --git a/src/WorkQueue/DefaultQueueListener.cpp b/src/WorkQueue/DefaultQueueListener.cpp
index f191c17..4d46860 100644
--- a/src/WorkQueue/DefaultQueueListener.cpp
+++ b/src/WorkQueue/DefaultQueueListener.cpp
@@ -27,9 +27,9 @@ using namespace AsteriskSCF::System::WorkQueue::V1;
 class DefaultQueueListenerPriv
 {
 public:
-    DefaultQueueListenerPriv(const QueueBasePtr& queue)
+    DefaultQueueListenerPriv(const QueueBasePtr& queue, const Ice::ThreadNotificationPtr& threadHook)
         : mWakeUp(false), mDead(false), mQueue(queue),
-        mIsShutdown(false),
+        mIsShutdown(false), mThreadHook(threadHook),
         mThread(boost::bind(&DefaultQueueListenerPriv::run, this)) { }
 
     bool idle()
@@ -53,6 +53,10 @@ public:
          * an infinite loop.
          */
         bool localDead = false;
+        if (mThreadHook != 0)
+        {
+            mThreadHook->start();
+        }
         while (!localDead)
         {
             try
@@ -68,6 +72,10 @@ public:
                 localDead = idle();
             }
         }
+        if (mThreadHook != 0)
+        {
+            mThreadHook->stop();
+        }
     }
 
     void setDead(bool dead)
@@ -84,11 +92,12 @@ public:
     boost::mutex mLock;
     boost::condition_variable mCond;
     bool mIsShutdown;
+    Ice::ThreadNotificationPtr mThreadHook;
     boost::thread mThread;
 };
 
-DefaultQueueListener::DefaultQueueListener(const QueueBasePtr& queue)
-    : mPriv(new DefaultQueueListenerPriv(queue)) { }
+DefaultQueueListener::DefaultQueueListener(const QueueBasePtr& queue, const Ice::ThreadNotificationPtr& threadHook)
+    : mPriv(new DefaultQueueListenerPriv(queue, threadHook)) { }
 
 DefaultQueueListener::~DefaultQueueListener()
 {
diff --git a/test/WorkQueue/TestWorkQueue.cpp b/test/WorkQueue/TestWorkQueue.cpp
index 50a0f9b..a2b6bb3 100644
--- a/test/WorkQueue/TestWorkQueue.cpp
+++ b/test/WorkQueue/TestWorkQueue.cpp
@@ -419,7 +419,7 @@ void waitForTaskCompletion(NotifyTaskPtr& task)
 BOOST_AUTO_TEST_CASE(defaultListener)
 {
     QueuePtr queue(new WorkQueue());
-    DefaultQueueListenerPtr listener(new DefaultQueueListener(queue));
+    DefaultQueueListenerPtr listener(new DefaultQueueListener(queue, 0));
     NotifyTaskPtr work1(new NotifyTask);
     NotifyTaskPtr work2(new NotifyTask);
     NotifyTaskPtr work3(new NotifyTask);

commit 94a22d0051ee42490b47c41cc81b0f0e61cf36ec
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Jun 30 15:51:12 2011 -0500

    Correct unit test configuration file and path errors.
    
    The path to the unit test configuration file was incomplete, and the file
    itself did not have the proper name for the test module.
    
    (closes issue ASTSCF-202)

diff --git a/config/IceUtilCppTests.conf b/config/IceUtilCppTests.conf
index 745d32f..029ae1a 100644
--- a/config/IceUtilCppTests.conf
+++ b/config/IceUtilCppTests.conf
@@ -17,4 +17,4 @@ IceBox.ServiceManager.Endpoints=default -p 56000
 IceBox.ServiceManager.ThreadPool.Size=4
 IceBoxManager.Proxy=IceBox/ServiceManager:default -p 56000
 
-IceBox.Service.ProxyHelper=ascf-ice-util-cpp-tests:create
+IceBox.Service.ProxyHelper=astscf-ice-util-cpp-test:create
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 160f2f7..610766e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -12,7 +12,7 @@ astscf_component_add_ice_libraries(astscf-ice-util-cpp-test IceBox)
 astscf_component_add_boost_libraries(astscf-ice-util-cpp-test unit_test_framework date_time thread)
 astscf_component_add_slice_collection_libraries(astscf-ice-util-cpp-test ASTSCF)
 astscf_component_build_icebox(astscf-ice-util-cpp-test)
-astscf_test_icebox(astscf-ice-util-cpp-test IceUtilCppTests.conf)
+astscf_test_icebox(astscf-ice-util-cpp-test config/IceUtilCppTests.conf)
 
 add_subdirectory(Async)
 add_subdirectory(Replication)

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


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list