From 74b78c428871eb14762bf5a4eee9e459e06ce570 Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 8 Nov 2007 11:20:28 +0000 Subject: [PATCH] IMP NPAL13547: Checkbox to kill SALOME completely. --- idl/DSC_Engines.idl | 9 +++++++ idl/SALOMEDS.idl | 10 ++++++++ idl/SALOME_ContainerManager.idl | 5 ++++ idl/SALOME_ModuleCatalog.idl | 10 ++++++++ idl/SALOME_Registry.idl | 1 + idl/SALOME_Session.idl | 4 +++ src/Container/SALOME_ContainerManager.cxx | 25 +++++++++++++++++++ src/Container/SALOME_ContainerManager.hxx | 3 +++ src/DSC/DSC_Basic/ConnectionManager_i.cxx | 12 +++++++++ src/DSC/DSC_Basic/ConnectionManager_i.hxx | 10 ++++++++ .../SALOME_ModuleCatalog_impl.cxx | 10 ++++++++ .../SALOME_ModuleCatalog_impl.hxx | 2 ++ src/Registry/RegistryService.cxx | 5 ++++ src/Registry/RegistryService.hxx | 1 + src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 14 +++++++++++ src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 6 +++++ src/Utils/Utils_ORB_INIT.cxx | 7 +++++- 17 files changed, 133 insertions(+), 1 deletion(-) diff --git a/idl/DSC_Engines.idl b/idl/DSC_Engines.idl index 83b558a59..0085608aa 100644 --- a/idl/DSC_Engines.idl +++ b/idl/DSC_Engines.idl @@ -342,6 +342,15 @@ module Engines { void disconnect(in connectionId id, in Engines::DSC::Message message) raises(Engines::ConnectionManager::BadId); + /*! + Shutdown the ConnectionManager process. + */ + oneway void ShutdownWithExit(); + + /*! + Returns the PID of the connection manager + */ + long getPID(); }; /*--------------------------------------------------------------------------------------------*/ diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index f4aea4bab..885da2c56 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -716,6 +716,16 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin void Shutdown(); +/*! + Returns the PID of the server +*/ + long getPID(); + +/*! + Shutdown the StudyManager process. +*/ + oneway void ShutdownWithExit(); + /*! \brief Creation of a new study Creates a new study with a definite name. diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index fe7700712..5013b402d 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -115,7 +115,12 @@ struct MachineParameters in ResPolicy policy, in CompoList componentList ); + oneway void ShutdownWithExit(); + void ShutdownContainers(); + + long getPID(); + } ; /*! \brief Interface of the %resourcesManager diff --git a/idl/SALOME_ModuleCatalog.idl b/idl/SALOME_ModuleCatalog.idl index 27f81b0f6..667bef10b 100644 --- a/idl/SALOME_ModuleCatalog.idl +++ b/idl/SALOME_ModuleCatalog.idl @@ -303,6 +303,16 @@ This interface is used for creation of the module catalog in %SALOME application { void ping(); +/*! + Returns the PID of the server +*/ + long getPID(); + +/*! + Shutdown the ModuleCatalog process. +*/ + oneway void ShutdownWithExit(); + /*! Gets a list of names of computers of the catalog */ diff --git a/idl/SALOME_Registry.idl b/idl/SALOME_Registry.idl index 8e4433215..5f27977f6 100644 --- a/idl/SALOME_Registry.idl +++ b/idl/SALOME_Registry.idl @@ -48,6 +48,7 @@ module Registry interface Components { void ping(); + long getPID(); unsigned long add ( in Infos lesInfos ) ; void remove ( in unsigned long id ) ; unsigned long size() ; diff --git a/idl/SALOME_Session.idl b/idl/SALOME_Session.idl index f067b753a..041df52a7 100644 --- a/idl/SALOME_Session.idl +++ b/idl/SALOME_Session.idl @@ -101,6 +101,10 @@ module SALOME Determines whether the server has already been loaded or not. */ void ping(); +/*! + Returns the PID of the server +*/ + long getPID(); /*! Get Active study ID */ diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 0fc39bd91..1b3fd4bde 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -105,6 +105,21 @@ void SALOME_ContainerManager::Shutdown() _remove_ref(); } +//============================================================================= +/*! CORBA method: + * shutdown the ContainerManager servant and kill the ContainerManager process + */ +//============================================================================= +void SALOME_ContainerManager::ShutdownWithExit() +{ + MESSAGE("ShutdownWithExit"); + PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); + _default_POA()->deactivate_object(oid); + _remove_ref(); + + exit( EXIT_SUCCESS ); +} + //============================================================================= /*! CORBA Method: * Loop on all the containers listed in naming service, ask shutdown on each @@ -144,6 +159,16 @@ void SALOME_ContainerManager::ShutdownContainers() } } +//============================================================================= +/*! CORBA Method: + * Returns the PID of the container manager + */ +//============================================================================= +CORBA::Long SALOME_ContainerManager::getPID() +{ + return (CORBA::Long)getpid(); +} + //============================================================================= /*! CORBA Method: * Find a suitable Container in a list of machines, or start one diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 34888f98c..b3485ab63 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -60,8 +60,11 @@ public: const Engines::CompoList& componentList); void Shutdown(); + void ShutdownWithExit(); void ShutdownContainers(); + CORBA::Long getPID(); + static const char *_ContainerManagerNameInNS; // Parallel extension diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.cxx b/src/DSC/DSC_Basic/ConnectionManager_i.cxx index 59f3b2624..6b1e376a6 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.cxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.cxx @@ -93,3 +93,15 @@ throw (Engines::ConnectionManager::BadId) delete infos; ids.erase(id); } + +void +ConnectionManager_i::ShutdownWithExit() +{ + exit( EXIT_SUCCESS ); +} + +CORBA::Long +ConnectionManager_i::getPID() +{ + return (CORBA::Long)getpid(); +} diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.hxx b/src/DSC/DSC_Basic/ConnectionManager_i.hxx index c0459f482..ebdfebf35 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.hxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.hxx @@ -67,6 +67,16 @@ class DSC_BASIC_EXPORT ConnectionManager_i : Engines::DSC::Message message) throw (Engines::ConnectionManager::BadId); + /*! + Shutdown the ConnectionManager process. + */ + void ShutdownWithExit(); + + /*! + Returns the PID of the connection manager + */ + CORBA::Long getPID(); + private : struct connection_infos { diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index f4cfd0797..ebd482b8d 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -551,6 +551,16 @@ SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name) return NULL; } +CORBA::Long SALOME_ModuleCatalogImpl::getPID() +{ + return (CORBA::Long)getpid(); +} + +void SALOME_ModuleCatalogImpl::ShutdownWithExit() +{ + exit( EXIT_SUCCESS ); +} + ParserComponent * SALOME_ModuleCatalogImpl::findComponent(const string & name) { diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index 0768c5de7..4c9334c84 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -104,6 +104,8 @@ public: GetComponentInfo(const char *name); void ping(){}; + CORBA::Long getPID(); + void ShutdownWithExit(); void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }; diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index 16c0b736c..52a3d1e9a 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -265,3 +265,8 @@ void RegistryService::ping() MESSAGE(" RegistryService::ping() pid "<< _getpid()); #endif } + +CORBA::Long RegistryService::getPID() +{ + return (CORBA::Long)getpid(); +} diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index 4315f9321..9b26f41f8 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -72,6 +72,7 @@ public : virtual ~RegistryService(void); void ping(); + CORBA::Long getPID(); virtual CORBA::ULong add (const Registry::Infos & infos); virtual CORBA::ULong size ( void ); #ifndef WNT diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 53b75016d..f06c882ba 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -450,6 +450,20 @@ PortableServer::POA_ptr SALOMEDS_StudyManager_i::GetPOA(const SALOMEDS::Study_pt return PortableServer::POA::_nil(); } +CORBA::Long SALOMEDS_StudyManager_i::getPID() +{ +#ifdef WIN32 + return (CORBA::Long)_getpid(); +#else + return (CORBA::Long)getpid(); +#endif +} + +void SALOMEDS_StudyManager_i::ShutdownWithExit() +{ + exit( EXIT_SUCCESS ); +} + //=========================================================================== // PRIVATE FUNCTIONS //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 2c85abb89..41118c5db 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -27,6 +27,10 @@ // std C++ headers #include +#ifndef WNT +#include +#endif + // IDL headers #include #include CORBA_SERVER_HEADER(SALOMEDS) @@ -136,6 +140,8 @@ public: virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); }; void ping(){}; + CORBA::Long getPID(); + void ShutdownWithExit(); virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index 0a8ddf697..1cb869e11 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -41,7 +41,12 @@ ORB_INIT::~ORB_INIT() if ( ! CORBA::is_nil( _orb ) ) { //std::cerr << "appel _orb->destroy()" << std::endl; - _orb->destroy() ; + try { + _orb->destroy() ; + } + catch(...) { + MESSAGE("Caught CORBA::Exception."); + } //std::cerr << "retour _orb->destroy()" << std::endl; } } -- 2.39.2