]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: improve the shutdown process
authorcaremoli <caremoli>
Mon, 22 Mar 2010 09:23:39 +0000 (09:23 +0000)
committercaremoli <caremoli>
Mon, 22 Mar 2010 09:23:39 +0000 (09:23 +0000)
1- use salome_kernel.py module instead of salome.py in shutdownSalome.py to avoid calling Study
2- disconnect all connections in the connection manager
3- change the order of servers shutdown :
    - connection manager
    - study
    - module catalog
    - registry
    - launcher
    - logger
and add some waiting time between each shutdown because it is asynchronous.

bin/shutdownSalome.py
src/DSC/DSC_Basic/ConnectionManager_i.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/SALOMEDS/SALOMEDS_Server.cxx

index a7826c4643c77655042f382ea8ed246650e02bdb..775b8f04ebd18208ee8f34ef3168c85104b5c0ca 100755 (executable)
 ## \file shutdownSalome.py
 #  shutdown all %SALOME servers and naming service
 #
-#  
+#
 
 import time
-import salome
-salome.salome_init()
-salome.lcc.shutdownServers()
+import salome_kernel
+orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
+lcc.shutdownServers()
 #give some time to shutdown to complete
 time.sleep(1)
-salome.LifeCycleCORBA.killOmniNames()
+salome_kernel.LifeCycleCORBA.killOmniNames()
index 04a2706c3d2b2eaed7ce7a6ac45d5d1ab66073fe..6aa0e345051881c0c36b10bea097b715c329cb04 100644 (file)
@@ -92,8 +92,7 @@ ConnectionManager_i::disconnect(Engines::ConnectionManager::connectionId id,
   connection_infos * infos = ids[id];
   try
     {
-      infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(),
-                                                      message);
+      infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(), message);
     }
   catch(CORBA::SystemException& ex)
     {
@@ -103,8 +102,7 @@ ConnectionManager_i::disconnect(Engines::ConnectionManager::connectionId id,
   try
     {
       infos->uses_component->disconnect_uses_port(infos->uses_port_name.c_str(),
-                                              infos->provides_port,
-                                              message);
+                                                  infos->provides_port, message);
     }
   catch(CORBA::SystemException& ex)
     {
@@ -121,10 +119,16 @@ ConnectionManager_i::disconnect(Engines::ConnectionManager::connectionId id,
 void
 ConnectionManager_i::ShutdownWithExit()
 {
+  ids_it = ids.begin();
+  while(ids_it != ids.end())
+    {
+      disconnect(ids_it->first, Engines::DSC::RemovingConnection);
+      ids_it = ids.begin();
+    }
+
   if(!CORBA::is_nil(_orb))
     _orb->shutdown(0);
 
-  //exit( EXIT_SUCCESS );
 }
 
 CORBA::Long
index c1c8b1a572213b543c3f1ee6f259a70ae90a8df8..a9612b4b51e886ded0768e6662d5150e9187f922 100644 (file)
@@ -33,6 +33,7 @@
 #include <time.h>
 #ifndef WIN32
   #include <sys/time.h>
+  #include <unistd.h>
 #endif
 
 #include "Basics_Utils.hxx"
@@ -530,36 +531,95 @@ void SALOME_LifeCycleCORBA::shutdownServers()
 
   string hostname = Kernel_Utils::GetHostname();
   
-  // 1) SalomeLauncher
-  CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
-  Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
-  if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
-    launcher->Shutdown();
-  
-  // 2) ConnectionManager
-  CORBA::Object_var objCnM=_NS->Resolve("/ConnectionManager");
-  Engines::ConnectionManager_var connMan=Engines::ConnectionManager::_narrow(objCnM);
-  if ( !CORBA::is_nil(connMan) && ( pid != connMan->getPID() ) )
-    connMan->ShutdownWithExit();
-  
-  // 3) SALOMEDS
-  CORBA::Object_var objSDS = _NS->Resolve("/myStudyManager");
-  SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow(objSDS) ;
-  if ( !CORBA::is_nil(studyManager) && ( pid != studyManager->getPID() ) )
-    studyManager->Shutdown();
-  
-  // 4) ModuleCatalog
-  CORBA::Object_var objMC=_NS->Resolve("/Kernel/ModulCatalog");
-  SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
-  if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
-    catalog->shutdown();
-  
-  // 5) Registry
-  CORBA::Object_var objR = _NS->Resolve("/Registry");
-  Registry::Components_var registry = Registry::Components::_narrow(objR);
-  if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
-      registry->Shutdown();
+  // 1) ConnectionManager
+  try
+    {
+      CORBA::Object_var objCnM=_NS->Resolve("/ConnectionManager");
+      Engines::ConnectionManager_var connMan=Engines::ConnectionManager::_narrow(objCnM);
+      if ( !CORBA::is_nil(connMan) && ( pid != connMan->getPID() ) )
+        connMan->ShutdownWithExit();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+
+  timespec ts_req;
+  ts_req.tv_nsec=100000000;
+  ts_req.tv_sec=0;
+
+//Wait some time so that ConnectionManager be completely shutdown
+#ifndef WIN32
+  nanosleep(&ts_req,0);
+#endif
+
+  // 2) SALOMEDS
+  try
+    {
+      CORBA::Object_var objSDS = _NS->Resolve("/myStudyManager");
+      SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow(objSDS) ;
+      if ( !CORBA::is_nil(studyManager) && ( pid != studyManager->getPID() ) )
+        studyManager->Shutdown();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+
+//Wait some time so that study be completely shutdown
+#ifndef WIN32
+  nanosleep(&ts_req,0);
+#endif
+
+  // 3) ModuleCatalog
+  try
+    {
+      CORBA::Object_var objMC=_NS->Resolve("/Kernel/ModulCatalog");
+      SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
+      if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
+        catalog->shutdown();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+
+//Wait some time so that ModulCatalog be completely shutdown
+#ifndef WIN32
+  nanosleep(&ts_req,0);
+#endif
 
+  // 4) Registry
+  try
+    {
+      CORBA::Object_var objR = _NS->Resolve("/Registry");
+      Registry::Components_var registry = Registry::Components::_narrow(objR);
+      if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
+          registry->Shutdown();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+
+//Wait some time so that registry be completely shutdown
+#ifndef WIN32
+  nanosleep(&ts_req,0);
+#endif
+
+  // 5) SalomeLauncher
+  try
+    {
+      CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
+      Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
+      if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
+        launcher->Shutdown();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+  
   // 6) Logger
   int argc = 0;
   char *xargv = (char*)"";
index 26e9474e7187e0cc70025b3e0b8e6e0dc7decea6..e27fd0d1492ad658359370fa5cd616d23d139017 100644 (file)
@@ -175,6 +175,7 @@ int main(int argc, char** argv)
       timer.ShowAbsolute();
 #endif
       orb->run();
+      MESSAGE( "end of SALOME_DS server" );
       orb->destroy();
     }
   catch(CORBA::SystemException&)