From e3ddecc841b77c3061ae62992c1208146d6f3bc1 Mon Sep 17 00:00:00 2001 From: caremoli Date: Fri, 23 Nov 2007 14:45:05 +0000 Subject: [PATCH] CCAR: several debugs in DSC ports and launcher - better disconnect for DSC ports when a container has gone (all files in DSC directory and DSC_Engines.idl) - catch SALOME_Exception in YACS : need the typecode in IDL lib (add SALOME_ExceptionDynSK.cc in Makefile.am) - remove existing entry in naming service on StartContainer (SALOME_ContainerManager.cxx) : risk of unconsistency - catch CORBA SystemException in FindNext : unable to start containers when component instances exist and when container has gone - remove exit in ShutdownWithExit : right way to stop servers is to call orb->shutdown(0) in a CORBA method, call orb->destroy() in the main thread after orb->run() and to have called _remove_ref on main servants (SALOME_ContainerManager.cxx, SALOME_Launcher.cxx, SALOME_LauncherServer.cxx). - remove memory leaks : use valgrind on Launcher and ConnectionManagerServer; several small modifications in many files. --- idl/DSC_Engines.idl | 5 +- idl/Makefile.am | 1 + src/Container/SALOME_ContainerManager.cxx | 42 +++++++---- src/DSC/DSC_Basic/ConnectionManager_i.cxx | 43 ++++++++--- src/DSC/DSC_Basic/ConnectionManager_i.hxx | 16 ++-- .../SALOME_ConnectionManagerServer.cxx | 1 + .../Calcium/CalciumGenericProvidesPort.hxx | 9 ++- .../Calcium/CalciumGenericUsesPort.hxx | 5 +- .../Datastream/Calcium/CalciumInterface.hxx | 20 ++++- src/Launcher/SALOME_Launcher.cxx | 4 +- src/Launcher/SALOME_LauncherServer.cxx | 12 ++- src/NamingService/SALOME_NamingService.cxx | 7 +- .../SALOME_LoadRateManager.cxx | 26 ++++++- .../SALOME_ResourcesCatalog_Handler.cxx | 74 +++++++++++++++---- .../SALOME_ResourcesManager.cxx | 7 +- src/SALOMELocalTrace/LocalTraceCollector.cxx | 1 + 16 files changed, 204 insertions(+), 69 deletions(-) diff --git a/idl/DSC_Engines.idl b/idl/DSC_Engines.idl index 0085608aa..25c6ec7eb 100644 --- a/idl/DSC_Engines.idl +++ b/idl/DSC_Engines.idl @@ -340,7 +340,10 @@ module Engines { \exception Engines::ConnectionManager::BadId */ void disconnect(in connectionId id, - in Engines::DSC::Message message) raises(Engines::ConnectionManager::BadId); + in Engines::DSC::Message message) raises(Engines::ConnectionManager::BadId, + Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected, + Engines::DSC::BadPortReference); /*! Shutdown the ConnectionManager process. diff --git a/idl/Makefile.am b/idl/Makefile.am index 70837010e..f763c738a 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -95,6 +95,7 @@ BASEIDL_SOURCES =\ Palm_PortsSK.cc DYNIDL_SOURCES=\ + SALOME_ExceptionDynSK.cc \ Calcium_PortsDynSK.cc MPIIDL_SOURCES = \ diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 1b3fd4bde..e8465c7af 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -113,11 +113,12 @@ void SALOME_ContainerManager::Shutdown() void SALOME_ContainerManager::ShutdownWithExit() { MESSAGE("ShutdownWithExit"); - PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); - _default_POA()->deactivate_object(oid); - _remove_ref(); - - exit( EXIT_SUCCESS ); + if(!CORBA::is_nil(_orb)) + { + _orb->shutdown(0); + } + + //exit( EXIT_SUCCESS ); } //============================================================================= @@ -260,6 +261,28 @@ StartContainer(const Engines::MachineParameters& params, command = _ResManager->BuildCommandToLaunchRemoteContainer(theMachine,params,id); _ResManager->RmTmpFile(); + + //check if an entry exists in Naming service + if(params.isMPI) + { + containerNameInNS = "/ContainerManager/id"; + sprintf(idc,"%ld",id); + containerNameInNS += idc; + } + else + containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str()); + + SCRUTE(containerNameInNS); + CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); + if ( !CORBA::is_nil(obj) ) + { + // unregister the registered container if it exists + _NS->Destroy_Name(containerNameInNS.c_str()); + // unregister component instances ??? + //Engines::Container_var cont=Engines::Container::_narrow(obj); + } + + // launch container with a system call int status=system(command.c_str()); if (status == -1){ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " << @@ -284,15 +307,6 @@ StartContainer(const Engines::MachineParameters& params, if ( count != 10 ) MESSAGE( count << ". Waiting for container on " << theMachine); - if(params.isMPI){ - containerNameInNS = "/ContainerManager/id"; - sprintf(idc,"%ld",id); - containerNameInNS += idc; - } - else - containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str()); - - SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); ret=Engines::Container::_narrow(obj); } diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.cxx b/src/DSC/DSC_Basic/ConnectionManager_i.cxx index 6b1e376a6..2f7f089c9 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.cxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.cxx @@ -27,9 +27,13 @@ #include "SALOME_NamingService.hxx" ConnectionManager_i::ConnectionManager_i(CORBA::ORB_ptr orb) { + _orb = CORBA::ORB::_duplicate(orb) ; SALOME_NamingService * ns = new SALOME_NamingService(orb); const char * ConnectionManagerNameInNS = "/ConnectionManager"; - ns->Register(_this(), ConnectionManagerNameInNS); + CORBA::Object_var obref = _this(); + _remove_ref(); + ns->Register(obref, ConnectionManagerNameInNS); + delete ns; current_id = 0; pthread_mutex_init(&mutex, NULL); @@ -42,12 +46,9 @@ ConnectionManager_i::connect(Engines::DSC_ptr uses_component, const char* uses_port_name, Engines::DSC_ptr provides_component, const char* provides_port_name) -throw (Engines::DSC::PortNotDefined, - Engines::DSC::BadPortType, - Engines::DSC::NilPort) { - Ports::Port_ptr p_port = provides_component->get_provides_port(provides_port_name, false); + Ports::Port_var p_port = provides_component->get_provides_port(provides_port_name, false); uses_component->connect_uses_port(uses_port_name, p_port); provides_component->connect_provides_port(provides_port_name); @@ -75,8 +76,8 @@ throw (Engines::DSC::PortNotDefined, void ConnectionManager_i::disconnect(Engines::ConnectionManager::connectionId id, Engines::DSC::Message message) -throw (Engines::ConnectionManager::BadId) { + int err=0; // Connection id exist ? ids_it = ids.find(id); if (ids_it == ids.end()) @@ -85,19 +86,41 @@ throw (Engines::ConnectionManager::BadId) // TODO // We need to catch exceptions if one of these disconnect operation fails. connection_infos * infos = ids[id]; - infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(), + try + { + infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(), message); - infos->uses_component->disconnect_uses_port(infos->uses_port_name.c_str(), - Ports::Port::_duplicate(infos->provides_port), + } + catch(CORBA::SystemException& ex) + { + std::cerr << "Problem in disconnect(CORBA::SystemException) provides port: " << infos->provides_port_name << std::endl; + err=1; + } + try + { + infos->uses_component->disconnect_uses_port(infos->uses_port_name.c_str(), + infos->provides_port, message); + } + catch(CORBA::SystemException& ex) + { + std::cerr << "Problem in disconnect(CORBA::SystemException) uses port: " << infos->uses_port_name << std::endl; + err=1; + } delete infos; ids.erase(id); + + if(err) + throw Engines::DSC::BadPortReference(); } void ConnectionManager_i::ShutdownWithExit() { - exit( EXIT_SUCCESS ); + if(!CORBA::is_nil(_orb)) + _orb->shutdown(0); + + //exit( EXIT_SUCCESS ); } CORBA::Long diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.hxx b/src/DSC/DSC_Basic/ConnectionManager_i.hxx index ebdfebf35..7696fc676 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.hxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.hxx @@ -52,10 +52,7 @@ class DSC_BASIC_EXPORT ConnectionManager_i : Engines::ConnectionManager::connectionId connect(Engines::DSC_ptr uses_component, const char* uses_port_name, Engines::DSC_ptr provides_component, - const char* provides_port_name) - throw (Engines::DSC::PortNotDefined, - Engines::DSC::BadPortType, - Engines::DSC::NilPort); + const char* provides_port_name); /*! * CORBA method : releases a connection performed with @@ -64,8 +61,7 @@ class DSC_BASIC_EXPORT ConnectionManager_i : * \see Engines::ConnectionManager::disconnect */ void disconnect(Engines::ConnectionManager::connectionId id, - Engines::DSC::Message message) - throw (Engines::ConnectionManager::BadId); + Engines::DSC::Message message); /*! Shutdown the ConnectionManager process. @@ -80,11 +76,11 @@ class DSC_BASIC_EXPORT ConnectionManager_i : private : struct connection_infos { - Engines::DSC_ptr uses_component; + Engines::DSC_var uses_component; std::string uses_port_name; - Engines::DSC_ptr provides_component; + Engines::DSC_var provides_component; std::string provides_port_name; - Ports::Port_ptr provides_port; + Ports::Port_var provides_port; }; typedef std::mapactivate(); orb->run(); + orb->destroy(); }catch(CORBA::SystemException&){ MESSAGE("Caught CORBA::SystemException."); }catch(PortableServer::POA::WrongPolicy&){ diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx index e10e1dac3..b419e3869 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx @@ -128,7 +128,14 @@ virtual CORBA::Any* get_property(const char* name) \ throw (Ports::NotDefined); \ \ - }; \ + virtual void provides_port_changed(int connection_nbr, \ + const Engines::DSC::Message message) { \ + if ( !connection_nbr && (message == Engines::DSC::RemovingConnection) ) \ + { \ + disconnect(false); \ + } \ + } \ + }; \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx index e5db43dc3..a71b9f547 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx @@ -53,12 +53,11 @@ CalciumGenericUsesPort< DataManipulator,CorbaPortType, repositoryName >::disconn for(int i = 0; i < this->_my_ports->length(); i++) { CorbaPortTypePtr port = CorbaPortType::_narrow((*this->_my_ports)[i]); try { - std::cerr << "-------- CalciumGenericUsesPort<>::disconnect"<< std::endl; + std::cerr << "-------- CalciumGenericUsesPort<>::disconnect: "<< i << std::endl; port->disconnect(provideLastGivenValue); } catch(const CORBA::SystemException& ex){ - throw DSC_Exception(LOC(OSS() << "Impossible d'invoquer la méthode disconnect sur le port provide n°" - << i << " ( i>= 0)")); + std::cerr << "Can't call disconnect on provides port " << i << std::endl; } } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx index 51f13c273..71f157f16 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx @@ -408,7 +408,7 @@ namespace CalciumInterface { #ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl; + std::cout << "-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl; #endif CorbaDataType corbaData; @@ -437,7 +437,14 @@ namespace CalciumInterface { //TODO : GERER LES EXCEPTIONS ICI : ex le port n'est pas connecté if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { - port->put(*corbaData,t, -1); + try + { + port->put(*corbaData,t, -1); + } + catch ( const DSC_Exception & ex) + { + throw (CalciumException(CalciumTypes::CPATAL,ex.what())); + } //Le -1 peut être traité par le cst DataIdContainer et transformé en 0 //Etre obligé de mettre une étoile ds (*corbadata) va poser des pb pour les types <> seq #ifdef _DEBUG_ @@ -445,7 +452,14 @@ namespace CalciumInterface { #endif } else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { - port->put(*corbaData,-1, i); + try + { + port->put(*corbaData,-1, i); + } + catch ( const DSC_Exception & ex) + { + throw (CalciumException(CalciumTypes::CPATAL,ex.what())); + } #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl; #endif diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 564e361c7..8ad02f628 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -51,6 +51,8 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa _NS = new SALOME_NamingService(orb); _ResManager = new SALOME_ResourcesManager(orb,poa,_NS); _ContManager = new SALOME_ContainerManager(orb,poa,_ResManager,_NS); + _ResManager->_remove_ref(); + _ContManager->_remove_ref(); _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; @@ -72,8 +74,6 @@ SALOME_Launcher::~SALOME_Launcher() { MESSAGE("destructor"); delete _NS; - delete _ResManager; - delete _ContManager; std::map < string, BatchLight::BatchManager * >::const_iterator it; for(it=_batchmap.begin();it!=_batchmap.end();it++) delete it->second; diff --git a/src/Launcher/SALOME_LauncherServer.cxx b/src/Launcher/SALOME_LauncherServer.cxx index a08feccb6..5913d0ffb 100644 --- a/src/Launcher/SALOME_LauncherServer.cxx +++ b/src/Launcher/SALOME_LauncherServer.cxx @@ -22,6 +22,8 @@ #include #include #include +#include + using namespace std; void AttachDebugger() @@ -57,11 +59,17 @@ int main(int argc, char* argv[]) set_terminate(&terminateHandler); set_unexpected(&unexpectedHandler); } + /* Init libxml + * To avoid memory leak, need to call xmlInitParser in the main thread + * and not call xmlCleanupParser later (cause implicit reinitialization in thread) + */ + xmlInitParser(); + PortableServer::POA_var root_poa; PortableServer::POAManager_var pman; CORBA::Object_var obj; - CORBA::ORB_ptr orb = CORBA::ORB_init( argc , argv ) ; + CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; BEGIN_OF(argv[0]); @@ -78,7 +86,9 @@ int main(int argc, char* argv[]) try{ SALOME_Launcher *lServ=new SALOME_Launcher(orb,root_poa); pman->activate(); + lServ->_remove_ref(); orb->run(); + orb->destroy(); }catch(CORBA::SystemException&){ MESSAGE("Caught CORBA::SystemException."); }catch(PortableServer::POA::WrongPolicy&){ diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 13aa8a802..eec18908d 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -1097,10 +1097,12 @@ throw(ServiceUnreachable) vector dirList ; - string currentDir = Current_Directory(); + char* currentDir = Current_Directory(); _list_directory_recurs(dirList, "", currentDir); + free(currentDir); + return dirList; } @@ -1686,7 +1688,8 @@ _current_directory(vector& splitPath, { // --- directory, search in it - splitPath.push_back(CORBA::string_dup(bindingName[0].id)); + const char* bindingNameid=bindingName[0].id; + splitPath.push_back(bindingNameid); lengthResult++; CORBA::Object_var obj = _current_context->resolve(bindingName); diff --git a/src/ResourcesManager/SALOME_LoadRateManager.cxx b/src/ResourcesManager/SALOME_LoadRateManager.cxx index 42f08df99..f0df795cb 100644 --- a/src/ResourcesManager/SALOME_LoadRateManager.cxx +++ b/src/ResourcesManager/SALOME_LoadRateManager.cxx @@ -47,12 +47,30 @@ string SALOME_LoadRateManager::FindNext(const Engines::MachineList& hosts,MapOfP ns->Change_Directory("/Containers"); vector vec = ns->list_directory_recurs(); + Engines::Container_var cont; for(vector::iterator iter = vec.begin();iter!=vec.end();iter++){ - CORBA::Object_var obj=ns->Resolve((*iter).c_str()); - Engines::Container_var cont=Engines::Container::_narrow(obj); + try + { + CORBA::Object_var obj=ns->Resolve((*iter).c_str()); + cont=Engines::Container::_narrow(obj); + } + catch(CORBA::SystemException& ex) + { + MESSAGE("SALOME_LoadRateManager::FindNext CORBA::SystemException ignore it"); + continue; + } if(!CORBA::is_nil(cont)){ - string mach = cont->getHostName(); - machines[mach]++; + try + { + CORBA::String_var hostname = cont->getHostName(); + std::string mach=(const char*)hostname; + machines[mach]++; + } + catch(CORBA::SystemException& ex) + { + MESSAGE("SALOME_LoadRateManager::FindNext CORBA::SystemException ignore it"); + continue; + } } } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index c4232d56d..58eb63d01 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -120,16 +120,25 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { _resource.Clear(); if (xmlHasProp(aCurNode, (const xmlChar*)test_hostname)) - _resource.DataForSort._hostName = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_hostname); + { + xmlChar* hostname = xmlGetProp(aCurNode, (const xmlChar*)test_hostname); + _resource.DataForSort._hostName = (const char*)hostname; + xmlFree(hostname); + } else break; if (xmlHasProp(aCurNode, (const xmlChar*)test_alias)) - _resource.Alias = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_alias); + { + xmlChar* alias = xmlGetProp(aCurNode, (const xmlChar*)test_alias); + _resource.Alias = (const char*)alias; + xmlFree(alias); + } else _resource.Alias = ""; - switch ( ((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_protocol))[0] ) + xmlChar* protocol= xmlGetProp(aCurNode, (const xmlChar*)test_protocol); + switch ( protocol[0]) { case 'r': _resource.Protocol = rsh; @@ -142,8 +151,10 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) _resource.Protocol = rsh; break; } + xmlFree(protocol); - switch ( ((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_mode))[0] ) + xmlChar* mode=xmlGetProp(aCurNode, (const xmlChar*)test_mode); + switch ( mode[0] ) { case 'i': _resource.Mode = interactive; @@ -156,10 +167,13 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) _resource.Mode = interactive; break; } + xmlFree(mode); if (xmlHasProp(aCurNode, (const xmlChar*)test_batch)) { - std::string aBatch = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_batch); + xmlChar* batch = xmlGetProp(aCurNode, (const xmlChar*)test_batch); + std::string aBatch = (const char*)batch; + xmlFree(batch); if (aBatch == "pbs") _resource.Batch = pbs; else if (aBatch == "lsf") @@ -172,7 +186,9 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) if (xmlHasProp(aCurNode, (const xmlChar*)test_mpi)) { - std::string anMpi = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_mpi); + xmlChar* mpi = xmlGetProp(aCurNode, (const xmlChar*)test_mpi); + std::string anMpi = (const char*)mpi; + xmlFree(mpi); if (anMpi == "lam") _resource.mpi = lam; else if (anMpi == "mpich1") @@ -186,25 +202,53 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) } if (xmlHasProp(aCurNode, (const xmlChar*)test_user_name)) - _resource.UserName = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_user_name); + { + xmlChar* user_name= xmlGetProp(aCurNode, (const xmlChar*)test_user_name); + _resource.UserName = (const char*)user_name; + xmlFree(user_name); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_appli_path)) - _resource.AppliPath = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_appli_path); + { + xmlChar* appli_path = xmlGetProp(aCurNode, (const xmlChar*)test_appli_path); + _resource.AppliPath = (const char*)appli_path; + xmlFree(appli_path); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_os)) - _resource.OS = (const char*)xmlGetProp(aCurNode, (const xmlChar*)test_os); + { + xmlChar* os = xmlGetProp(aCurNode, (const xmlChar*)test_os); + _resource.OS = (const char*)os; + xmlFree(os); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_mem_in_mb)) - _resource.DataForSort._memInMB = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_mem_in_mb)); + { + xmlChar* mem_in_mb = xmlGetProp(aCurNode, (const xmlChar*)test_mem_in_mb); + _resource.DataForSort._memInMB = atoi((const char*)mem_in_mb); + xmlFree(mem_in_mb); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz)) - _resource.DataForSort._CPUFreqMHz = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz)); + { + xmlChar* cpu_freq_mhz = xmlGetProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz); + _resource.DataForSort._CPUFreqMHz = atoi((const char*)cpu_freq_mhz); + xmlFree(cpu_freq_mhz); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_nodes)) - _resource.DataForSort._nbOfNodes = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_nodes)); + { + xmlChar* nb_of_nodes = xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_nodes); + _resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes); + xmlFree(nb_of_nodes); + } if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node)) - _resource.DataForSort._nbOfProcPerNode = atoi((const char*)xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node)); + { + xmlChar* nb_of_proc_per_node = xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node); + _resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node); + xmlFree(nb_of_proc_per_node); + } // Process modules xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; @@ -214,8 +258,10 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) { - std::string aModuleName = (const char*)xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aModuleName = (const char*)module_name; _resource.ModulesList.push_back(aModuleName); + xmlFree(module_name); } } aCurSubNode = aCurSubNode->next; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 7c31fa87e..20b689b1d 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -358,9 +358,6 @@ void SALOME_ResourcesManager::WriteInXmlFile() // Free the document xmlFreeDoc(aDoc); - // Free the global variables that may have been allocated by the parser - xmlCleanupParser(); - fclose(aFile); MESSAGE("WRITING DONE!"); @@ -392,8 +389,6 @@ const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile() // Free the document xmlFreeDoc(aDoc); - // Free the global variables that may have been allocated by the parser - xmlCleanupParser(); fclose(aFile); } else @@ -831,6 +826,8 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const char *iorstr = _NS->getIORaddr(); command += "ORBInitRef NameService="; command += iorstr; + //It's in fact a CORBA::String allocated with new [] !!! + delete [] iorstr; } diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index 6cbaed7b5..f34170657 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -148,6 +148,7 @@ LocalTraceCollector:: ~LocalTraceCollector() int ret = pthread_join(*_threadId, NULL); if (ret) cerr << "error close LocalTraceCollector : "<< ret << endl; else DEVTRACE("LocalTraceCollector destruction OK"); + delete _threadId; _threadId = 0; _threadToClose = 0; } -- 2.39.2