summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-01-05 11:56:55 +0100
committerBenoit Foucher <benoit@zeroc.com>2016-01-05 11:56:55 +0100
commit22403a2ad0d8921df9f4ec06f2571d251dbae3a6 (patch)
treef221ed8fd97017bc9afe13ac8bad62f1d7dfb5c2 /cpp
parentTravis cleanup (diff)
downloadice-22403a2ad0d8921df9f4ec06f2571d251dbae3a6.tar.bz2
ice-22403a2ad0d8921df9f4ec06f2571d251dbae3a6.tar.xz
ice-22403a2ad0d8921df9f4ec06f2571d251dbae3a6.zip
Fixed potential deadlock that could occur with Ice for C++ when using collocation optimization and serialization
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ThreadPool.cpp6
-rw-r--r--cpp/test/Ice/adapterDeactivation/AllTests.cpp5
-rw-r--r--cpp/test/Ice/adapterDeactivation/Collocated.cpp6
3 files changed, 12 insertions, 5 deletions
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 7ff3f57db4b..5d03c88f4f4 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -777,7 +777,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
// If the handler called ioCompleted(), we re-enable the handler in
// case it was disabled and we decrease the number of thread in use.
//
- if(_serialize)
+ if(_serialize && current._handler.get() != _workQueue.get())
{
_selector.enable(current._handler.get(), current.operation);
if(current._handler->_hasMoreData && current._handler->_registered & SocketOperationRead)
@@ -1004,7 +1004,7 @@ IceInternal::ThreadPool::ioCompleted(ThreadPoolCurrent& current)
if(!_destroyed)
{
- if(_serialize)
+ if(_serialize && current._handler.get() != _workQueue.get())
{
_selector.disable(current._handler.get(), current.operation);
@@ -1079,7 +1079,7 @@ IceInternal::ThreadPool::ioCompleted(ThreadPoolCurrent& current)
}
}
- return _serialize;
+ return _serialize && current._handler.get() != _workQueue.get();
}
#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
diff --git a/cpp/test/Ice/adapterDeactivation/AllTests.cpp b/cpp/test/Ice/adapterDeactivation/AllTests.cpp
index 8186540cb30..9587c0cc268 100644
--- a/cpp/test/Ice/adapterDeactivation/AllTests.cpp
+++ b/cpp/test/Ice/adapterDeactivation/AllTests.cpp
@@ -30,10 +30,10 @@ allTests(const CommunicatorPtr& communicator)
cout << "ok" << endl;
{
- string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
+ string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
"127.0.0.1" : "\"0:0:0:0:0:0:0:1\"";
cout << "creating/destroying/recreating object adapter... " << flush;
- ObjectAdapterPtr adapter =
+ ObjectAdapterPtr adapter =
communicator->createObjectAdapterWithEndpoints("TransientTestAdapter", "default -h " + host);
try
{
@@ -55,6 +55,7 @@ allTests(const CommunicatorPtr& communicator)
cout << "creating/activating/deactivating object adapter in one operation... " << flush;
obj->transient();
+ obj->end_transient(obj->begin_transient());
cout << "ok" << endl;
{
diff --git a/cpp/test/Ice/adapterDeactivation/Collocated.cpp b/cpp/test/Ice/adapterDeactivation/Collocated.cpp
index ef093c73098..48763b3ba41 100644
--- a/cpp/test/Ice/adapterDeactivation/Collocated.cpp
+++ b/cpp/test/Ice/adapterDeactivation/Collocated.cpp
@@ -22,6 +22,12 @@ int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
+
+ //
+ // 2 threads are necessary to dispatch the collocated transient() call with AMI
+ //
+ communicator->getProperties()->setProperty("TestAdapter.ThreadPool.Size", "2");
+
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
ServantLocatorPtr locator = new ServantLocatorI;
adapter->addServantLocator(locator, "");