summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-06-23 15:27:03 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-06-23 15:27:03 +0200
commitd9fd16f6427706e790c3228f712642626e71e783 (patch)
tree43009dbaa7cfd8ff04e5d4b463fa54fc2702b4b6 /cpp
parentFixed ICE-7979 - Ice/ami server shutdown hang (diff)
downloadice-d9fd16f6427706e790c3228f712642626e71e783.tar.bz2
ice-d9fd16f6427706e790c3228f712642626e71e783.tar.xz
ice-d9fd16f6427706e790c3228f712642626e71e783.zip
Another fix for ICE-7979 - Ice/ami server shutdown hang
Diffstat (limited to 'cpp')
-rw-r--r--cpp/test/Ice/ami/TestI.cpp54
-rw-r--r--cpp/test/Ice/ami/TestI.h1
2 files changed, 42 insertions, 13 deletions
diff --git a/cpp/test/Ice/ami/TestI.cpp b/cpp/test/Ice/ami/TestI.cpp
index f7bb761ea0e..77496b12ede 100644
--- a/cpp/test/Ice/ami/TestI.cpp
+++ b/cpp/test/Ice/ami/TestI.cpp
@@ -14,7 +14,7 @@ using namespace std;
using namespace Ice;
TestIntfI::TestIntfI() :
- _batchCount(0)
+ _batchCount(0), _shutdown(false)
{
}
@@ -111,16 +111,34 @@ TestIntfI::startDispatchAsync(std::function<void()> response, std::function<void
const Ice::Current&)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(_shutdown)
+ {
+ response();
+ return;
+ }
+ else if(_pending)
+ {
+ _pending();
+ }
_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);
+ if(_shutdown)
+ {
+ // Ignore, this can occur with the forcefull connection close test, shutdown can be dispatch
+ // before start dispatch.
+ cb->ice_response();
+ return;
+ }
+ else if(_pending)
+ {
+ _pending->ice_response();
+ }
_pending = cb;
- notifyAll();
}
#endif
@@ -128,27 +146,37 @@ void
TestIntfI::finishDispatch(const Ice::Current& current)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- while(!_pending)
+ if(_shutdown)
{
- wait();
+ return;
}
+ else if(_pending) // Pending might not be set yet if startDispatch is dispatch out-of-order
+ {
#ifdef ICE_CPP11_MAPPING
- _pending();
- _pending = nullptr;
+ _pending();
+ _pending = nullptr;
#else
- _pending->ice_response();
- _pending = 0;
+ _pending->ice_response();
+ _pending = 0;
#endif
+ }
}
void
TestIntfI::shutdown(const Ice::Current& current)
{
- //
- // Just in case a request arrived late.
- //
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- assert(!_pending);
+ _shutdown = true;
+ if(_pending)
+ {
+#ifdef ICE_CPP11_MAPPING
+ _pending();
+ _pending = nullptr;
+#else
+ _pending->ice_response();
+ _pending = 0;
+#endif
+ }
current.adapter->getCommunicator()->shutdown();
}
diff --git a/cpp/test/Ice/ami/TestI.h b/cpp/test/Ice/ami/TestI.h
index 20c11bf8f8b..5d05089241c 100644
--- a/cpp/test/Ice/ami/TestI.h
+++ b/cpp/test/Ice/ami/TestI.h
@@ -51,6 +51,7 @@ public:
private:
int _batchCount;
+ bool _shutdown;
#ifdef ICE_CPP11_MAPPING
std::function<void()> _pending;
#else