From 3f03b2188221f2ad756540a9008ba60b01ea10fb Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Tue, 6 Jan 2009 11:19:29 +0100 Subject: Partial fix for bug 3538 --- cpp/src/Ice/CommunicatorI.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'cpp/src/Ice/CommunicatorI.cpp') 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(_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 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; } } -- cgit v1.2.3