summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp28
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp1
2 files changed, 16 insertions, 13 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 65895a3099b..609926aa1df 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -71,7 +71,7 @@ printGCStats(const IceInternal::GCStats& stats)
void
Ice::CommunicatorI::destroy()
{
- if(_instance->destroy())
+ if(_instance && _instance->destroy())
{
IceUtil::StaticMutex::Lock sync(gcMutex);
@@ -289,15 +289,7 @@ Ice::CommunicatorI::CommunicatorI(const InitializationData& initData)
// destructor is invoked.
//
const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
- }
- catch(...)
- {
- __setNoDelete(false);
- throw;
- }
- __setNoDelete(false);
- {
//
// If this is the first communicator that is created, use that communicator's
// property settings to determine whether to start the garbage collector.
@@ -316,13 +308,25 @@ Ice::CommunicatorI::CommunicatorI(const InitializationData& initData)
}
if(++communicatorCount == 1)
{
- theCollector = new IceInternal::GC(gcInterval, printGCStats);
+ IceUtil::Handle<IceInternal::GC> collector = new IceInternal::GC(gcInterval, printGCStats);
if(gcInterval > 0)
{
- theCollector->start();
+ collector->start();
}
+
+ //
+ // Assign only if start() succeeds, if it fails this makes sure stop isn't called in destroy().
+ //
+ theCollector = collector;
}
}
+ catch(...)
+ {
+ destroy();
+ __setNoDelete(false);
+ throw;
+ }
+ __setNoDelete(false);
}
Ice::CommunicatorI::~CommunicatorI()
@@ -343,7 +347,7 @@ Ice::CommunicatorI::finishSetup(int& argc, char* argv[])
}
catch(...)
{
- _instance->destroy();
+ destroy();
throw;
}
}
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index a12eff6b937..adc25621fb8 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -118,7 +118,6 @@ Ice::PluginManagerI::destroy()
if(_communicator)
{
-
if(_initialized)
{
map<string, PluginPtr>::iterator r;