diff options
author | Bernard Normier <bernard@zeroc.com> | 2008-12-31 14:34:37 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2008-12-31 14:34:37 -0500 |
commit | a0dfb6ad783f35c1b0cad78b9cdae077b57d6de3 (patch) | |
tree | 31fd8eb1d67cce0091b3f1757da55b2114af9363 /cpp/test | |
parent | Merge branch 'R3_3_branch' of ssh://git/home/git/ice into R3_3_branch (diff) | |
download | ice-a0dfb6ad783f35c1b0cad78b9cdae077b57d6de3.tar.bz2 ice-a0dfb6ad783f35c1b0cad78b9cdae077b57d6de3.tar.xz ice-a0dfb6ad783f35c1b0cad78b9cdae077b57d6de3.zip |
Fixed bug #3232 (Freeze transactional evictor leaks)
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/Freeze/evictor/TestI.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/cpp/test/Freeze/evictor/TestI.cpp b/cpp/test/Freeze/evictor/TestI.cpp index 3b213b3e93c..cd05dbd5f9d 100644 --- a/cpp/test/Freeze/evictor/TestI.cpp +++ b/cpp/test/Freeze/evictor/TestI.cpp @@ -67,14 +67,14 @@ Test::AccountI::transfer2_async(const AMD_Account_transfer2Ptr& cb, int amount, cb->ice_response(); } - class ResponseThread : public IceUtil::Thread, private IceUtil::Monitor<IceUtil::Mutex> { public: ResponseThread(const Test::AMD_Account_transfer3Ptr& cb) : _cb(cb), - _response(false) + _response(false), + _cancelled(false) { } @@ -92,6 +92,13 @@ public: notify(); } + void cancel() + { + Lock sync(*this); + _cancelled = true; + notify(); + } + virtual void run() { @@ -99,12 +106,12 @@ public: bool timedOut = false; - while(!timedOut && _response == false && _exception.get() == 0) + while(!timedOut && _response == false && _cancelled == false && _exception.get() == 0) { timedOut = !timedWait(IceUtil::Time::seconds(1)); } - if(timedOut) + if(_cancelled) { return; } @@ -126,11 +133,15 @@ public: private: Test::AMD_Account_transfer3Ptr _cb; bool _response; + bool _cancelled; std::auto_ptr<Ice::UserException> _exception; }; typedef IceUtil::Handle<ResponseThread> ResponseThreadPtr; + + + void Test::AccountI::transfer3_async(const AMD_Account_transfer3Ptr& cb, int amount, const Test::AccountPrx& toAccount, const Current& current) { @@ -139,8 +150,8 @@ Test::AccountI::transfer3_async(const AMD_Account_transfer3Ptr& cb, int amount, // ResponseThreadPtr thread = new ResponseThread(cb); - thread->start(33000).detach(); - + IceUtil::ThreadControl tc = thread->start(33000); + test(_evictor->getCurrentTransaction() != 0); try @@ -150,6 +161,8 @@ Test::AccountI::transfer3_async(const AMD_Account_transfer3Ptr& cb, int amount, } catch(const Ice::UserException& e) { + tc.detach(); + // // Need to rollback here -- "rollback on user exception" does not work // when the dispatch commits before it gets any response! @@ -157,9 +170,17 @@ Test::AccountI::transfer3_async(const AMD_Account_transfer3Ptr& cb, int amount, _evictor->getCurrentTransaction()->rollback(); thread->exception(e); + return; } + catch(...) + { + thread->cancel(); + tc.join(); + throw; + } + tc.detach(); thread->response(); } @@ -593,7 +614,6 @@ Test::RemoteEvictorI::destroyAllServants(const string& facetName, const Current& } } - Test::RemoteEvictorFactoryI::RemoteEvictorFactoryI(const ObjectAdapterPtr& adapter, const std::string& envName) : _adapter(adapter), |