]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Last tuning
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 19 Jun 2019 08:46:28 +0000 (10:46 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 19 Jun 2019 08:46:28 +0000 (10:46 +0200)
idl/SALOME_CommonTypes.idl
idl/SALOME_ExternalServerLauncher.idl
idl/SALOME_SDS.idl
src/Container/SALOME_ContainerManager.cxx
src/Launcher/SALOME_ExternalServerLauncher.cxx
src/Launcher/SALOME_ExternalServerLauncher.hxx

index f5e62485d09acdff56759e50968521f0860454c2..ba3eaa085398c56de4b9d51ed5554bd2906b0ef0 100644 (file)
@@ -25,6 +25,7 @@ module SALOME
 {
   typedef sequence<string> StringVec;
   typedef sequence<long> LongVec;
+  typedef sequence<octet> ByteVec;
 };
 
 #endif
index cee79cb764998124056124297c168492d8f82afe..2f9efcd12b78af8fb801f43fa9d7af56044c882d 100644 (file)
@@ -47,6 +47,7 @@ module SALOME
     void registerToKill(in string server_name, in long PID) raises (SALOME::SALOME_Exception);
     void shutdownServers() raises (SALOME::SALOME_Exception);
     string gethostname();
+    ByteVec fetchContentOfFileAndRm(in string file_name) raises (SALOME::SALOME_Exception);
   };
 };
 
index 749b400aaa5ab21e7648e36738904095d5e009f5..98447e142cdefe9e48d00bac867c9027bc38a104 100644 (file)
@@ -28,7 +28,6 @@
 
 module SALOME
 {
-  typedef sequence<octet> ByteVec;
   typedef sequence<ByteVec> SeqOfByteVec;
   
   interface DataScopeServer;
index c50c8c0f81ed0ed45fa4831c20a7a35bbe094b4f..608fda19d53d5b3477825ecd53ed604fe56e7837 100644 (file)
@@ -1407,10 +1407,10 @@ long SALOME_ContainerManager::SystemWithPIDThreadSafe(const std::vector<std::str
   pid_t pid ( fork() ) ; // spawn a child process, following code is executed in both processes
   if ( pid == 0 ) // I'm a child, replace myself with a new ompi-server
     {
-      std::size_t sz(command.size()-1);
+      std::size_t sz(command.size());
       char **args = new char *[sz+1];
       for(std::size_t i=0;i<sz;i++)
-        args[i] = strdup(command[i+1].c_str());
+        args[i] = strdup(command[i].c_str());
       args[sz] = nullptr;
       execvp( command[0].c_str() , args );
       std::ostringstream oss;
index 6ef363251df58058263b02bce276b0fdf858011d..2f2bc73d49329c09dc6461dd8c6f5be115c3d3b6 100644 (file)
@@ -30,7 +30,9 @@
 #include <unistd.h>
 
 #include <sstream>
+#include <fstream>
 #include <algorithm>
+#include <memory>
 
 constexpr char NAME_IN_NS[]="/ExternalServers";
 
@@ -156,6 +158,33 @@ char *SALOME_ExternalServerLauncher::gethostname()
   return CORBA::string_dup(ret.c_str());
 }
 
+SALOME::ByteVec *SALOME_ExternalServerLauncher::fetchContentOfFileAndRm(const char *file_name)
+{
+  std::ifstream t(file_name);
+  if(!t.good())
+    {
+      std::ostringstream oss; oss << "SALOME_ExternalServerLauncher::fetchContentOfFileAndRm : Error when trying to open \"" <<  file_name << "\" file !";
+      throw SALOME_LauncherException(oss.str());
+    }
+  t.seekg(0, std::ios::end);
+  size_t size(t.tellg());
+  std::unique_ptr<char,std::function<void(char *)> > buffer(new char[size],[](char *pt) { delete [] pt; });
+  t.seekg(0);
+  t.read(buffer.get(),size);
+  //
+  std::unique_ptr<SALOME::ByteVec> ret(new SALOME::ByteVec);
+  ret->length(size);
+  for(std::size_t i=0;i<size;++i)
+    (*ret)[i] = buffer.get()[i];
+  //
+  if( unlink(file_name)!=0 )
+    {
+      std::cerr << "Error when trying to remove \"" << file_name << "\" !";
+    }
+  //
+  return ret.release();
+}
+
 std::vector<std::string> SALOME_ExternalServerLauncher::ListOfExternalServersCpp(SALOME_NamingService *ns)
 {
   ns->Change_Directory(NAME_IN_NS);
index 32824e6d5caac5c3ea15a83e1cc377f7454a65b7..e83016df9e1a60bb414c90b52e0d38359e71af79 100644 (file)
@@ -45,6 +45,7 @@ class SALOMELAUNCHER_EXPORT SALOME_ExternalServerLauncher : public POA_SALOME::E
   SALOME::StringVec *listServersInNS() override;
   SALOME::ExternalServerHandler_ptr retrieveServerRefGivenNSEntry( const char *ns_entry ) override;
   char *gethostname() override;
+  SALOME::ByteVec *fetchContentOfFileAndRm(const char *file_name) override;
   const SALOME_CPythonHelper *getPyHelper() const { return _pyHelper; }
  private:
   static std::string CreateAbsNameInNSFromServerName(const std::string& scopeName);