delete _myConnexionToRegistry;
_myConnexionToRegistry = 0 ;
_poa->deactivate_object(*_id) ;
- CORBA::release(_poa) ;
delete(_id) ;
//SCRUTE(pd_refCount);
_thisObj->_remove_ref();
Engines::Container_ptr Engines_Component_i::GetContainerRef()
{
// MESSAGE("Engines_Component_i::GetContainerRef");
- CORBA::Object_ptr o = _poa->id_to_reference(*_contId) ;
+ CORBA::Object_var o = _poa->id_to_reference(*_contId) ;
return Engines::Container::_narrow(o);
}
void Engines_Component_i::sendMessage(const char *event_type,
const char *message)
{
- _notifSupplier->Send(graphName(), nodeName(), event_type, message);
+ _notifSupplier->Send(_graphName.c_str(), _nodeName.c_str(), event_type, message);
}
//=============================================================================
//=============================================================================
Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
- PortableServer::POA_var poa,
+ PortableServer::POA_ptr poa,
char *containerName ,
int argc , char* argv[],
bool activAndRegist,
{
_id = _poa->activate_object(this);
_NS = new SALOME_NamingService();
- _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ;
+ _NS->init_orb( _orb ) ;
CORBA::Object_var obj=_poa->id_to_reference(*_id);
Engines::Container_var pCont
= Engines::Container::_narrow(obj);
+ _remove_ref();
_containerName = _NS->BuildContainerNameForNS(containerName,
hostname.c_str());
}
fileTransfer_i* aFileTransfer = new fileTransfer_i();
- _fileTransfer = Engines::fileTransfer::_narrow(aFileTransfer->_this());
+ CORBA::Object_var obref=aFileTransfer->_this();
+ _fileTransfer = Engines::fileTransfer::_narrow(obref);
+ aFileTransfer->_remove_ref();
}
}
{
MESSAGE("Container_i::~Container_i()");
delete _id;
+ if(_NS)
+ delete _NS;
}
//=============================================================================
if(_isServantAloneInProcess)
{
MESSAGE("Effective Shutdown of container Begins...");
- LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
- bp1->deleteInstance(bp1);
if(!CORBA::is_nil(_orb))
_orb->shutdown(0);
}
instanceName.c_str(),
studyId);
string iors = PyString_AsString(result);
+ Py_DECREF(result);
SCRUTE(iors);
Py_RELEASE_NEW_THREAD;
{
CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
iobject = Engines::Component::_narrow( obj ) ;
+ _listInstances_map[instanceName] = iobject;
}
return iobject._retn();
}
void Engines_Container_i::decInstanceCnt(string genericRegisterName)
{
+ if(_cntInstances_map.count(genericRegisterName)==0)
+ return;
string aGenRegisterName =genericRegisterName;
MESSAGE("Engines_Container_i::decInstanceCnt " << aGenRegisterName);
ASSERT(_cntInstances_map[aGenRegisterName] > 0);
myMachine=getShortHostName()
Component_path = self._containerName + "/" + self._instanceName
MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) )
- naming_service.Register(self._this(), Component_path)
+ id_o = poa.activate_object(self)
+ compo_o = poa.id_to_reference(id_o)
+ naming_service.Register(compo_o, Component_path)
# Add componentinstance to registry
obj = naming_service.Resolve('/Registry')
def destroy(self):
MESSAGE( "SALOME_ComponentPy_i::destroy" )
- self._poa.deactivate_object(self)
- CORBA.release(self._poa)
+ id = self._poa.servant_to_id(self)
+ self._poa.deactivate_object(id)
#-------------------------------------------------------------------------
std::string _instanceName ;
std::string _interfaceName ;
- CORBA::ORB_ptr _orb;
- PortableServer::POA_ptr _poa;
+ CORBA::ORB_var _orb;
+ PortableServer::POA_var _poa;
PortableServer::ObjectId * _id;
PortableServer::ObjectId * _contId;
Engines_Component_i * _thisObj ;
// Initialise the ORB.
//SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
- //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+ //There is no need to use a singleton as ORB_init returns a ref counted singleton
+ //The only difference is on delete : no automatic call to destroy
+ //But it's in general too late in exit
+ CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+ /*
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
CORBA::ORB_ptr orb = init(argc , argv ) ;
-
+ */
// LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
INFOS_COMPILATION;
BEGIN_OF(argv[0]);
// add new container to the kill list
#ifndef WNT
- ostrstream aCommand ;
+ stringstream aCommand ;
aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << ends ;
- system(aCommand.str());
+ system(aCommand.str().c_str());
#endif
Engines_Container_i * myContainer
#endif
HandleServerSideSignals(orb);
-
+
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ //Delete python container that destroy orb from python (pyCont._orb.destroy())
+ Py_Finalize();
}
catch(CORBA::SystemException&)
{
#-------------------------------------------------------------------------
+ def __del__(self ):
+ print "SALOME_Container_i.__del__"
+ self._orb.destroy()
+
def import_component(self, componentName):
MESSAGE( "SALOME_Container_i::import_component" )
ret=0
_NS->Destroy_Name(_ContainerManagerNameInNS);
PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
_poa->deactivate_object(oid);
- _remove_ref();
-}
-
-//=============================================================================
-/*! CORBA method:
- * shutdown the ContainerManager servant and kill the ContainerManager process
- */
-//=============================================================================
-void SALOME_ContainerManager::ShutdownWithExit()
-{
- MESSAGE("ShutdownWithExit");
- if(!CORBA::is_nil(_orb))
- {
- _orb->shutdown(0);
- }
-
- //exit( EXIT_SUCCESS );
+ //_remove_ref() has already been done at creation
+ //_remove_ref();
}
//=============================================================================
SCRUTE((*iter));
CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
Engines::Container_var cont=Engines::Container::_narrow(obj);
- if(!CORBA::is_nil(cont)){
- MESSAGE("ShutdownContainers: " << (*iter));
- cont->Shutdown();
- }
- else MESSAGE("ShutdownContainers: no container ref for " << (*iter));
+ if(!CORBA::is_nil(cont))
+ {
+ MESSAGE("ShutdownContainers: " << (*iter));
+ try
+ {
+ cont->Shutdown();
+ }
+ catch(CORBA::SystemException& e)
+ {
+ INFOS("CORBA::SystemException ignored : " << e);
+ }
+ catch(CORBA::Exception&)
+ {
+ INFOS("CORBA::Exception ignored.");
+ }
+ catch(...)
+ {
+ INFOS("Unknown exception ignored.");
+ }
+ }
+ else
+ MESSAGE("ShutdownContainers: no container ref for " << (*iter));
}
}
}
-//=============================================================================
-/*! CORBA Method:
- * Returns the PID of the container manager
- */
-//=============================================================================
-CORBA::Long SALOME_ContainerManager::getPID()
-{
- return (CORBA::Long)getpid();
-}
-
//=============================================================================
/*! CORBA Method:
* Find a suitable Container in a list of machines, or start one
const Engines::CompoList& componentList);
void Shutdown();
- void ShutdownWithExit();
void ShutdownContainers();
- CORBA::Long getPID();
-
static const char *_ContainerManagerNameInNS;
// Parallel extension
public:
Engines_Container_i();
Engines_Container_i(CORBA::ORB_ptr orb,
- PortableServer::POA_var poa,
+ PortableServer::POA_ptr poa,
char * containerName ,
int argc, char* argv[],
bool activAndRegist = true,
CORBA::Octet *buf = aBlock->get_buffer();
int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
ASSERT(nbWri == toFollow);
+ delete aBlock;
}
fclose(fp);
MESSAGE("end of transfer of " << comp_file_name);
_t_fileDistributedSource _fileDistributedSource;
Engines::SfState _state;
Engines::Container_ptr _container;
- Engines::Salome_file_ptr _default_source_Salome_file;
+ Engines::Salome_file_var _default_source_Salome_file;
};
#endif