Salome HOME
[bos #37406][CEA] Fixed segfault in YACS_YacsRuntimeTest on UB22,FD36 and FD37 by...
[modules/yacs.git] / src / runtime / CORBANode.cxx
index fcb9047be4e6458cb0aff3cfaa9ea449ed23bab9..4c0c6a63b62a0f97a9ba89550a3eede27c7f3bbb 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2006-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "CalStreamPort.hxx"
 #include "InPort.hxx"
 #include "TypeCode.hxx"
+#include "AutoLocker.hxx"
 
 #ifdef SALOME_KERNEL
-#include "SALOME_NamingService.hxx"
+#include "SALOME_NamingService_Wrapper.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "SALOME_Exception.hh"
 #endif
@@ -351,10 +352,7 @@ void SalomeNode::connectService()
   if(_setOfOutputDataStreamPort.size() == 0)return;
 
   CORBA::Object_var objComponent=((SalomeComponent*)_component)->getCompoPtr();
-  SALOME_NamingService NS(getSALOMERuntime()->getOrb()) ;
-  SALOME_LifeCycleCORBA LCC(&NS) ;
-  CORBA::Object_var obj = NS.Resolve("/ConnectionManager");
-  Engines::ConnectionManager_var manager=Engines::ConnectionManager::_narrow(obj);
+  ConnectionManager& manager = getSALOMERuntime()->getConnectionManager();
   Engines::Superv_Component_var me=Engines::Superv_Component::_narrow(objComponent);
   if( CORBA::is_nil(me) )
     {
@@ -398,7 +396,7 @@ void SalomeNode::connectService()
             }
           try
             {
-              id=manager->connect(me,port->getName().c_str(),other,(*iterout)->getName().c_str());
+              id=manager.connect(me,port->getName().c_str(),other,(*iterout)->getName().c_str());
             }
           catch(Engines::DSC::PortNotDefined& ex)
             {
@@ -467,22 +465,19 @@ void SalomeNode::disconnectService()
 {
   DEBTRACE( "SalomeNode::disconnectService: "<<getName());
   // in some rare cases, disconnectService can be called from 2 different threads
-  YACS::BASES::Lock lock(&_mutex);
+  YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
 
   if(ids.size() == 0)
     return;
 
-  SALOME_NamingService NS(getSALOMERuntime()->getOrb()) ;
-  SALOME_LifeCycleCORBA LCC(&NS) ;
-  CORBA::Object_var obj = NS.Resolve("/ConnectionManager");
-  Engines::ConnectionManager_var manager=Engines::ConnectionManager::_narrow(obj);
+  ConnectionManager& manager = getSALOMERuntime()->getConnectionManager();
   std::list<Engines::ConnectionManager::connectionId>::iterator iter;
   for(iter = ids.begin(); iter != ids.end(); iter++)
     {
       DEBTRACE("Trying to disconnect: " << *iter );
       try
         {
-          manager->disconnect(*iter,Engines::DSC::RemovingConnection);
+          manager.disconnect(*iter,Engines::DSC::RemovingConnection);
         }
       catch(Engines::ConnectionManager::BadId& ex)
         {