From: caremoli Date: Fri, 6 Jun 2008 13:57:33 +0000 (+0000) Subject: CCAR: some corrections in : X-Git-Tag: V4_1_3~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7be586a98587a537bac17c8a8ce79df443c1863b;p=modules%2Fkernel.git CCAR: some corrections in : - disconnection of CALCIUM ports - shutdown of Python container - shutdown of C++ container - launching of standalone component --- diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 867411196..885750da9 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -295,8 +295,8 @@ void Engines_Component_i::destroy() delete _myConnexionToRegistry; _myConnexionToRegistry = 0 ; - _poa->deactivate_object(*_id) ; - delete(_id) ; + if(_id) + delete(_id) ; //SCRUTE(pd_refCount); _thisObj->_remove_ref(); //SCRUTE(pd_refCount); diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 0095b0bc5..d574fa95c 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -655,7 +655,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, } else { - int count=10; + int count=20; CORBA::Object_var obj = CORBA::Object::_nil() ; while ( CORBA::is_nil(obj) && count ) { @@ -678,6 +678,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, { MESSAGE("SALOME_Container::create_component_instance successful"); iobject=Engines::Component::_narrow(obj); + _listInstances_map[instanceName] = iobject; return iobject._retn(); } } diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 20f46f6d7..b172832ed 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -280,10 +280,19 @@ StartContainer(const Engines::MachineParameters& params, 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); + // shutdown the registered container if it exists + Engines::Container_var cont=Engines::Container::_narrow(obj); + if(!CORBA::is_nil(cont)) + { + try + { + cont->Shutdown(); + } + catch(CORBA::Exception&) + { + INFOS("CORBA::Exception ignored."); + } + } } //redirect stdout and stderr in a file diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 4eac58a65..41cfcaeee 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -304,6 +304,8 @@ class SALOME_ContainerPy_i (Engines__POA.Container): #------------------------------------------------------------------------- def Shutdown(self): + self._naming_service.Destroy_Name(self._containerName); + self._naming_service.Destroy_FullDirectory(self._containerName); self._orb.shutdown(0) pass @@ -316,32 +318,28 @@ class SALOME_ContainerPy_i (Engines__POA.Container): #============================================================================= -#initialise the ORB and find the root POA -print "Starting ",sys.argv[1] -orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) -poa = orb.resolve_initial_references("RootPOA") -if verbose(): print "ORB and POA initialized" - -#create an instance of SALOME_ContainerPy_i and a Container reference -#containerName = "FactoryServerPy" -MESSAGE( str(sys.argv) ) -containerName = sys.argv[1] -cpy_i = SALOME_ContainerPy_i(orb, poa, containerName) -if verbose(): print "SALOME_ContainerPy_i instance created ",cpy_i -cpy_o = cpy_i._this() -if verbose(): print "SALOME_ContainerPy_i instance activated ",cpy_o -sys.stdout.flush() -sys.stderr.flush() - -#activate the POA -poaManager = poa._get_the_POAManager() -poaManager.activate() - -#Block for ever -orb.run() - - - - - - +if __name__ == "__main__": + #initialise the ORB and find the root POA + if verbose():print "Starting ",sys.argv[1] + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + poa = orb.resolve_initial_references("RootPOA") + if verbose():print "ORB and POA initialized" + + #create an instance of SALOME_ContainerPy_i and a Container reference + #containerName = "FactoryServerPy" + MESSAGE( str(sys.argv) ) + containerName = sys.argv[1] + cpy_i = SALOME_ContainerPy_i(orb, poa, containerName) + if verbose():print "SALOME_ContainerPy_i instance created ",cpy_i + cpy_o = cpy_i._this() + if verbose():print "SALOME_ContainerPy_i instance activated ",cpy_o + sys.stdout.flush() + sys.stderr.flush() + + #activate the POA + poaManager = poa._get_the_POAManager() + poaManager.activate() + + #Block for ever + orb.run() + if verbose():print "SALOME_ContainerPy_i shutdown" diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx index 6f8fd6d97..7adf70ce1 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx @@ -58,22 +58,30 @@ public virtual POA_Ports::PortProperties, \ public GenericProvidesPort< __VA_ARGS__ , CalciumCouplingPolicy, calcium_provides_port > { \ private : \ - omni_semaphore _mustnotdisconnectyet; \ + omni_mutex _disconnect_mutex; \ + int _mustnotdisconnect; \ public : \ typedef __VA_ARGS__ DataManipulator; \ typedef DataManipulator::Type CorbaDataType; \ typedef GenericPort< DataManipulator , \ CalciumCouplingPolicy > Port; \ + specificPortName () : _mustnotdisconnect(0) {}; \ \ - specificPortName () :_mustnotdisconnectyet(0) {}; \ - \ virtual ~ specificPortName (); \ \ inline void disconnect(bool provideLastGivenValue) { \ - if (! _mustnotdisconnectyet.trywait() ) { \ - Port::disconnect(provideLastGivenValue); \ - } \ - } \ + _disconnect_mutex.lock(); \ + if(_mustnotdisconnect > 1) \ + { \ + _mustnotdisconnect--; \ + } \ + else if(_mustnotdisconnect == 1) \ + { \ + _mustnotdisconnect--; \ + Port::disconnect(provideLastGivenValue); \ + } \ + _disconnect_mutex.unlock(); \ + } \ inline void setDependencyType(CalciumTypes::DependencyType dependencyType) { \ Port::setDependencyType(dependencyType); \ } \ @@ -139,9 +147,15 @@ virtual void provides_port_changed(int connection_nbr, \ const Engines::DSC::Message message) { \ if ( message == Engines::DSC::AddingConnection) \ - _mustnotdisconnectyet.post(); \ + { \ + _disconnect_mutex.lock(); \ + _mustnotdisconnect++; \ + _disconnect_mutex.unlock(); \ + } \ else if ( message == Engines::DSC::RemovingConnection ) \ - disconnect(false); \ + { \ + disconnect(false); \ + } \ } \ }; \ diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index e4a44d309..81ad8d15a 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -32,6 +32,7 @@ import sys import time from omniORB import CORBA import CosNaming +import string from string import * from SALOME_utilities import * @@ -88,7 +89,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') if len(result_resolve_path)>1: # A directory is treated (not only an object name) # We had to test if the directory where ObjRef should be recorded @@ -156,7 +157,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') _context_name=[] for i in range(len(result_resolve_path)-1): _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir")) @@ -189,7 +190,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') _context_name = [] for i in range(len(result_resolve_path)): _context_name[CosNaming.NameComponent(result_resolve_path[i],"dir")] @@ -204,7 +205,46 @@ class SALOME_NamingServicePy_i(object): MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" ) except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) - - - + def Destroy_Name(self,Path): + resolve_path=string.split(Path,'/') + if resolve_path[0] == '': del resolve_path[0] + dir_path=resolve_path[:-1] + context_name=[] + for e in dir_path: + context_name.append(CosNaming.NameComponent(e,"dir")) + context_name.append(CosNaming.NameComponent(resolve_path[-1],"object")) + + try: + self._root_context.unbind(context_name) + except CosNaming.NamingContext.NotFound, ex: + return + except CORBA.Exception,ex: + return + + def Destroy_FullDirectory(self,Path): + context_name=[] + for e in string.split(Path,'/'): + if e == '':continue + context_name.append(CosNaming.NameComponent(e,"dir")) + + try: + context=self._root_context.resolve(context_name) + except CosNaming.NamingContext.NotFound, ex: + return + except CORBA.Exception,ex: + return + + bl,bi=context.list(0) + if bi is not None: + ok,b=bi.next_one() + while(ok): + for s in b.binding_name : + if s.kind == "object": + context.unbind([s]) + elif s.kind == "dir": + context.unbind([s]) + ok,b=bi.next_one() + + context.destroy() + self._root_context.unbind(context_name)