diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-06-23 14:35:50 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-06-23 14:35:50 +0200 |
commit | 6c0ebb4d8a5625cae83eb7e299cdf961bfbf49e3 (patch) | |
tree | a6a8c6c1f6e62942ae59f05d50983c672ebcdc59 /cpp/test/Ice/ami/TestI.cpp | |
parent | Fixed ICE-8148 - Ice/location test failure because of EADDRINUSE (diff) | |
download | ice-6c0ebb4d8a5625cae83eb7e299cdf961bfbf49e3.tar.bz2 ice-6c0ebb4d8a5625cae83eb7e299cdf961bfbf49e3.tar.xz ice-6c0ebb4d8a5625cae83eb7e299cdf961bfbf49e3.zip |
Fixed ICE-7979 - Ice/ami server shutdown hang
Diffstat (limited to 'cpp/test/Ice/ami/TestI.cpp')
-rw-r--r-- | cpp/test/Ice/ami/TestI.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/cpp/test/Ice/ami/TestI.cpp b/cpp/test/Ice/ami/TestI.cpp index c9eddb8283d..f7bb761ea0e 100644 --- a/cpp/test/Ice/ami/TestI.cpp +++ b/cpp/test/Ice/ami/TestI.cpp @@ -111,14 +111,16 @@ TestIntfI::startDispatchAsync(std::function<void()> response, std::function<void const Ice::Current&) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _pending.push_back(move(response)); + _pending = move(response); + notifyAll(); } #else void TestIntfI::startDispatch_async(const Test::AMD_TestIntf_startDispatchPtr& cb, const Ice::Current&) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _pending.push_back(cb); + _pending = cb; + notifyAll(); } #endif @@ -126,18 +128,17 @@ void TestIntfI::finishDispatch(const Ice::Current& current) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); -#ifdef ICE_CPP11_MAPPING - for(vector<function<void()>>::iterator p = _pending.begin(); p != _pending.end(); ++p) + while(!_pending) { - (*p)(); + wait(); } +#ifdef ICE_CPP11_MAPPING + _pending(); + _pending = nullptr; #else - for(vector<Test::AMD_TestIntf_startDispatchPtr>::iterator p = _pending.begin(); p != _pending.end(); ++p) - { - (*p)->ice_response(); - } + _pending->ice_response(); + _pending = 0; #endif - _pending.clear(); } void @@ -147,17 +148,7 @@ TestIntfI::shutdown(const Ice::Current& current) // Just in case a request arrived late. // IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); -#ifdef ICE_CPP11_MAPPING - for(vector<function<void()>>::iterator p = _pending.begin(); p != _pending.end(); ++p) - { - (*p)(); - } -#else - for(vector<Test::AMD_TestIntf_startDispatchPtr>::iterator p = _pending.begin(); p != _pending.end(); ++p) - { - (*p)->ice_response(); - } -#endif + assert(!_pending); current.adapter->getCommunicator()->shutdown(); } |