From a699cf9821d01dc9c607701e2d2db0ac877c0c4e Mon Sep 17 00:00:00 2001 From: caremoli Date: Sun, 8 Jun 2008 13:18:40 +0000 Subject: [PATCH] CCAR: solve some problems during shutdown - singletons are deleted at exit (atexit function is called at the beginning of programs) but order is important. Trace singleton must be destroyed last because MESSAGE and others are called in destructor of other singletons. So I have enforced local trace initialization in ATEXIT_ class from Utils directory - Improve Registry shutdown (called _remove_ref to delete RegistryService object) - add a delay between shutdown servers and kill omninames in shutdownSalome.py --- bin/shutdownSalome.py | 5 ++++- src/Registry/RegistryService.hxx | 2 +- src/Registry/SALOME_Registry_Server.cxx | 1 + src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 3 +++ src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/shutdownSalome.py b/bin/shutdownSalome.py index 491266662..9f9cd6d80 100755 --- a/bin/shutdownSalome.py +++ b/bin/shutdownSalome.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +import time import salome salome.salome_init() salome.lcc.shutdownServers() -salome.SALOME_LifeCycleCORBA_killOmniNames() +#give some time to shutdown to complete +time.sleep(1) +salome.LifeCycleCORBA.killOmniNames() diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index 9b26f41f8..bc6097fcd 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -89,7 +89,7 @@ public : void SessionName( const char *sessionName ) ; - void SetOrb( CORBA::ORB_ptr orb ) { _orb = orb; return; } + void SetOrb( CORBA::ORB_ptr orb ) { _orb = CORBA::ORB::_duplicate(orb); return; } void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 50e608f31..8183340c2 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -170,6 +170,7 @@ int main( int argc , char **argv ) ptrRegistry->SessionName( ptrSessionName ) ; ptrRegistry->SetOrb(orb); varComponents = ptrRegistry->_this() ; + ptrRegistry->_remove_ref(); //let poa manage registryservice deletion // The RegistryService must not already exist. try diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx index 61239063a..71818af97 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -36,6 +36,7 @@ extern "C" # include "Utils_DESTRUCTEUR_GENERIQUE.hxx" //# include "utilities.h" +# include "LocalTraceBufferPool.hxx" void Nettoyage(); #ifdef _DEBUG_ @@ -83,6 +84,8 @@ public : DESTRUCTEUR_GENERIQUE_::Destructeurs = new std::list ; // Destructeur alloue dynamiquement (cf. ci-dessous) , // il est utilise puis detruit par la fonction Nettoyage + //To be sure the trace singleton will be the last one to be destroyed initialize it here before calling atexit + LocalTraceBufferPool::instance(); int cr = atexit( Nettoyage ); // execute Nettoyage lors de exit, aprs la destruction des donnees statiques ! assert(cr==0) ; ATEXIT_Done = true ; diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx index 9ae866266..54e0bcd22 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -140,4 +140,4 @@ private : }; -# endif /* # if !defined( __SINGLETON__H__ ) */ +# endif /* # if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) */ -- 2.39.2