Salome HOME
With kill using LifeCycle destroy extra pids registered into SALOME_ExternalServerLau... V9_4_0a1
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Sep 2019 09:27:54 +0000 (11:27 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Sep 2019 09:27:54 +0000 (11:27 +0200)
src/Launcher/SALOME_ExternalServerHandler.cxx
src/Launcher/SALOME_ExternalServerHandler.hxx
src/Launcher/SALOME_ExternalServerLauncher.cxx
src/Launcher/SALOME_ExternalServerLauncher.hxx
src/LifeCycleCORBA/CMakeLists.txt
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx

index ddda9a766eae710e62527756b8416caeee8de1bc..14ca4cbaaa5991a6fbb1ec8b88cf0c96904f31e2 100644 (file)
@@ -61,13 +61,18 @@ char *SALOME_ExternalServerHandler::getName()
   return CORBA::string_dup(_name.c_str());
 }
 
-void SALOME_ExternalServerHandler::killMe()
+void SALOME_ExternalServerHandler::KillPID(long pid)
 {
 #ifndef WIN32
-  kill(_pid,SIGTERM);//SIGTERM is emitted not SIGKILL to give _pid process a chance to trap it.
+  kill(pid,SIGTERM);//SIGTERM is emitted not SIGKILL to give _pid process a chance to trap it.
 #endif
 }
 
+void SALOME_ExternalServerHandler::killMe()
+{
+  KillPID(_pid);
+}
+
 void SALOME_ExternalServerHandler::ping()
 {
 #ifndef WIN32
index 045ec4c50760ac4028b8bf4fcd8fff48c2a84b09..1d69b78fca4cf564157c395f2fcf09846ec7f275 100644 (file)
@@ -38,6 +38,7 @@ class SALOMELAUNCHER_EXPORT SALOME_ExternalServerHandler : public POA_SALOME::Ex
   SALOME_ExternalServerHandler(SALOME_ExternalServerLauncher *boss, const std::string& name, SALOME_NamingService *ns, long pid);
   virtual ~SALOME_ExternalServerHandler();
   void registerToKill(const SALOME_CPythonHelper *pyHelper) const;
+  static void KillPID(long pid);
  public:
   CORBA::Long getPID() override;
   char *getName() override;
index 4574819ee72f3aec16f4458b73b489a4537e1d07..7a3f0173627b2051d9f40979f20d77e5e263a5bd 100644 (file)
@@ -40,7 +40,7 @@
 #include <memory>
 #include <functional>
 
-constexpr char NAME_IN_NS[]="/ExternalServers";
+const char SALOME_ExternalServerLauncher::NAME_IN_NS[]="/ExternalServers";
 
 unsigned SALOME_ExternalServerLauncher::CNT = 0;
 
@@ -121,6 +121,7 @@ void SALOME_ExternalServerLauncher::registerToKill(const char *server_name, CORB
   std::ostringstream oss;
   oss << "Custom_"<< server_name << "_" << CNT++;
   _pyHelper->registerToSalomePiDict(oss.str(),PID);
+  _list_of_pids_to_kill.push_back(PID);
 }
 
 void SALOME_ExternalServerLauncher::cleanServersInNS()
@@ -138,6 +139,11 @@ void SALOME_ExternalServerLauncher::cleanServersInNS()
 
 void SALOME_ExternalServerLauncher::shutdownServers()
 {
+  for(auto pid : this->_list_of_pids_to_kill)
+    {
+      SALOME_ExternalServerHandler::KillPID(pid);
+    }
+  //
   std::vector<std::string> lioes(ListOfExternalServersCpp(_NS));
   for(auto servName : lioes)
     {
index e83016df9e1a60bb414c90b52e0d38359e71af79..9eaa3b57471e7bdd3c9095fca37b1bae4c82a014 100644 (file)
@@ -58,4 +58,7 @@ class SALOMELAUNCHER_EXPORT SALOME_ExternalServerLauncher : public POA_SALOME::E
   SALOME_NamingService *_NS = nullptr;
   PortableServer::POA_var _poa;
   static unsigned CNT;
+  std::vector<long> _list_of_pids_to_kill;
+ public:
+  static const char NAME_IN_NS[];
 };
index 10563420b9c9fc80b73ec2877f769c2696a64b06..3be0eff8edda17702266cb3c8b360de89c744ec8 100644 (file)
@@ -33,6 +33,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Batch
   ${CMAKE_CURRENT_SOURCE_DIR}/../Notification
   ${CMAKE_CURRENT_SOURCE_DIR}/../Registry
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Launcher
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMESDS
   ${PROJECT_BINARY_DIR}/idl
 )
@@ -47,6 +48,7 @@ SET(COMMON_LIBS
   SALOMEBasics
   SalomeGenericObj
   SalomeIDLKernel
+  SalomeLauncher
 )
 
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
index 1e3ce0cdacd718cee85886f4c1f84a3327db84e5..5351562b6a091d59a55a15ace2e8a588f12981b0 100644 (file)
@@ -44,6 +44,7 @@
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "SALOME_ResourcesManager.hxx"
 #include "SALOMESDS_DataServerManager.hxx"
+#include "SALOME_ExternalServerLauncher.hxx"
 
 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
 #include CORBA_CLIENT_HEADER(SALOME_Session)
@@ -499,7 +500,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
 #ifndef WIN32
   nanosleep(&ts_req,0);
 #endif
-  // 4 ) Remote ScopeServer (the DataServer is hosted by SalomeLauncher shutdown right after)
+  // 4 ) Remote ScopeServer (the DataServer is hosted by SalomeLauncher shutdown right after on point 6)
   try
     {
       CORBA::Object_var objDSM(_NS->Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
@@ -511,8 +512,19 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
     {
        // ignore and continue
     }
-
-  // 5) SalomeLauncher
+  // 5) External server launcher (the ExternalServer is hosted by SalomeLauncher shutdown right after on point 6)
+  try
+    {
+      CORBA::Object_var objDSM(_NS->Resolve(SALOME_ExternalServerLauncher::NAME_IN_NS));
+      SALOME::ExternalServerLauncher_var dsm(SALOME::ExternalServerLauncher::_narrow(objDSM));
+      if ( !CORBA::is_nil(dsm) )
+        dsm->shutdownServers();
+    }
+  catch(const CORBA::Exception& e)
+    {
+       // ignore and continue
+    }
+  // 6) SalomeLauncher
   try
     {
       if(shutdownLauncher){