From fdeb9cc274791a2d6c24f7b82927662cedc1d04a Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 8 Apr 2004 06:48:48 +0000 Subject: [PATCH] PR: correction for application shutdown --- src/Session/SALOME_Session_Server.cxx | 3 +++ src/Session/Session_ServerLauncher.cxx | 19 +++++++++++++++++-- src/Session/Session_ServerLauncher.hxx | 5 ++--- src/Session/Session_ServerThread.cxx | 15 ++------------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 408ed1728..26babef31 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -222,6 +222,8 @@ int main(int argc, char **argv) MESSAGE (confMsg ); QAD_CONFIG->createConfigFile(true); } + orb->shutdown(0); + myServerLauncher->KillAll(); aCatch.Deactivate(); } catch (SALOME_Exception& e) @@ -249,5 +251,6 @@ int main(int argc, char **argv) { INFOS("Caught unknown exception."); } + MESSAGE("End of SALOME_Session_Server"); return 0 ; } diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx index 54cf11cba..e9def60fb 100644 --- a/src/Session/Session_ServerLauncher.cxx +++ b/src/Session/Session_ServerLauncher.cxx @@ -197,7 +197,7 @@ void Session_ServerLauncher::ActivateAll() } Session_ServerThread* aServerThread = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex); - _serverThreads.push_back(aServerThread); + _serverThreads.push_front(aServerThread); aServerThread->Init(); } @@ -209,8 +209,23 @@ void Session_ServerLauncher::ActivateAll() argv[0] = "Session"; Session_ServerThread* aServerThread = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex); - _serverThreads.push_back(aServerThread); + _serverThreads.push_front(aServerThread); aServerThread->Init(); } +//============================================================================= +/*! + * Destruction des classes serveur dans l'ordre inverse de creation + */ +//============================================================================= + +void Session_ServerLauncher::KillAll() +{ + MESSAGE("Session_ServerLauncher::KillAll()"); + list::iterator itServ; + for (itServ = _serverThreads.begin(); itServ !=_serverThreads.end(); itServ++) + { + delete (*itServ); + } +} diff --git a/src/Session/Session_ServerLauncher.hxx b/src/Session/Session_ServerLauncher.hxx index 893754ac0..45804e17d 100644 --- a/src/Session/Session_ServerLauncher.hxx +++ b/src/Session/Session_ServerLauncher.hxx @@ -65,14 +65,13 @@ public: QWaitCondition *ServerLaunch); virtual ~Session_ServerLauncher(); void run(); -protected: + void KillAll(); +protected: void CheckArgs(); - void ActivateAll(); private: - int _argc; char ** _argv; CORBA::ORB_var _orb; diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index 3e61eea0a..e5e4f055c 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -237,16 +237,13 @@ void Session_ServerThread::ActivateModuleCatalog(int argc, SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); - MESSAGE("---"); + // Tell the POA that the objects are ready to accept requests. _root_poa->activate_object (Catalogue_i); - MESSAGE("---"); CORBA::Object_ptr myCata = Catalogue_i->_this(); - MESSAGE("---"); _NS->Register(myCata ,"/Kernel/ModulCatalog"); - MESSAGE("---"); } catch(CORBA::SystemException&) { @@ -293,7 +290,6 @@ void Session_ServerThread::ActivateSALOMEDS(int argc, PortableServer::ObjectId_var myStudyManager_iid = _root_poa->activate_object(myStudyManager_i); - myStudyManager_i->register_name("/myStudyManager"); } catch(CORBA::SystemException&) @@ -350,8 +346,7 @@ void Session_ServerThread::ActivateRegistry(int argc, Registry::Components_var varComponents; try { - //RegistryService *ptrRegistry = SINGLETON_::Instance(); - RegistryService *ptrRegistry = new RegistryService(); + RegistryService *ptrRegistry = SINGLETON_::Instance(); ptrRegistry->SessionName( ptrSessionName ); varComponents = ptrRegistry->_this(); // The RegistryService must not already exist. @@ -408,12 +403,10 @@ void Session_ServerThread::ActivateContainer(int argc, PortableServer::ImplicitActivationPolicy_var implicitActivation = _root_poa->create_implicit_activation_policy( PortableServer::NO_IMPLICIT_ACTIVATION); - MESSAGE("---"); // default = NO_IMPLICIT_ACTIVATION PortableServer::ThreadPolicy_var threadPolicy = _root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL); // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL - MESSAGE("---"); // create policy list CORBA::PolicyList policyList; @@ -422,7 +415,6 @@ void Session_ServerThread::ActivateContainer(int argc, _duplicate(implicitActivation); policyList[1] = PortableServer::ThreadPolicy:: _duplicate(threadPolicy); - MESSAGE("---"); PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil(); @@ -431,12 +423,10 @@ void Session_ServerThread::ActivateContainer(int argc, policyList); //with nil_mgr instead of pman, //a new POA manager is created with the new POA - MESSAGE("---"); // destroy policy objects implicitActivation->destroy(); threadPolicy->destroy(); - MESSAGE("---"); // obtain the factory poa manager PortableServer::POAManager_var pmanfac = factory_poa->the_POAManager(); @@ -444,7 +434,6 @@ void Session_ServerThread::ActivateContainer(int argc, MESSAGE("pmanfac->activate()"); } - MESSAGE("---"); char *containerName = ""; if (argc >1) { -- 2.39.2