summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/CommunicatorI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/CommunicatorI.cpp')
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp60
1 files changed, 39 insertions, 21 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 05d1aaecc6f..85db7a08a7a 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -13,7 +13,6 @@
#include <Ice/Instance.h>
#include <Ice/ProxyFactory.h>
#include <Ice/ThreadPool.h>
-#include <Ice/ObjectAdapter.h>
#include <Ice/ServantFactoryManager.h>
#include <Ice/ObjectAdapterFactory.h>
#include <Ice/Logger.h>
@@ -28,37 +27,40 @@ void
Ice::CommunicatorI::destroy()
{
JTCSyncT<JTCRecursiveMutex> sync(*this);
+
shutdown();
- _instance->destroy();
- _instance = 0;
+
+ if (_instance)
+ {
+ _instance->destroy();
+ _instance = 0;
+ }
+
+ //
+ // Don't set _threadPool to null here! See the comments in the
+ // header file.
+ //
}
void
Ice::CommunicatorI::shutdown()
{
- JTCSyncT<JTCRecursiveMutex> sync(*this);
- if (!_instance)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- _instance->objectAdapterFactory()->shutdown();
+ //
+ // No mutex locking here! This operation must be signal-safe.
+ //
+ _threadPool->initiateServerShutdown();
}
void
Ice::CommunicatorI::waitForShutdown()
{
- ThreadPoolPtr threadPool;
-
+ JTCSyncT<JTCRecursiveMutex> sync(*this);
+ if (!_instance)
{
- JTCSyncT<JTCRecursiveMutex> sync(*this);
- if (!_instance)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- threadPool = _instance->threadPool();
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- threadPool->waitUntilServerFinished();
+ _threadPool->waitUntilServerFinished();
}
ObjectPrx
@@ -103,7 +105,7 @@ Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const s
{
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- return _instance->objectAdapterFactory() -> createObjectAdapter(name, endpts);
+ return _instance->objectAdapterFactory()->createObjectAdapter(name, endpts);
}
void
@@ -161,9 +163,25 @@ Ice::CommunicatorI::getPickler()
return _instance->pickler();
}
-Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties) :
- _instance(new Instance(this, properties))
+Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties)
{
+ __setNoDelete(true);
+ try
+ {
+ _instance = new Instance(this, properties);
+ }
+ catch(...)
+ {
+ __setNoDelete(false);
+ throw;
+ }
+ __setNoDelete(false);
+
+ //
+ // Se the comments in the header file for an explanation of why we
+ // need _threadPool directly in CommunicatorI.
+ //
+ _threadPool = _instance->threadPool();
}
Ice::CommunicatorI::~CommunicatorI()