diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-02-12 09:50:25 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-02-12 09:50:25 -0330 |
commit | d6a276ee2646f92231c3d8b77af8742fbd921bd2 (patch) | |
tree | 0826c3e43406de9e0377c43fb01edbbce51fa202 /cpp/src | |
parent | Bug 3651 - slice2cpp --depend does not error on bad slice (diff) | |
parent | Ensure that no more fds error message is flushed before the abort (diff) | |
download | ice-d6a276ee2646f92231c3d8b77af8742fbd921bd2.tar.bz2 ice-d6a276ee2646f92231c3d8b77af8742fbd921bd2.tar.xz ice-d6a276ee2646f92231c3d8b77af8742fbd921bd2.zip |
Merge branch 'R3_3_branch' of ssh://cvs.zeroc.com/home/git/ice into R3_3_branch
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 7 | ||||
-rw-r--r-- | cpp/src/IceGrid/IceGridNode.cpp | 96 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeSessionManager.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 24 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/ReplicaSessionManager.cpp | 7 | ||||
-rw-r--r-- | cpp/src/IceStorm/Service.cpp | 51 |
8 files changed, 155 insertions, 51 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index b00d915aae4..31ce984e6ce 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -1280,8 +1280,10 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt { if(noMoreFds(ex.error)) { - Error out(_instance->initializationData().logger); - out << "fatal error: can't accept more connections:\n" << ex << '\n' << _acceptor->toString(); + { + Error out(_instance->initializationData().logger); + out << "fatal error: can't accept more connections:\n" << ex << '\n' << _acceptor->toString(); + } abort(); } diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 0b99b68a417..aad9b15b64f 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -1054,8 +1054,11 @@ Activator::destroy() // when there's no more processes and when _deactivating is set to // true. // - _thread->getThreadControl().join(); - _thread = 0; + if(_thread) + { + _thread->getThreadControl().join(); + _thread = 0; + } assert(_processes.empty()); } diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 4dc9a62e978..a78d45531a7 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -77,6 +77,7 @@ public: protected: virtual bool start(int, char*[]); + bool startImpl(int, char*[]); virtual void waitForShutdown(); virtual bool stop(); virtual CommunicatorPtr initializeCommunicator(int&, char*[], const InitializationData&); @@ -184,6 +185,25 @@ NodeService::shutdown() bool NodeService::start(int argc, char* argv[]) { + try + { + if(!startImpl(argc, argv)) + { + stop(); + return false; + } + } + catch(...) + { + stop(); + throw; + } + return true; +} + +bool +NodeService::startImpl(int argc, char* argv[]) +{ bool nowarn = false; bool readonly = false; string desc; @@ -668,43 +688,53 @@ NodeService::waitForShutdown() bool NodeService::stop() { - try - { - _activator->destroy(); - } - catch(...) + if(_activator) { - assert(false); + try + { + _activator->shutdown(); + _activator->destroy(); + } + catch(...) + { + assert(false); + } + _activator = 0; } - // - // The timer must be destroyed after the activator and before the - // communicator is shutdown. - // - try - { - _timer->destroy(); - } - catch(...) + if(_timer) { - assert(false); + // + // The timer must be destroyed after the activator and before the + // communicator is shutdown. + // + try + { + _timer->destroy(); + } + catch(...) + { + assert(false); + } + _timer = 0; } - _activator = 0; - // // Deactivate the node object adapter. // - try + if(_adapter) { - _adapter->deactivate(); - _adapter = 0; - } - catch(const Ice::LocalException& ex) - { - ostringstream ostr; - ostr << "unexpected exception while shutting down node:\n" << ex; - warning(ostr.str()); + try + { + _adapter->deactivate(); + _adapter = 0; + } + catch(const Ice::LocalException& ex) + { + ostringstream ostr; + ostr << "unexpected exception while shutting down node:\n" << ex; + warning(ostr.str()); + } } // @@ -715,7 +745,10 @@ NodeService::stop() // // Stop the platform info thread. // - _node->getPlatformInfo().stop(); + if(_node) + { + _node->getPlatformInfo().stop(); + } // // We can now safely shutdown the communicator. @@ -735,8 +768,11 @@ NodeService::stop() // // Break cylic reference counts. // - _node->shutdown(); - _node = 0; + if(_node) + { + _node->shutdown(); + _node = 0; + } // // And shutdown the collocated registry. diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp index 718a559f92f..878c0bb03d7 100644 --- a/cpp/src/IceGrid/NodeSessionManager.cpp +++ b/cpp/src/IceGrid/NodeSessionManager.cpp @@ -322,19 +322,29 @@ NodeSessionManager::destroy() NodeSessionMap sessions; { Lock sync(*this); + if(_destroyed) + { + return; + } _destroyed = true; _sessions.swap(sessions); notifyAll(); } - _thread->terminate(); + if(_thread) + { + _thread->terminate(); + } NodeSessionMap::const_iterator p; for(p = sessions.begin(); p != sessions.end(); ++p) { p->second->terminate(); } - _thread->getThreadControl().join(); + if(_thread) + { + _thread->getThreadControl().join(); + } for(p = sessions.begin(); p != sessions.end(); ++p) { p->second->getThreadControl().join(); diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index b5c58b51583..088a1c6d8a3 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -167,6 +167,25 @@ RegistryI::~RegistryI() bool RegistryI::start() { + try + { + if(!startImpl()) + { + stop(); + return false; + } + } + catch(...) + { + stop(); + throw; + } + return true; +} + +bool +RegistryI::startImpl() +{ assert(_communicator); PropertiesPtr properties = _communicator->getProperties(); @@ -687,7 +706,10 @@ RegistryI::stop() // ensure that there will be no more invocations on IceStorm once // it's shutdown. // - _database->destroyTopics(); + if(_database) + { + _database->destroyTopics(); + } try { diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h index 59102782ee6..430920de7a8 100644 --- a/cpp/src/IceGrid/RegistryI.h +++ b/cpp/src/IceGrid/RegistryI.h @@ -52,6 +52,7 @@ public: ~RegistryI(); bool start(); + bool startImpl(); void stop(); virtual SessionPrx createSession(const std::string&, const std::string&, const Ice::Current&); diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp index 05e57c908ef..74ff82acb46 100644 --- a/cpp/src/IceGrid/ReplicaSessionManager.cpp +++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp @@ -346,16 +346,19 @@ ReplicaSessionManager::getNodes(const NodePrxSeq& nodes) const void ReplicaSessionManager::destroy() { + ThreadPtr thread; { Lock sync(*this); if(!_thread) { return; } + thread = _thread; + _thread = 0; } - _thread->terminate(); - _thread->getThreadControl().join(); + thread->terminate(); + thread->getThreadControl().join(); _database = 0; _wellKnownObjects = 0; diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp index b6b1305d538..a6700d473a2 100644 --- a/cpp/src/IceStorm/Service.cpp +++ b/cpp/src/IceStorm/Service.cpp @@ -144,10 +144,17 @@ ServiceI::start( TransientTopicManagerImplPtr manager = new TransientTopicManagerImpl(_instance); _managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(manager, topicManagerId)); } - catch(const Ice::Exception&) + catch(const Ice::Exception& ex) { _instance = 0; - throw; + + ostringstream s; + s << "exception while starting IceStorm service " << name << ":\n"; + s << ex; + + IceBox::FailureException e(__FILE__, __LINE__); + e.reason = s.str(); + throw e; } topicAdapter->activate(); publishAdapter->activate(); @@ -163,10 +170,17 @@ ServiceI::start( _manager = new TopicManagerImpl(_instance); _managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(_manager->getServant(), topicManagerId)); } - catch(const Ice::Exception&) + catch(const Ice::Exception& ex) { _instance = 0; - throw; + + ostringstream s; + s << "exception while starting IceStorm service " << name << ":\n"; + s << ex; + + IceBox::FailureException e(__FILE__, __LINE__); + e.reason = s.str(); + throw e; } } else @@ -209,7 +223,7 @@ ServiceI::start( Ice::Error error(communicator->getLogger()); error << "deployment error: `" << topicManagerAdapterId << "' prefix does not match `" << nodeAdapterId << "'"; - throw "IceGrid deployment is incorrect"; + throw IceBox::FailureException(__FILE__, __LINE__, "IceGrid deployment is incorrect"); } // Determine the set of node id and node proxies. @@ -239,7 +253,7 @@ ServiceI::start( { Ice::Error error(communicator->getLogger()); error << "deployment error: `" << adapterid << "' does not start with `" << instanceName << "'"; - throw "IceGrid deployment is incorrect"; + throw IceBox::FailureException(__FILE__, __LINE__, "IceGrid deployment is incorrect"); } // The node id follows. We find the first digit (the @@ -262,7 +276,7 @@ ServiceI::start( Ice::Error error(communicator->getLogger()); error << "deployment error: node id does not follow instance name. instance name:" << instanceName << " adapter id: " << adapterid; - throw "IceGrid deployment is incorrect"; + throw IceBox::FailureException(__FILE__, __LINE__, "IceGrid deployment is incorrect"); } int nodeid = atoi(adapterid.substr(start, end-start).c_str()); @@ -280,7 +294,7 @@ ServiceI::start( { Ice::Error error(communicator->getLogger()); error << "Replication requires at least 3 Nodes"; - throw "error"; + throw IceBox::FailureException(__FILE__, __LINE__, "Replication requires at least 3 Nodes"); } try @@ -343,10 +357,17 @@ ServiceI::start( node->start(); } - catch(const Ice::Exception&) + catch(const Ice::Exception& ex) { _instance = 0; - throw; + + ostringstream s; + s << "exception while starting IceStorm service " << name << ":\n"; + s << ex; + + IceBox::FailureException e(__FILE__, __LINE__); + e.reason = s.str(); + throw e; } } @@ -378,10 +399,16 @@ ServiceI::start(const CommunicatorPtr& communicator, TransientTopicManagerImplPtr manager = new TransientTopicManagerImpl(_instance); _managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(manager, id)); } - catch(const Ice::Exception&) + catch(const Ice::Exception& ex) { _instance = 0; - throw; + ostringstream s; + s << "exception while starting IceStorm service " << name << ":\n"; + s << ex; + + IceBox::FailureException e(__FILE__, __LINE__); + e.reason = s.str(); + throw e; } } |