diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-12-19 14:15:28 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-19 19:06:26 +0100 |
commit | 880b66fe31296fce70ec2e2f8a9c2ce4092cee9d (patch) | |
tree | c11eb3dbbaf324cdc5725734e194d925b88dd5b2 /cppu | |
parent | 5f150e63a4df2f4dccc6eeeac3a2462429ebc4c2 (diff) |
Prevent creation of new ORequestThreads during shutdown.
(cherry picked from commit b68640c44ecdb1df59d704cc6c2bae8bb412d7d0)
Signed-off-by: Michael Stahl <mstahl@redhat.com>
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'cppu')
-rw-r--r-- | cppu/source/threadpool/thread.cxx | 25 | ||||
-rw-r--r-- | cppu/source/threadpool/thread.hxx | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/cppu/source/threadpool/thread.cxx b/cppu/source/threadpool/thread.cxx index 58aec56cf185..cc22a453c79d 100644 --- a/cppu/source/threadpool/thread.cxx +++ b/cppu/source/threadpool/thread.cxx @@ -30,12 +30,22 @@ #include <osl/diagnose.h> #include <uno/threadpool.h> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XInterface.hpp> #include <rtl/instance.hxx> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> #include "thread.hxx" #include "jobqueue.hxx" #include "threadpool.hxx" +namespace { + +namespace css = com::sun::star; + +} using namespace osl; extern "C" { @@ -53,6 +63,8 @@ void SAL_CALL cppu_requestThreadWorker( void *pVoid ) namespace cppu_threadpool { // ---------------------------------------------------------------------------------- + ThreadAdmin::ThreadAdmin(): m_disposed(false) {} + ThreadAdmin::~ThreadAdmin() { #if OSL_DEBUG_LEVEL > 1 @@ -66,6 +78,15 @@ namespace cppu_threadpool { void ThreadAdmin::add( ORequestThread *p ) { MutexGuard aGuard( m_mutex ); + if( m_disposed ) + { + throw css::lang::DisposedException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "cppu_threadpool::ORequestThread created after" + " cppu_threadpool::ThreadAdmin has been disposed")), + css::uno::Reference< css::uno::XInterface >()); + } m_lst.push_back( p ); } @@ -79,6 +100,10 @@ namespace cppu_threadpool { void ThreadAdmin::join() { + { + MutexGuard aGuard( m_mutex ); + m_disposed = true; + } ORequestThread *pCurrent; do { diff --git a/cppu/source/threadpool/thread.hxx b/cppu/source/threadpool/thread.hxx index bbef51eabca4..a3ea45aadaed 100644 --- a/cppu/source/threadpool/thread.hxx +++ b/cppu/source/threadpool/thread.hxx @@ -74,6 +74,7 @@ namespace cppu_threadpool { class ThreadAdmin { public: + ThreadAdmin(); ~ThreadAdmin (); static ThreadAdminHolder &getInstance(); void add( ORequestThread * ); @@ -83,6 +84,7 @@ namespace cppu_threadpool { private: ::osl::Mutex m_mutex; ::std::list< ORequestThread * > m_lst; + bool m_disposed; }; } // end cppu_threadpool |