From 13b9de9350ae7f08a5c7bda233b372087f56bed6 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 17 Jan 2022 10:20:38 +0100 Subject: [PATCH] [tuleap26946] : SSL - Fix inconsistency between C++ and Python components --- idl/SALOME_Component.idl | 2 ++ src/Container/Container_i.cxx | 10 ++++++++- src/Container/SALOME_ComponentPy.py | 2 +- src/Container/SALOME_Container_i.hxx | 2 ++ .../SALOME_Fake_NamingService.cxx | 22 +++++++++++++++++-- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index d58943ad2..1481c75b8 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -152,6 +152,8 @@ module Engines //! In case of SSL mode Returns entry to Embedded NS EmbeddedNamingService get_embedded_NS_if_ssl(); + + boolean is_SSL_mode(); //! Unload component libraries from the container. void finalize_removal() ; diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 85c65cedd..ec3a46911 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -57,6 +57,7 @@ int SIGUSR1 = 1000; #include "SALOME_NamingService.hxx" #include "SALOME_Fake_NamingService.hxx" #include "SALOME_Embedded_NamingService_Client.hxx" +#include "SALOME_Embedded_NamingService.hxx" #include "Basics_Utils.hxx" #ifdef _XOPEN_SOURCE @@ -1562,7 +1563,14 @@ Engines::EmbeddedNamingService_ptr Abstract_Engines_Container_i::get_embedded_NS } else { - return Engines::EmbeddedNamingService::_nil(); + SALOME_Fake_NamingService *fns(dynamic_cast(this->_NS)); + if(fns) + { + Engines::EmbeddedNamingService_var ret = GetEmbeddedNamingService(); + return ret._retn(); + } + else + return Engines::EmbeddedNamingService::_nil(); } } diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 635f7e87e..c350df9cc 100644 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -302,7 +302,7 @@ class SALOME_ComponentPy_i(SALOME_ComponentPy_Gen_i): self._naming_service = SALOME_NamingServicePy_i(self._orb) else: self._naming_service = SALOME_Embedded_NamingService_ClientPy(emb_ns) - Component_path = self._containerName + "/" + self._instanceName + Component_path = contID.name + "/" + self._instanceName#self._containerName MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) ) self._naming_service.Register(self._compo_o, Component_path) # Add componentinstance to registry diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index ee2c5db54..d4d940d51 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -88,6 +88,8 @@ public: load_impl(const char *nameToRegister, const char *componentName); + bool is_SSL_mode() override { return this->isSSLMode(); } + Engines::EmbeddedNamingService_ptr get_embedded_NS_if_ssl() override; SALOME_NamingService_Container_Abstract *getNS() const { return _NS; } diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx index 2952fef9e..8796f1fca 100644 --- a/src/NamingService/SALOME_Fake_NamingService.cxx +++ b/src/NamingService/SALOME_Fake_NamingService.cxx @@ -160,9 +160,27 @@ SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone() CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc) { std::ostringstream oss; - oss << SEP << "Containers" << SEP << hostname << SEP << containerName << SEP << componentName; + oss << SEP << "Containers" << SEP << hostname << SEP << containerName << SEP << componentName << "_inst_"; std::string entryToFind(oss.str()); - return Resolve(entryToFind.c_str()); + { + std::lock_guard g(_mutex); + std::vector candidates; + for(auto it : _map) + { + if(it.first.find(entryToFind) == 0) + candidates.push_back(it.first); + } + if(candidates.size() == 1) + { + auto it = _map.find(candidates[0]); + return CORBA::Object::_duplicate((*it).second); + } + else + { + return CORBA::Object::_nil(); + } + + } } std::vector< std::pair< std::string, Engines::Container_var> > SALOME_Fake_NamingService::ListOfContainersInNS_NoThreadSafe() -- 2.39.2